ie = document.all?1:0;
var cur_visit;
function hL(E){
	if (ie)
	{
		while (E.tagName!="TD")
		{E=E.parentElement;}
	}
	else
	{
		while (E.tagName!="TD")
		{E=E.parentNode;}
	}
    if (E!=cur_visit)
	     E.className = "H";
	E.children[0].style.color= "white";
	E.children[0].style.fontWeight="";
	E.children[0].style.textDecoration="underline";
//	E.children[0].children[0].style.fontStyle="italic";
}

function dL(E){
    if (E==cur_visit)
	   return;
	if (ie)
	{
		E.className = "";
	    E.children[0].style.color= "#5983CC";
	    E.children[0].style.fontWeight= "";
	    E.children[0].style.textDecoration="none";
	    E.children[0].style.fontStyle="";
		// E.children[0].children[0].className="menu";
	}
	else
	{
		E=E.parentNode;
	}
}

function go_url(E){
  var old_visit;
  old_visit = cur_visit;
  E.className="FIX";
  cur_visit=E;  
  if (old_visit!=null)
    dL(old_visit);

  E.children[0].click();
}

function Mouse_over(src){
	src.style.backgroundColor = "DDFFBB";
	src.style.fontStyle ="italic";
	src.style.textDecoration ="underline";
	src.style.fontWeight ="Bolder";
    src.style.fontSize = "14px";
	src.style.color ="ff0000";
	src.style.cursor="hand";
	return true;
 }

function Mouse_out(src){
	src.style.backgroundColor = "Gainsboro";
	src.style.fontStyle ="";
	src.style.fontWeight ="Bolder";
	src.style.textDecoration ="";
    src.style.fontSize = "14px"; 
	src.style.color ="0000ff";
	src.style.cursor="";
	return true;
}
   
function Text_OnFocus(src, cOvr) 
{   
   src.style.backgroundColor=cOvr;
   src.style.color="ff0000";
}

//  define the action when the text got focused
function Text_OnBlur(src, cOvr) 
{   
  src.style.backgroundColor = cOvr;
  src.style.color="0000ff";
}

function IsNumber(GivenStr)
{
    var str=GivenStr;
	var digit="1234567890.+- ";
	
	for (i=0; i<str.length; i++)
	{
	    if ( digit.indexOf(str.substring(i,i+1))<0 )  
		    return false;
	}
	return true;
}

function IsDate(str)
{
        var dateList;
		
		if (str.indexOf("/")>0 )  // date separate by "/"
		{  	dateList=str.split("/");
	 	    if ( parseInt(dateList[2])  < 1  ||   parseInt(dateList[2]) >3000 )   // year
				return false;
			if ( parseFloat(dateList[0])  < 1  ||   parseFloat(dateList[0]) >12 )   // month				 
		         return false;
			if ( parseFloat(dateList[1])  < 1  ||   parseFloat(dateList[1]) >31 )   // day
	 	         return false;
			if (  parseInt(dateList[0])  == 2 &&  parseInt(dateList[1]) >29 )   // February
		      return false;
		}
		else if (str.indexOf("-")>0 )
		{
			dateList=str.split("-");
			if (parseInt(dateList[0])<1000 || parseInt(dateList[0])>3000 )
			   return false;  // year is wrong!
			if (parseFloat(dateList[1])<1 || parseFloat(dateList[1])>12 )
			   return false; // month is wrong!
			if (parseFloat(dateList[2])<1 || parseFloat(dateList[2])>31 )
			   return false; // day is wrong!
			if ( parseInt(dateList[0])  == 2 && parseFloat(dateList[2])>29 )
			   return false; // check if February is wrong!
		}
		else
		   return false;
		return true;
}   

function ucfirst(str){
	 var list, str1,str2;
	 var i;
	 list=str.split(" ");
	 for (i=0; i<list.length;  i++)
	 {
	    str1=list[i].substr(0,1);
		str2=list[i].substr(1,list[i].length -1);
		str1 =str1.toUpperCase();
//		str2=str2.toLowerCase();
		list[i]=str1 + str2;   
	 }
	 str1="";
	 for (i=0; i<list.length;  i++)  
	 {  // loop to merge string 
	    if (i==0)
		    str1=list[i];
		else
			str1 =str1 +" "+ list[i];
	 }
	 return str1;
  }
  
function CreditCardDate(src)
{
    var datelist=src.value.split("/");
	var isDate = 0; 
	if (src.value.length != 5 ){
		isDate = 1;
	}

	if (parseFloat(datelist[0])>12 || parseFloat(datelist[0])<1 )   // month
	{
		isDate = 1;
	}
	if (parseFloat(datelist[1])<0 || parseFloat(datelist[1])>99 )  //year
	{
		isDate=1;
	}	
	if (isDate==1)
	{   alert("Please give a  valid expiry date! e.g. 09/03, format: month/year");
	    src.focus();
		return false;
	}
	return true;
}

function ProcessClick(urlStr,target)
{
        var oldUrl, oldTarget;
		oldUrl = document.ShipForm.action;
		oldTarget = document.ShipForm.target;
		document.ShipForm.target="";
	    switch (target)
		{
			case "local":
			   document.ShipForm.target="";
		       document.ShipForm.action=urlStr;
			   break;
			case "blank":
			   document.ShipForm.target="_blank";
		       document.ShipForm.action=urlStr;
			   break;
			case "NewWin":
		       window.open("" ,"NewWin","width=770,height=450,top=80,left=0,menubar=yes,sizeable=yes,toolbar=no,scrollbars=yes");
			   document.ShipForm.target="NewWin";
		       document.ShipForm.action=urlStr;
			   break;
			case "SaveWin":
		       window.open("" ,"SaveWin","width=700,height=100,top=200,left=150,menubar=no,sizeable=no,toolbar=no,scrollbars=no");
			   document.ShipForm.target="SaveWin";
		       document.ShipForm.action=urlStr;
			   break;
			default:
		}
	   document.ShipForm.submit();
	   document.ShipForm.action=oldUrl;
	   document.ShipForm.target = oldTarget ;
}

function isEmail(val)
{
  var i, j;
  	i=val.indexOf("@");	   
    if (i>0)	{
	    j=val.lastIndexOf(".");
		if (j<i){
		   return false;
		}
		if (j==val.length-1){
		   return false;
		}
	}
	else{
		  return false;
	}
	
	return true;
}

function remove_dash(src)
{
    Text_OnBlur(src,'FFFFFF');
	if (src.value.indexOf(".")>0 )
	   src.value = src.value.replace(".","");
	if (src.value.indexOf("-")>0 )
	   src.value = src.value.replace("-","");	
    if (src.value.length>0 ){
	    if ( !IsNumber(src.value) ){
		     alert("Please enter number string!");
			 src.focus();
		}
		   
	}
}

function IsAlpha(str){
//   var alphaChars = "abcdefghijklmnopqrstuvwxyz ";
   var i, ch;
   for (i=0; i<str.length;i++){
       ch=str.charAt(i);
	   if ( !( (ch>="a" && ch<="z" ) || (ch>="A" && ch<="Z" ) || ch==" " ) ) {
	      return false;
	   }
   }
   return true;
}
