function AdjustImage(e) {
    if(Browser.ie=='6.0'){
        e.width = 31;
    }
    //alert(e.width+':'+e.height);
}

function RemainStrLength(ObjTextId,strLength,ObjSpanId)
{
        var i,str1,str2,str3,nLen;
        var r, re;                  
        re = /[\r\n]+/mg;
        str1 = document.getElementById(ObjTextId).value;
        //var tempstr2=document.getElementById(ObjTextId).value;
        nLen = 0;
        for(i=1;i<=str1.length;i++)
        {
              str2=str1.substring(i-1,i)
              str3=escape(str2);
              if(str3.length>3)
              {
                   nLen = nLen + 2;
              }
              else
              {
                   nLen = nLen + 1;
              }
         }
         var Objlength=parseInt(strLength);
         if(nLen>Objlength){
           var tempstr=str1.substring(0,Objlength);
           document.getElementById(ObjTextId).value=tempstr;
           document.getElementById(ObjSpanId).innerHTML="0 ";
           return false;
         }else{
            var leftstr=Objlength-parseInt(nLen);
            document.getElementById(ObjSpanId).innerHTML=leftstr+" ";
         }
         return true;
}
function isInteger(value)
{
    return parseInt(value) || value == 0;
}
function isFloat(value)
{
    return parseFloat(value) || parseFloat(value) == 0;
}
function convertToCurrency(value)
{
    return Math.round(value * 100) / 100;
}
function $get(id, element) {
    if (!element) return document.getElementById(id);
    if (element.getElementById) return element.getElementById(id);

    var nodeQueue = [];
    var childNodes = element.childNodes;
    for (var i = 0; i < childNodes.length; i++) {
        var node = childNodes[i];
        if (node.nodeType == 1) {
            nodeQueue[nodeQueue.length] = node;
        }
    }

    while (nodeQueue.length) {
        node = nodeQueue.shift();
        if (node.id == id) {
            return node;
        }
        childNodes = node.childNodes;
        for (i = 0; i < childNodes.length; i++) {
            node = childNodes[i];
            if (node.nodeType == 1) {
                nodeQueue[nodeQueue.length] = node;
            }
        }
    }

    return null;
}

	var previewFrom = null;
	var previewTimeoutId = null;
function getPosXY(a,offset){
       var p=offset?offset.slice(0):[0,0],tn;

      if(a){
            p[0]+=xPageX(a);
            p[1]+=xPageY(a);
         }
      return p;
}

function checkComplete(){

              checkComplete.__onload();
}

checkComplete.__onload=function(){
         clearInterval(checkComplete.__timeId);

}
//add message
function showPopupHelp(e,id){
   showPopupHelpExtend(e,id,50,0);   
}
function showPopupHelpExtend(e,id,offsetleft,offsettop)
{
    hidePopupHelp();
    previewFrom=e.target||e.srcElement;
    previewTimeoutId=setTimeout('_showPopupHelpExtend("'+id+'",'+offsetleft+','+offsettop+')',50);
    checkComplete.__img=null;
}
function hidePopupHelp(e){
try{
        if (e && (e.target||e.srcElement))
        {
            var target = e.target||e.srcElement;
            if(target.tagName.toUpperCase()=='A')
            {
                if (!target.onclick )
                {
                    if(target.target != "_blank")
                    {
                        window.location.href = target.href;
                         return;
                    }
                    else
                    {
                        window.open(target.href);
                        return;
                    }
                }
            }
        }
       clearTimeout(previewTimeoutId);
        for(i=0;i<ArrPopup.length;i++)
    {
        document.getElementById(ArrPopup[i].toString()).style.display='none';
        HideFrame(ArrPopup[i].toString());
    }
    
   }catch(e){
   }  
}
function isHideAction(e, elems){    
    try{
        if (e && (e.target||e.srcElement))
        {         
            var target = e.target||e.srcElement;            
            if(target.tagName.toUpperCase()=='A')
            {
                if (!target.onclick)
                {
                    if(target.target != "_blank")
                    {
                        window.location.href = target.href;
                        return false;
                    }
                    else
                        return false;
                }
            }
            var checkElem = target;
            
            while(checkElem) {
                //alert(checkElem.id);
                for (var i = 0; i < elems.length; i++)
                {
                    if (checkElem == elems[i])
                        return false;
                }
                
                checkElem = checkElem.parentNode;
            }
        }        
        return true;
    } catch(e) {
        return false;
    }
}

