// Main function object fade
nereidFadeObjects = new Object();
nereidFadeTimers = new Object();

function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        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 = -1;
    }
    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);
    }
}

// Menu fade
function FadeOn(obj){ nereidFade(obj,0,0,50) }
function FadeOut(obj){ nereidFade(obj,100,0,50) }

// Banner fade
function BannerFadeOn(obj){ nereidFade(obj,60,100,30) }
function BannerFadeOut(obj){ nereidFade(obj,100,10,5) }

// Process fade
function ProcessFadeOn(obj){ nereidFade(obj,100,0,30) }
function ProcessFadeOut(obj){ nereidFade(obj,30,0,5) }

// Left Menu
function MenuLeftOn(obj){ obj.bgColor="#eeeeee" }
function MenuLeftOut(obj){ obj.bgColor="#ffffff" }

/* Modified to support Opera */ 
function bookmarksite(title,url){ 
  if (window.sidebar) // firefox 
    window.sidebar.addPanel(title, url, ""); 
  else if(window.opera && window.print){ // opera 
    var elem = document.createElement('a'); 
    elem.setAttribute('href',url); 
    elem.setAttribute('title',title); 
    elem.setAttribute('rel','sidebar'); 
    elem.click(); 
  } 
  else if(document.all)// ie 
    window.external.AddFavorite(url, title); 
} 

//  Hide & Show layer Function
var timer;
function HideShow(layer,status){
  if (status=="show"){ state='visible'; timer=0; }else{ state='hidden'; timer=200; }
  setTimeout(eval("document.all."+layer+".style.visibility = state"), timer);
}

function ShowProcess(layer){
  document.all.p1.style.visibility='hidden'; 
  document.all.p2.style.visibility='hidden';
  document.all.p3.style.visibility='hidden'; 
  document.all.p4.style.visibility='hidden';
  document.all.p5.style.visibility='hidden';
  document.all.p6.style.visibility='hidden';
  eval("document.all."+layer+".style.visibility='visible'");
}

function ShowProcess2(layer){
  document.all.p1.style.visibility='hidden'; 
  document.all.p2.style.visibility='hidden';
  document.all.p3.style.visibility='hidden'; 
  document.all.p4.style.visibility='hidden';
  document.all.p5.style.visibility='hidden';
  eval("document.all."+layer+".style.visibility='visible'");
}

function SwitchPrice(){
  document.all.p.value="";
  if(document.form1.t[0].checked && document.form1.t[1].checked){
    document.all.pl0.style.display='block';
	document.all.pl1.style.display='none';
	document.all.pl2.style.display='none';
  }else if (document.form1.t[0].checked){
    document.all.pl0.style.display='none';
	document.all.pl1.style.display='block';
	document.all.pl2.style.display='none';
  }else if (document.form1.t[1].checked){
    document.all.pl0.style.display='none';
	document.all.pl1.style.display='none';
	document.all.pl2.style.display='block';
  }
}

//##  Check input numberic only   ##
function Filter_Numberic() {
  var keycode = window.event.keyCode;
  if( keycode >= 37 && keycode <= 40 ) return true;  // arrow left, up, right, down  
  if( keycode >= 48 && keycode <= 57 ) return true;  // key 0-9
  if( keycode >= 96 && keycode <= 105 ) return true;  // numpad 0-9
  if( keycode == 110 || keycode == 190  ) return true;  // dot
  if( keycode == 8  ) return true;  // backspace
  if( keycode == 9 ) return true;  // tab
  if( keycode == 13 ) return true;  // enter
  if( keycode == 45 ||  keycode == 46 || keycode == 35 || keycode == 36) return true;  // insert, del, end, home
  return false;
}

//##  Send var to get method  ##
function SetPage(obj_name,obj_value){
  var PageNo = obj_name+"=";
  var url = new String( window.location );
  var newurl = url.substring(url.lastIndexOf("/")+1,url.length);

  if (newurl.indexOf("#")>0)
  {    
	var exitS = "N";
    var startS = newurl.indexOf("#")-1;
	var charS = newurl.substring(0,newurl.indexOf("#"));
	do {
      if (newurl.charAt(startS+1)=="?" || newurl.charAt(startS+1)=="&" || startS+1==newurl.length) {exitS="Y";} 
	  startS++;
	} while (exitS=="N");
	charS += newurl.substring(startS,newurl.length);
	newurl = charS;
  } 

  if (url.indexOf("?")>0){
    if (newurl.indexOf(PageNo)<0){
	  newurl += "&"+PageNo+obj_value;
	}else{
	  var getdata = "";
	  var arraydata = newurl.substring(newurl.indexOf("?")+1,newurl.length).split( "&" );
      for( i=0; i<arraydata.length; i++ ){ 
	    if (arraydata[i].indexOf(PageNo)<0){
	      getdata += "&"+arraydata[i];
		}else{
		  getdata += "&"+PageNo+obj_value
		}
      }	  
	  getdata = getdata.substring(1,getdata.length);
	  newurl = newurl.substring(0,newurl.indexOf("?")+1)+getdata;	  
	}	
  }else{
	newurl += "?"+PageNo+obj_value;
  }
  location.href=newurl;  
}

//  Paging
function GoToPage(pageno,order){
  var PageNo = "";
  if(order==undefined){PageNo = "pageno=";}else{PageNo = "pageno"+order+"=";}
  var url = new String( window.location );
  var newurl = url.substring(url.lastIndexOf("/")+1,url.length);

  if (newurl.indexOf("#")>0)
  {    
	var exitS = "N";
    var startS = newurl.indexOf("#")-1;
	var charS = newurl.substring(0,newurl.indexOf("#"));
	do {
      if (newurl.charAt(startS+1)=="?" || newurl.charAt(startS+1)=="&" || startS+1==newurl.length) {exitS="Y";} 
	  startS++;
	} while (exitS=="N");
	charS += newurl.substring(startS,newurl.length);
	newurl = charS;
  } 

  if (url.indexOf("?")>0){
    if (newurl.indexOf(PageNo)<0){
	  newurl += "&"+PageNo+pageno;
	}else{
	  var getdata = "";
	  var arraydata = newurl.substring(newurl.indexOf("?")+1,newurl.length).split( "&" );
      for( i=0; i<arraydata.length; i++ ){ 
	    if (arraydata[i].indexOf(PageNo)<0){
	      getdata += "&"+arraydata[i];
		}else{
		  getdata += "&"+PageNo+pageno
		}
      }	  
	  getdata = getdata.substring(1,getdata.length);
	  newurl = newurl.substring(0,newurl.indexOf("?")+1)+getdata;	  
	}	
  }else{
	newurl += "?"+PageNo+pageno;
  }
  location.href=newurl;    
}
