function setCookie(theName,theValue,theDay)
{
	if ((theName != null) && (theValue != null))
	{
		expDay = "Wed, 01 Jan 2020 18:56:35 GMT";	
		//if (theDay != null)
		//{
		//	theDay = eval(theDay);	
		//	setDay.setTime(setDay.getTime()+(theDay*1000*60*60*24));
			setDay = new Date();
			setDay.setTime(setDay.getTime()+(1*1000*60*60*24));
			expDay = setDay.toGMTString();
		//}
		document.cookie = theName + "="+escape(theValue)+";expires="+expDay;
		return true;
	}
	return false;
}

function deleteCookie(theName)
{
	document.cookie = theName + "=;expires=Thu,01-Jan-70 00:00:01 GMT";
	return true;
}

function getCookie(theName)
{
	theName += "=";	
	theCookie = document.cookie+";";	
	start = theCookie.indexOf(theName);	
	if (start != -1)
	{
		end = theCookie.indexOf(";",start);
		return unescape(theCookie.substring(start+theName.length,end));
	}
	return false;
}

function viewCookie(CookieName)
{
	getValue = getCookie(CookieName);
	alert(CookieName+"="+getValue);
}

function buttonOut(object) {
   if (!document.all)
       return;
   vbuttonLeft = eval(object.name+"Left");
   vbuttonLeft.style.backgroundImage = "url('../../images/box-raised-left.jpg')";
   vbuttonCenter = eval(object.name+"Center");
   vbuttonCenter.style.backgroundImage = "url('../../images/box-raised-center.jpg')";
   vbuttonRight = eval(object.name+"Right");
   vbuttonRight.style.backgroundImage = "url('../../images/box-raised-right.jpg')";
   object.style.cursor = 'hand';
}

function buttonOver(object) {
   if (!document.all)
       return;   
   vbuttonLeft = eval(object.name+"Left");
   vbuttonLeft.style.backgroundImage = "url('../../images/box-lowered-left.jpg')";
   vbuttonCenter = eval(object.name+"Center");
   vbuttonCenter.style.backgroundImage = "url('../../images/box-lowered-center.jpg')";
   vbuttonRight = eval(object.name+"Right");
   vbuttonRight.style.backgroundImage = "url('../../images/box-lowered-right.jpg')";
   object.style.cursor = 'hand';
}

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();
function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -5;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;
    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

var arrayImg = new Array();

function preloadImage() {
   var argus = preloadImage.arguments;
   if(document.images) {
      var argus = preloadImage.arguments;
      for(var i=0;i<argus.length;i++) {
         arrayImg[i] = new Image();
         arrayImg[i].src = argus[i];
      }
   }
}

function chknum(obj,  isInt) {
   pcsstr = obj.value;
   
   if(pcsstr.length > 0) {
       flag = isNaN(pcsstr);
       if(flag == true) {
          obj.focus();
          alert("This field must be numeric value!");          
          return(false);
       }
       if(isInt==true) {
            if(pcsstr.indexOf(".")>-1) {
            obj.value = pcsstr.substr(0,pcsstr.indexOf("."));
                  obj.focus();
              alert("This field must be integer value!");          
              return(false);
         }
       }
   }
   else {
        obj.value = "0";
   }
   return(true);
}

function pickDate(sender) {
     strDate = alltrim(sender.value);
     if(strDate.length==0) {
          vdate = new  Date();   
          vyear = vdate.getFullYear();
          vyear = vyear.toString();
          vmonth = (vdate.getMonth()+1);
          vmonth = ((vmonth < 10) ? "0" : "") + vmonth;
          vday = vdate.getDate();
          vday = ((vday < 10) ? "0" : "") + vday;
          today = vmonth+"/"+vday+"/"+vyear.substr(2,2);                   
          strDate=today;
    }
    window.showModalDialog("/calendar.asp?date="+strDate,sender,"status:no;scroll:no;dialogWidth:220px;dialogHeight:230px;center:yes");                      
}

String.prototype.trim = function () {return this.replace(/^\s+|\s+$/g, "");}

function alltrim(inputString) 
{
   if(typeof inputString != "string") { return inputString; }
   
   var retValue = inputString; 
      
   var ch = retValue.substr(retValue.length-1, 1);   
   
   while (escape(ch) == "%A0" || escape(ch) == "%20") {        
      retValue = retValue.substr(0,retValue.length-1);
      ch = retValue.substr(retValue.length-1, 1);      
   }
   ch = retValue.substr(0,1);   
   while (escape(ch) == "%A0" || escape(ch) == "%20") {        
      retValue = retValue.substr(1,retValue.length-1);
      ch = retValue.substr(0, 1);      
   }
   return retValue;
} 

function round(number,X) {
    X = (!X ? 2 : X);              
    return Math.round(number*Math.pow(10,X))/Math.pow(10,X);
}
 
function format_number(pnumber,decimals) 
{  
  flag = isNaN(pnumber);
  if(flag == false) {
     if(pnumber.length>0) {
        if(pnumber.lastIndexOf(".")==-1) pnumber = pnumber + ".";
        dot = pnumber.lastIndexOf(".");
        adot = (pnumber.length - 1 - dot);
        for(k=decimals;k>adot;k--) {
            pnumber += "0";
        }
     }
  }
  return pnumber;  
}  

function StrReplace(sstr,ostr,nstr) {
    vpos = sstr.indexOf(ostr);
    vit = sstr;
    do {
       vit = vit.replace(ostr,nstr);        
       vpos = vit.indexOf(ostr);
    } while(vpos >= 0);
    dstr = vit;
    return dstr;
} 

function get_fixdec(in_data){
   fra_int=Math.floor(in_data);
   fra_dec=Math.floor((in_data-fra_int) * 16);
   fra_up=0;
   if(fra_dec != 0) {
	  fra_down=16;
  	  fra_up=fra_dec;
 	  while((fra_up/2) == Math.floor(fra_up/2)) {
	 	 fra_up=fra_up/2;
		 fra_down=fra_down/2;
	  }
   }
   if(fra_up==0)
      return(fra_int)
   else
      return(fra_int+fra_up/fra_down);
}

function CapitalStr(str) {
         nstr=str;
    if(alltrim(str).length>0) {
       str = str.toLowerCase();  
       ary = str.split(" ");
       nstr = "";
       for(idx=0;idx<ary.length;idx++) {
           ostr = (ary[idx].substr(0,1)).toUpperCase() +  ary[idx].substr(1,(ary[idx].length-1));
           nstr = nstr + ostr+" ";
       } 
    }
    return (nstr);
}

function Replace(sstr,ostr,nstr) {
    vpos = sstr.indexOf(ostr);
    vit = sstr;
    do {
       vit = vit.replace(ostr,nstr);        
       vpos = vit.indexOf(ostr);
    } while(vpos >= 0);
    return(vit);
} 