function _showPopupHelp(id){
    _showPopupHelpExtend(id,50,0)
}
function _showPopupHelpExtend(id,offsetleft,offsettop)
{
    var PopupId="Popup_"+id;
    PopupPreviewBox=document.getElementById(PopupId);
    var popupWidth = 285;
    if (PopupPreviewBox && PopupPreviewBox.firstChild)
    {
        var firstChildWidth = xWidth(PopupPreviewBox.firstChild);
        if (firstChildWidth  > 0)
            popupWidth = firstChildWidth;
    }
    checkComplete.__img=new Image();
    var picLink=previewFrom.getAttribute("pic-link");
    checkComplete.href=picLink;
    checkComplete.__timeId=setInterval("checkComplete()",20);    
    var pos=getPosXY(document.getElementById(id),[50,-0]);
    PopupPreviewBox.style.left=pos[0]-(popupWidth-offsetleft)+'px';//285 table's width
    PopupPreviewBox.style.top=(pos[1]+offsettop)+'px';
    PopupPreviewBox.style.display='block';
    
    SetFramePositionUnderPopup(PopupId);
}
function findFirstTable(Ele) {
    if (Ele.hasChildNodes()) {
        for(var i=0;i < Ele.childNodes.length;i++) {            
            if(Ele.childNodes[i].tagName=="TABLE")
                return Ele.childNodes[i];
            else {
                var oResult = findFirstTable(Ele.childNodes[i]);
                if (typeof(oResult) != "undefined")
                    return oResult;
            }
        }
    }
    
    return null;
}

var ArrPopup=new Array();
function addPopup(PopupId)
{
   ArrPopup.push(PopupId);
}

var buttons1983=new Array();
function addDisButton(btn)
{
    buttons1983.push(btn);

}
function findDisable()
{ 
    for(var i=0;i<this.buttons1983.length;i++)
    {
        try
        {       
            document.getElementById(buttons1983[i].toString()).disabled=true;
        }
        catch(e)
        {
            return;
        }
    }  
}
function xPageX(e) {
  if (xDef(e.pageX)) return e.pageX;
  var x = 0;
  while (e) {
    if (xDef(e.offsetLeft)) x += e.offsetLeft;
    e = xParent(e);
  }
  return x;
}
function xPageY(e) {
 
  if (xDef(e.pageY)) return e.pageY;
  var y = 0;
  while (e) {
    if (xDef(e.offsetTop)) y += e.offsetTop;
    e = xParent(e);
  }
  return y;
}
function xParent(e){

  var p=null;
  if (xDef(e.offsetParent)) p=e.offsetParent;
  else if (xDef(e.parentNode)) p=e.parentNode;
  else if (xDef(e.parentElement)) p=e.parentElement;
  else if (xDef(e.parentLayer)){if (e.parentLayer!=window) p=e.parentLayer;}
  return p;
}
function xDef() {
  for(var i=0; i<arguments.length; ++i){if(typeof(arguments[i])=="undefined") return false;}
  return true;
}
function xScrollTop() {
  var offset=0;
  if(xDef(window.pageYOffset)) offset=window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop) offset=document.documentElement.scrollTop;
  else if(document.body && xDef(document.body.scrollTop)) offset=document.body.scrollTop;
  return offset;
}
function xScrollLeft() {
  var offset=0;
  if(xDef(window.pageXOffset)) offset=window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft) offset=document.documentElement.scrollLeft;
  else if(document.body && xDef(document.body.scrollLeft)) offset=document.body.scrollLeft;
  return offset;
}
function xClientHeight() {
  // Variables:
  var xVersion='3.12',xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase();
  if(window.opera){
    xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
    if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
  }
  else if(document.layers) xNN4=true;
  else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}  

  var h=0;
  if(xOp5or6) h=window.innerHeight;
//  else if(xIE4Up && document.documentElement && document.documentElement.clientHeight)
  else if(!window.opera && document.documentElement && document.documentElement.clientHeight) // v3.12
    h=document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    h=document.body.clientHeight;
  else if(xDef(window.innerWidth,window.innerHeight,document.width)) {
    h=window.innerHeight;
    if(document.width>window.innerWidth) h-=16;
  }
  return h;
}
function xClientWidth() {
var xVersion='3.12',xOp7=false,xOp5or6=false,xIE4Up=false,xNN4=false,xUA=navigator.userAgent.toLowerCase();
if(window.opera){
    xOp7=(xUA.indexOf('opera 7')!=-1 || xUA.indexOf('opera/7')!=-1);
    if (!xOp7) xOp5or6=(xUA.indexOf('opera 5')!=-1 || xUA.indexOf('opera/5')!=-1 || xUA.indexOf('opera 6')!=-1 || xUA.indexOf('opera/6')!=-1);
  }
  else if(document.layers) xNN4=true;
  else {xIE4Up=document.all && xUA.indexOf('msie')!=-1 && parseInt(navigator.appVersion)>=4;}  
  
  var w=0;
  if(xOp5or6) w=window.innerWidth;
//  else if(xIE4Up && document.documentElement && document.documentElement.clientWidth)
  else if(!window.opera && document.documentElement && document.documentElement.clientWidth) // v3.12
    w=document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    w=document.body.clientWidth;
  else if(xDef(window.innerWidth,window.innerHeight,document.height)) {
    w=window.innerWidth;
    if(document.height>window.innerHeight) w-=16;
  }
  return w;
}
function xWidth(e) {
  var uW;
  var css=xDef(e.style);
  if(css && xDef(e.style.width,e.offsetWidth) && typeof(e.style.width)=="string") {   
    uW=e.offsetWidth;
  }
  else if(css && xDef(e.style.pixelWidth)) {
    uW=e.style.pixelWidth;
  }
  else if(xDef(e.clip) && xDef(e.clip.right)) {
    uW=e.clip.right;
  }
  return uW;
}
function  DisableRefresh()
{
  try
    {
        var formObj=document.forms["aspnetForm"];
    }
    catch(e)
    {
    var formObj=document.aspnetForm;
    
    }
    if (formObj.addEventListener) {
     
       formObj.addEventListener("submit", disRefresh,false);
    }
    else if (formObj.attachEvent) {
        formObj.attachEvent("onsubmit",disRefresh);
    }
}
function disRefresh()
{
    if(Page_IsValid)
        timeout=setTimeout("findDisable()",0); 
}
function evalLinkJavascript(sHref) {
    eval(sHref.replace("javascript:", ''));
}
function xAddEventListener(obj, evenTypeName, fn){
    if (obj.addEventListener){
        obj.addEventListener(evenTypeName, fn, true);
        return true;
    } else if (obj.attachEvent){
        return obj.attachEvent("on"+evenTypeName, fn);
    } else {
        return false;
    }
}
function CheckCookieEnabled(){
   
    if(document.cookie==""){
      var ShowCookie = document.createElement("div"); 
; 
ShowCookie.style.backgroundColor="red";
ShowCookie.innerHTML="Please Enable Cookies";
//document.body.appendChild(ShowCookie); 
document.body.insertBefore(ShowCookie, document.body.firstChild)

    }
}
CheckCookieEnabled();

function HideAllSelectObject()
{

    var obj=document.forms[0].getElementsByTagName("select");
    for(var j=0;j<obj.length;j++)
    {
        obj[j].style.visibility='hidden';
    }
}   
function ShowAllSelectObject()
{
    var obj=document.forms[0].getElementsByTagName("select");
    for(var j=0;j<obj.length;j++)
    {
        obj[j].style.visibility='visible';
    }
}
function GetObjPos(ATarget)
{
    var target = ATarget;
    var pos = new CPos(target.offsetLeft, target.offsetTop);
    
    var target = target.offsetParent;
    while (target)
    {
        pos.x += target.offsetLeft;
        pos.y += target.offsetTop;
        
        target = target.offsetParent
    }
    
    return pos;
}
function CPos(x, y)
{
    this.x = x;
    this.y = y;
}

function SetFramePositionUnderPopup(divId)
{
    if(navigator.userAgent.indexOf("MSIE 6.0")>-1)
    {
        var frameId="frame_"+divId;
        var frameObj=document.getElementById(frameId);
        var refSubObj=document.getElementById(divId);
        if(frameObj&&refSubObj)
        {
            frameObj.style.display=refSubObj.style.display;
            frameObj.style.top=parseInt(refSubObj.style.top.replace("px",""))+20+"px";
            frameObj.style.left=refSubObj.style.left;
            frameObj.height=refSubObj.clientHeight-20;
            frameObj.width=refSubObj.clientWidth;
            frameObj.style.zIndex=refSubObj.style.zIndex-1;
        }
    }
}
function HideFrame(divId)
{
    if(navigator.userAgent.indexOf("MSIE 6.0")>-1)
    {
        var frameId="frame_"+divId;
        if(document.getElementById(frameId))
        {
            document.getElementById(frameId).style.display="none";
        }
    }
}
function handleOpenLink(e) {
    if (typeof (e) == "undefined")
        e = event;
    return isALink(e);
}
function isALink(e) {
    try {
        if (e && (e.target || e.srcElement)) {
            var target = e.target || e.srcElement;
            if (target.tagName.toUpperCase() == 'A') {
                return true;
            }
        }
        return false;
    }
    catch (e) {
        return false;
    }
}
String.prototype.Trim=function(){return this.replace(/(^\s*)|(\s*$)/g,"");}