function select_color(therow,thecolor){
  if (thecolor==null){
	therow.bgColor = "#FFFFCC";
  }else{
    therow.bgColor = thecolor;
  }
}
function unselect_color(therow,thecolor){
  if (thecolor==null){
	therow.bgColor = "#FFFFFF";
  }else{
	therow.bgColor = thecolor;
  }
}
function set_trstyle(thetd){
  var thetable,i=0,j=0;
  thetable=thetd.parentElement.parentElement;
  for (i=1;i<thetable.rows.length;i++){
	thetable.rows[i].style.fontWeight="normal";
  }
  thetd.parentElement.style.fontWeight="bold";
}
function GetoffsetLeft(theObject){
  var absLeft = 0;
  var tmpObject = theObject;
  while (tmpObject != null){
	absLeft += tmpObject.offsetLeft;
	tmpObject = tmpObject.offsetParent;
  }
  return(absLeft); //return theObject's absolute offsetLeft
}
function GetoffsetTop(theObject){
  var absTop = 0;
  var tmpObject = theObject;
  while (tmpObject != null){
    absTop += tmpObject.offsetTop;
	tmpObject = tmpObject.offsetParent;
  }
  return(absTop); //return theObj's absolute offsetTop
}
function go_para(){
  window.close();
}
function show_logo(){
  //var logo_div=document.all.item("company_logo");
  var logo_div=document.getElementById("company_logo");
  //var logo_img=document.all.item("company_img");
  var logo_img=document.getElementById("company_img");
  if (logo_div!=null){
    if (logo_div.style.display=="none"){
      logo_div.style.display="";
	  logo_img.src="/image/minus3.gif";
    }else{
      logo_div.style.display="none";
	  logo_img.src="/image/plus3.gif";
    }
  }
}
function winopen(theurl,thewidth,theheight,thename){
  var tmpwin,tmpname;
  if (thename==null){
  	tmpname="popup";
  }else{
  	tmpname=thename;
  }
  tmpwin=window.open(theurl,tmpname,"toolbar=yes,location=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,width="+thewidth.toString()+",height="+theheight.toString());
  tmpwin.moveTo(0,0);
}
function CancelEvent(){
	event.returnValue = false;
}
function go_submit(){
  var keepDIV = "";
  keepDIV += "<DIV style=\"background-color:#EEEEEE; position:absolute; top:0px; left:0px; ";
  keepDIV += "width:" + (document.body.scrollWidth).toString() + "px; height:" + (document.body.scrollHeight+10).toString() + "px;\" ";
  keepDIV += "onSelect=\"\">";
  keepDIV += "<table width=\"100%\" height=\"" + (document.body.clientHeight * 0.8).toString() + "\" border=\"0\" align=\"center\">";
  keepDIV += "<tr><td valign=\"middle\">";
  keepDIV += "<table class=\"index\" style=\"position:absolute; width:200px; height:80px; ";
  keepDIV += "top:"+(document.body.scrollTop + (document.body.clientHeight>>1) - 80).toString()+"; left:"+(document.body.scrollLeft + (document.body.clientWidth>>1) - 100).toString()+";\">";
  keepDIV += "<tr><td class=\"affix\">Receiving Data...</td></tr></table>";
  keepDIV += "</td></tr></table>";
  //keepDIV += "<IFRAME frameborder=\"no\" scrolling=\"no\" src=\"/include/blank.asp\" style=\"position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:-1;\"></IFRAME>";
  keepDIV += "</DIV>";
  var theform=document.forms[0];
  var i=0,elelen=0,tmpele;
  if (check_form(theform)){
	if ((elelen > 10)&&(theform.target=="_self")){
		document.oncontextmenu = CancelEvent;
		document.onkeydown = CancelEvent;
		document.onselectstart = CancelEvent;
		document.ondragstart = CancelEvent;
		elelen=theform.elements.length;
		for (i=0;i<elelen;i++){
			tmpele=theform.elements[i];
			switch (tmpele.type){
				case "select-one":
				case "select-multiple":
					tmpele.style.visibility = "hidden";
					break;
			}
		}
		for (i=0;i<window.frames.length;i++){
			if ((window.frames[i].name!=null)&&(window.frames[i].name!="")){				
				document.all.item(window.frames[i].name).style.visibility = "hidden";
			}
		}
		document.body.insertAdjacentHTML("beforeEnd", keepDIV);
		//document.body.style.overflow="hidden";
		//document.body.scrollTop=0;
		//document.body.scrollLeft=0;
		window.setTimeout("document.forms[0].submit()",10);
	}else{
		document.forms[0].submit();
	}
  }
}
function go_close(){
  window.close();
}
function show_body(){
  document.body.style.display = "";
}
function set_tab(){
  var maxcol=0,tmpele;
  var focus_tag=false;
  var thename="",namelng=0;
  var theform = eval("document.forms[0]");
  if (theform!=null){
	elelen=theform.elements.length;
	for (i=0;i<elelen;i++){
	  tmpele = theform.elements[i];
	  switch (tmpele.type){
	  	case "text":
			if (tmpele.readOnly==true){
			  tmpele.style.backgroundColor = "gainsboro";
			}
			tmpele.maxLength="50";
			thename=tmpele.name.toLowerCase();
			namelng=thename.length;
			//document.forms[0].elements[i].tabIndex="1";
			if ((thename.substr(namelng-5,5)=="_date")
			||(thename.substr(namelng-4,4)=="_etd")
			||(thename.substr(namelng-4,4)=="_eta")
			||(thename.substr(namelng-9,9)=="downlimit")
			||(thename.substr(namelng-7,7)=="uplimit")){
			  tmpele.onfocus = new Function("CreateMonthView(this)");
			  tmpele.onclick = new Function("CreateMonthView(this)");
			  tmpele.onblur = new Function("DeleteMonthView(this)");
			}
			break;
		case "textarea":
			if ((tmpele.wrap.toLowerCase()=="soft")&&(tmpele.rows>1)&&(tmpele.style.display!="none")){
				tmpele.style.display="none";
				tmpele.wrap="OFF";
				tmpele.style.display="";
			}
			break;
	  }
	}
  }
}
function get_option(thename, theval, thetype){
	var theform = document.forms[0];
	set_option(thename, theval, thetype);
	switch (thetype){
		case "0":
			sel_name = "customer_short_list";
			break;
		case "1":
			sel_name = "customer_full_list";
			break;
		case "2":
			sel_name = "city_short_list";
			break;
		case "4":
			sel_name = "vsl_short_list";
			break;
	}
    if (theform.elements(sel_name).options.length>1){
      theform.elements(sel_name).selectedIndex=1;
    }else{
      theform.elements(sel_name).selectedIndex=0;
    }
}
function set_option(thename, theval, thetype){
	var theform = document.forms[0];
	var theobj = theform.elements[thename];
	if (theobj.value == theval){
		var xmlDoc = new ActiveXObject("MSXML2.DOMDocument");
		xmlDoc.async = false;
		switch (thetype){
			case "0":
			case "1":
				xmlDoc.load("/include/get_customer_list.asp?type=" + escape(thetype) + "&query=" + escape(theval));
				break;
			case "2":
				xmlDoc.load("/include/get_city_list.asp?query=" + escape(theval));
				break;
			case "4":
				xmlDoc.load("/include/get_vessel_list.asp?query=" + escape(theval));
		}
		var pErr = xmlDoc.parseError;
		if (pErr.errorCode==0){
			theform.elements[xmlDoc.documentElement.getAttribute("name").toString()].outerHTML = xmlDoc.documentElement.xml.toString();
		}else{
			alert("xml Error:" + pErr.reason);
		}
		xmlDoc = null;
	}
}
function hide_customer_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if ((document.activeElement.name=="customer_short_list")
	 || (document.activeElement.name=="customer_short_div")){
	  active_tag=true;
	}
  }
  if (active_tag==false){
    document.active_customer_name="";
	//document.all.item("customer_short_div").style.display="none";
	document.getElementById("customer_short_div").style.display="none";
  }
}
function hide_fee_list(theno){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if (document.activeElement.name=="fee_short_list"){
	  active_tag=true;
	}
  }
  if (active_tag==false){
    document.active_fee_no="";
	//document.all.item("fee_short_div").style.display="none";
	document.getElementById("fee_short_div").style.display="none";
    set_feecurrency(theno);
  }
}
function hide_city_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if ((document.activeElement.name=="city_short_list")
	 || (document.activeElement.name=="city_short_div")){
	  active_tag=true;
	}
  }
  if (active_tag==false){
    document.active_city_name="";
	//document.all.item("city_short_div").style.display="none";
	document.getElementById("city_short_div").style.display="none";
  }
}
function hide_vsl_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if ((document.activeElement.name=="vsl_short_list")
	 || (document.activeElement.name=="vsl_short_div")){
	  active_tag=true;
	}
  }
  if (active_tag==false){
    document.active_vsl_name="";
	//document.all.item("vsl_short_div").style.display="none";
	document.getElementById("vsl_short_div").style.display="none";
  }
}
function hide_state_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if (document.activeElement.name=="state_short_list"){
	  active_tag=true;
	}
  }
  if (active_tag==false){
	//document.all.item("state_short_div").style.display="none";
	document.getElementById("state_short_div").style.display="none";
  }
}
function hide_sales_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if (document.activeElement.name=="sales_short_list"){
	  active_tag=true;
	}
  }
  if (active_tag==false){
	//document.all.item("sales_short_div").style.display="none";
	document.getElementById("sales_short_div").style.display="none";
  }
}
function hide_skyway_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if (document.activeElement.name=="skyway_short_list"){
	  active_tag=true;
	}
  }
  if (active_tag==false){
	//document.all.item("skyway_short_div").style.display="none";
	document.getElementById("skyway_short_div").style.display="none";
  }
}
function hide_job_list(){
  var theform=document.forms[0];
  var active_tag=false;
  if (document.activeElement.name!=null){
    if (document.activeElement.name=="job_short_list"){
	  active_tag=true;
	}
  }
  if (active_tag==false){
	//document.all.item("job_short_div").style.display="none";
	document.getElementById("job_short_div").style.display="none";
  }
}
function show_vsllist(thename){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  if (theform.elements("vsl_short_list")==null){
    return false;
  }
  thecodeobj=theform.elements(thename+"_code");
  thenameobj=theform.elements(thename+"_name");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  document.getElementById("vsl_short_div").style.posTop = GetoffsetTop(thecodeobj);
  document.getElementById("vsl_short_div").style.posLeft = GetoffsetLeft(thecodeobj) + thecodeobj.offsetWidth + 1;
  document.getElementById("vsl_short_div").style.display = "";
  document.active_vsl_name = thename;
  theform.elements("vsl_short_list").outerHTML = "<SELECT class=\"combox\" name=\"vsl_short_list\" onChange=\"set_selindex('vsl');\" onBlur=\"document.all.item('vsl_short_div').style.display='none'\"><option value=\"\"></option><option value=\"" + thecodeobj.value.replace(/"/g,"&quot;") + "\">" + thenameobj.value.replace(/"/g,"&quot;") + "</option></SELECT>";
  theform.elements("vsl_short_list").value=thecodeobj.value;
}
function show_citylist(thename){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  if (theform.elements("city_short_list")==null){
    return false;
  }
  thecodeobj=theform.elements(thename+"_code");
  thenameobj=theform.elements(thename+"_name");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  document.getElementById("city_short_div").style.posTop = GetoffsetTop(thecodeobj);
  document.getElementById("city_short_div").style.posLeft = GetoffsetLeft(thecodeobj) + thecodeobj.offsetWidth + 1;
  document.getElementById("city_short_div").style.display = "";
  document.active_city_name = thename;
  theform.elements("city_short_list").outerHTML = "<SELECT class=\"combox\" name=\"city_short_list\" onChange=\"set_selindex('city');\" onBlur=\"document.all.item('city_short_div').style.display='none'\"><option value=\"\"></option><option value=\"" + thecodeobj.value.replace(/"/g,"&quot;") + "\">" + thenameobj.value.replace(/"/g,"&quot;") + "</option></SELECT>";
  theform.elements("city_short_list").value=thecodeobj.value;
}
function show_custlist(thename){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  if (theform.elements("customer_short_list")==null){
    return false;
  }
  switch (thename){
    case "nominate":
	  thecodeobj=theform.elements("intro_type");
	  thenameobj=theform.elements("intro_short");
	  thefullobj=theform.elements("intro_full");
	  break;
	default:
	  thecodeobj=theform.elements(thename+"_code");
	  thenameobj=theform.elements(thename+"_short");
	  thefullobj=theform.elements(thename+"_full");
  }
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  //document.all.item("customer_short_div").style.posTop = GetoffsetTop(thecodeobj);
  //document.all.item("customer_short_div").style.posLeft = GetoffsetLeft(thecodeobj) + thecodeobj.offsetWidth + 1;
  //document.all.item("customer_short_div").style.display = "";
  document.getElementById("customer_short_div").style.posTop = GetoffsetTop(thecodeobj);
  document.getElementById("customer_short_div").style.posLeft = GetoffsetLeft(thecodeobj) + thecodeobj.offsetWidth + 1;
  document.getElementById("customer_short_div").style.display = "";
  document.active_customer_name = thename;
  //set_option(theobj.name, theobj.value, "0");
  //set_option(theobj.name, theobj.value, "1");
  theform.elements("customer_short_list").outerHTML = "<SELECT class=\"combox\" name=\"customer_short_list\" onChange=\"set_selindex('customer');\" onBlur=\"document.all.item('customer_short_div').style.display='none'\"><option value=\"\"></option><option value=\"" + thecodeobj.value.replace(/"/g,"&quot;") + "\">" + thenameobj.value.replace(/"/g,"&quot;") + "</option></SELECT>";
  theform.elements("customer_full_list").outerHTML = "<SELECT name=\"customer_full_list\"><option value=\"\"></option><option value=\"" + thefullobj.value.replace(/"/g,"&quot;") + "\">" + thecodeobj.value.replace(/"/g,"&quot;") + "</option></SELECT>";
  theform.elements("customer_short_list").value=thecodeobj.value;
}
function show_customer_list(thename){
  var theform=document.forms[0];
  var theobj;
  if (theform.elements("customer_short_list")==null){
    return false;
  }
  switch (thename){
    case "nominate":
	  theobj=theform.elements("intro_type");
	  break;
	default:
	  theobj=theform.elements(thename+"_code");
  }
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  document.active_customer_name=thename;
  theform.elements("customer_short_list").value=theobj.value;
  //document.all.item("customer_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("customer_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("customer_short_div").style.display = "";
  document.getElementById("customer_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("customer_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("customer_short_div").style.display = "";
}
function show_fee_list(theno){
  var theform=document.forms[0];
  if (theform.elements("fee_short_list")==null){
    return false;
  }
  var theobj=theform.elements("fee_code_"+theno);
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  document.active_fee_no=theno;
  theform.elements("fee_short_list").value=theobj.value;
  //document.all.item("fee_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("fee_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("fee_short_div").style.display = "";
  document.getElementById("fee_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("fee_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("fee_short_div").style.display = "";
}
function show_city_list(thename){
  var theform=document.forms[0];
  if (theform.elements("city_short_list")==null){
    return false;
  }
  var theobj=theform.elements(thename+"_code");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  document.active_city_name=thename;  
  theform.elements("city_short_list").value=theobj.value;
  //document.all.item("city_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("city_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("city_short_div").style.display = "";
  document.getElementById("city_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("city_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("city_short_div").style.display = "";
}
function show_vsl_list(thename){
  var theform=document.forms[0];
  if (theform.elements("vsl_short_list")==null){
    return false;
  }
  var theobj=theform.elements(thename+"_code");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  document.active_vsl_name=thename;  
  theform.elements("vsl_short_list").value=theobj.value;
  //document.all.item("vsl_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("vsl_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("vsl_short_div").style.display = "";
  document.getElementById("vsl_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("vsl_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("vsl_short_div").style.display = "";
}
function show_state_list(){
  var theform=document.forms[0];
  if (theform.elements("state_short_list")==null){
    return false;
  }
  var theobj=theform.elements("state_code");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  theform.elements("state_short_list").value=theobj.value;
  //document.all.item("state_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("state_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("state_short_div").style.display = "";
  document.getElementById("state_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("state_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("state_short_div").style.display = "";
}
function show_sales_list(){
  var theform=document.forms[0];
  if (theform.elements("sales_short_list")==null){
    return false;
  }
  var theobj=theform.elements("sales_code");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  theform.elements("sales_short_list").value=theobj.value;
  //document.all.item("sales_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("sales_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("sales_short_div").style.display = "";
  document.getElementById("sales_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("sales_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("sales_short_div").style.display = "";
}
function show_skyway_list(){
  var theform=document.forms[0];
  if (theform.elements("skyway_short_list")==null){
    return false;
  }
  var theobj=theform.elements("skyway_code");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  theform.elements("skyway_short_list").value=theobj.value;
  //document.all.item("skyway_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("skyway_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("skyway_short_div").style.display = "";
  document.getElementById("skyway_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("skyway_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("skyway_short_div").style.display = "";
}
function show_job_list(){
  var theform=document.forms[0];
  if (theform.elements("job_short_list")==null){
    return false;
  }
  var theobj=theform.elements("small_job_no");
  if ((theobj.readOnly==true)||(theobj.disabled==true)){
    return;
  }
  theform.elements("job_short_list").value=theobj.value;
  //document.all.item("job_short_div").style.posTop = GetoffsetTop(theobj);
  //document.all.item("job_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  //document.all.item("job_short_div").style.display = "";
  document.getElementById("job_short_div").style.posTop = GetoffsetTop(theobj);
  document.getElementById("job_short_div").style.posLeft = GetoffsetLeft(theobj) + theobj.offsetWidth + 1;
  document.getElementById("job_short_div").style.display = "";
}
function check_vsllist(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  thecodeobj=theform.elements(thename+"_code");
  thenameobj=theform.elements(thename+"_name");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  if (thetag==0){
    window.setTimeout("get_option('"+thecodeobj.name+"','"+thecodeobj.value.replace(/'/g,"\\\'")+"','4')",50);	
  }
  if (thetag==1){
    //get_option(thecodeobj.name,thecodeobj.value,"4");
	thecodeobj.value = theform.elements("vsl_short_list").value;
	var selIndex = theform.elements("vsl_short_list").selectedIndex;
	if (selIndex>=0){
	  thenameobj.value = theform.elements("vsl_short_list").options[selIndex].text;
	}else{
	  thenameobj.value = "";
	}
	hide_vsl_list();
  }
}
function check_citylist(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  thecodeobj=theform.elements(thename+"_code");
  thenameobj=theform.elements(thename+"_name");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  if (thetag==0){
    window.setTimeout("get_option('"+thecodeobj.name+"','"+thecodeobj.value.replace(/'/g,"\\\'")+"','2')",50);	
  }
  if (thetag==1){
    //get_option(thecodeobj.name,thecodeobj.value,"2");
	thecodeobj.value = theform.elements("city_short_list").value;		
	var selIndex = theform.elements("city_short_list").selectedIndex;
	if (selIndex>=0){
	  thenameobj.value = theform.elements("city_short_list").options[selIndex].text;
	}else{
	  thenameobj.value = "";
	}
	hide_city_list();
  }
}
function check_custlist(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj,thenameobj,thefullobj;
  switch (thename){
    case "nominate":
	  thecodeobj=theform.elements("intro_type");
	  thenameobj=theform.elements("intro_short");
	  thefullobj=theform.elements("intro_full");
	  break;
	default:
	  thecodeobj=theform.elements(thename+"_code");
	  thenameobj=theform.elements(thename+"_short");
	  thefullobj=theform.elements(thename+"_full");
  }
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  if (thetag==0){
    window.setTimeout("get_option('"+thecodeobj.name+"','"+thecodeobj.value.replace(/'/g,"\\\'")+"','0')",50);	
  }
  if (thetag==1){
    get_option(thecodeobj.name,thecodeobj.value,"1");
	thecodeobj.value = theform.elements("customer_short_list").value;
	var selIndex = theform.elements("customer_short_list").selectedIndex;
	if (selIndex>=0){
	  thenameobj.value = theform.elements("customer_short_list").options[selIndex].text;
	}else{
	  thenameobj.value = "";
	}
	thefullobj.value = theform.elements("customer_full_list").value;
	hide_customer_list();
  }
}
function check_customer(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements(thename+"_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements(thename+"_short");
  var thefullobj=theform.elements(thename+"_full");
  var selidx=0;
  if ((theform.elements("customer_short_list").selectedIndex != -1)
    ||(thecodeobj.value.length <= 6)||(thetag==1)){
    selidx = get_selindex(theform.elements("customer_short_list"),thecodeobj);
    theform.elements("customer_short_list").selectedIndex=selidx;
  }
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("customer_short_list").options[selidx].value;
	  if (thenameobj!=null){
	  	thenameobj.value = theform.elements("customer_short_list").options[selidx].text;
	  }
      thefullobj.value = theform.elements("customer_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
	  if (thenameobj!=null){
	  	thenameobj.value = "";
	  }	  
      thefullobj.value = "";
    }
	hide_customer_list();
  }
}
function check_nominate(thetag){
  var theform=document.forms[0];
  var selidx=0;
  var thecodeobj=theform.elements("intro_type");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  selidx = get_selindex(theform.elements("customer_short_list"),thecodeobj);
  theform.elements("customer_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("customer_short_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
    }
	hide_customer_list();
  }
}
function check_fee(theno,thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements("fee_code_"+theno);
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  //var thenameobj=eval("theform."+thename+"_name");
  var selidx=0;
  selidx = get_selindex(theform.elements("fee_short_list"),thecodeobj);
  theform.elements("fee_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("fee_short_list").options[selidx].value;
      //thenameobj.value = theform.elements("fee_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      //thenameobj.value = "";
    }
	hide_fee_list(theno);
  }
}
function check_city(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements(thename+"_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements(thename+"_name");
  var selidx=0;
  selidx = get_selindex(theform.elements("city_short_list"),thecodeobj);
  theform.elements("city_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("city_short_list").options[selidx].value;
      thenameobj.value = theform.elements("city_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thenameobj.value = "";
    }
	hide_city_list();
  }
}
function check_vsl(thename,thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements(thename+"_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements(thename+"_name");
  var selidx=0;
  selidx = get_selindex(theform.elements("vsl_short_list"),thecodeobj);
  theform.elements("vsl_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("vsl_short_list").options[selidx].value;
      thenameobj.value = theform.elements("vsl_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thenameobj.value = "";
    }
	hide_vsl_list();
  }
}
function check_state(thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements("state_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements("state_full");
  var selidx=0;
  selidx = get_selindex(theform.elements("state_short_list"),thecodeobj);
  theform.elements("state_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("state_short_list").options[selidx].value;
      thenameobj.value = theform.elements("state_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thenameobj.value = "";
    }
	hide_state_list();
  }
}
function check_sales(thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements("sales_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements("sales_name");
  var selidx=0;
  selidx = get_selindex(theform.elements("sales_short_list"),thecodeobj);
  theform.elements("sales_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("sales_short_list").options[selidx].value;
      thenameobj.value = theform.elements("sales_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thenameobj.value = "";
    }
	hide_sales_list();
  }
}
function check_skyway(thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements("skyway_code");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thenameobj=theform.elements("skyway_name");
  var selidx=0;
  selidx = get_selindex(theform.elements("skyway_short_list"),thecodeobj);
  theform.elements("skyway_short_list").selectedIndex=selidx;
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("skyway_short_list").options[selidx].value;
      thenameobj.value = theform.elements("skyway_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thenameobj.value = "";
    }
	hide_skyway_list();
  }
}
function check_job(thetag){
  var theform=document.forms[0];
  var thecodeobj=theform.elements("small_job_no");
  if ((thecodeobj.readOnly==true)||(thecodeobj.disabled==true)){
    return;
  }
  var thefullobj=theform.elements("big_job_no");
  var selidx=0;
  selidx = get_selindex(theform.elements("job_short_list"),thecodeobj);
  if (thetag==1){
    if (selidx>=0){
	  thecodeobj.value = theform.elements("job_short_list").options[selidx].value;
      thefullobj.value = theform.elements("job_full_list").options[selidx].value;
    }else{
      thecodeobj.value = "";
      thefullobj.value = "";
    }
	hide_job_list();
  }
}
function get_curindex(sltObj,txtVal,txtLen,sltCur){
  var tmpCur = sltCur;
  var tmpVal = "";
  if (txtLen < 3){
    return (sltCur);
  }else{
    while (tmpCur > 0){
	  tmpCur--;
	  tmpVal = sltObj.options[tmpCur].value.substr(0,txtLen);
	  if (tmpVal != txtVal){
		return (tmpCur+1);
	  }
	}
  }
}
function get_codindex(sltObj,txtVal,txtLen,sltBeg,sltEnd){
  if (sltBeg >= sltEnd){
  	return(-1);
  }
  var tmpLen = parseInt((sltEnd - sltBeg)/2, 10);
  var sltCur = sltBeg + tmpLen;
  var tmpVal = sltObj.options[sltCur].value;
  var subVal = tmpVal.substr(0,txtLen);
  if (tmpVal == txtVal){
    return (sltCur);
  }
  if (subVal == txtVal){
    return (get_curindex(sltObj, txtVal, txtLen, sltCur));
  }
  if (subVal > txtVal){
    return (get_codindex(sltObj, txtVal, txtLen, sltBeg, sltCur));
  }
  if (subVal < txtVal){
    return (get_codindex(sltObj, txtVal, txtLen, sltCur + 1, sltEnd));
  }
}
function get_selindex(sltObj,txtObj){
  var sltbeg = 0,sltend = 0;
  var i=0,j=0,k=0;
  var ival="",jval="",kval="";
  var txtval = txtObj.value.toUpperCase();
  if (txtval==""){
    return 0;
  }
  var txtlen = txtval.length;
  var sltlen = sltObj.options.length;
  var codidx = get_codindex(sltObj, txtval, txtlen, 0, sltlen);
  if (codidx != -1){
    return (codidx);
  }
  var sltidx = sltObj.selectedIndex;
  if (sltidx != -1){
    sltbeg = sltidx - 100;
	if (sltbeg < 0){
	  sltbeg = 0;
	}
	sltend = sltidx + 100;
	if (sltend > sltlen){
	  sltend = sltlen;
	}
/*
    if (txtObj.value.length != txtlen){
  	  return -1;
    }
	for (i=sltidx;i<sltend;i++){
	  if (sltObj.options[i].value.substr(0,txtlen) == txtval){
	    return i;
	  }
	}
    if (txtObj.value.length != txtlen){
  	  return -1;
    }
	for (i=sltbeg;i<sltidx;i++){
	  if (sltObj.options[i].value.substr(0,txtlen) == txtval){
	    return i;
	  }
	}
*/	
    if (txtObj.value.length != txtlen){
  	  return -1;
    }
	for (i=sltidx;i<sltend;i++){
	  if (sltObj.options[i].text.substr(0,txtlen) == txtval){
	    return i;
	  }
	}
    if (txtObj.value.length != txtlen){
  	  return -1;
    }
	for (i=sltbeg;i<sltidx;i++){
	  if (sltObj.options[i].text.substr(0,txtlen) == txtval){
	    return i;
	  }
	}
  }

  if (txtObj.value.length != txtlen){
  	return -1;
  }
  if (sltlen < 200){
    sltbeg = 0;
	sltend = sltlen;
  }else{
    i = parseInt(sltlen*1/3,10);
	j = parseInt(sltlen*2/3,10);
	k = sltlen - 1;
	ival = sltObj.options[i].value.substr(0,txtlen);
	jval = sltObj.options[j].value.substr(0,txtlen);
	kval = sltObj.options[k].value.substr(0,txtlen);
	if (txtval < ival){
	  sltbeg = 0;
  	  sltend = i+1;
	}
	if (txtval == ival){
	  sltbeg = i;
	  sltend = i+1;
	}
	if ((txtval > ival)&&(txtval < jval)){
	  sltbeg = i;
	  sltend = j+1;
	}
	if (txtval == jval){
	  sltbeg = j;
	  sltend = j+1;
	}
	if ((txtval > jval)&&(txtval < kval)){
	  sltbeg = j;
	  sltend = k+1;
	}
	if (txtval == kval){
	  sltbeg = k;
	  sltend = k+1;
	}
  }
  
  j = sltbeg + parseInt((sltend-sltbeg)/2,10);  
/*
  if (txtObj.value.length != txtlen){
  	return -1;
  }
  for (i=sltbeg;i<j;i++){
    if (sltObj.options[i].value.substr(0,txtlen) == txtval){
      return i;
    }
  }
  if (txtObj.value.length != txtlen){
  	return -1;
  }
  for (i=j;i<sltend;i++){
    if (sltObj.options[i].value.substr(0,txtlen) == txtval){
      return i;
    }
  }
*/
  if (txtObj.value.length != txtlen){
  	return -1;
  }  
  for (i=sltbeg;i<j;i++){
	if (sltObj.options[i].text.substr(0,txtlen) == txtval){
      return i;
    }
  }
  if (txtObj.value.length != txtlen){
  	return -1;
  }
  for (i=j;i<sltend;i++){
	if (sltObj.options[i].text.substr(0,txtlen) == txtval){
      return i;
    }
  }

  if (txtObj.value.length != txtlen){
  	return -1;
  }
  for (i=0;i<sltbeg;i++){
	if (sltObj.options[i].text.substr(0,txtlen) == txtval){
	  return i;
	}
  }
  if (txtObj.value.length != txtlen){
  	return -1;
  }
  for (i=sltend;i<sltlen;i++){
	if (sltObj.options[i].text.substr(0,txtlen) == txtval){
	  return i;
	}
  }

  return -1;
}
function set_selindex(thetype){
  var theform=document.forms[0];
  var thename="",selidx=0;
  switch (thetype){
    case "customer":
		thename=document.active_customer_name;
		selidx=theform.elements("customer_short_list").selectedIndex;
		if ((thename!="")&&(selidx>=0)){
		  if (thename!="nominate"){
		    var thecodeobj=theform.elements(thename+"_code");
			var thenameobj=theform.elements(thename+"_short");
		    var thefullobj=theform.elements(thename+"_full");
		    thecodeobj.value = theform.elements("customer_short_list").options[selidx].value;
			thenameobj.value = theform.elements("customer_short_list").options[selidx].text;
			if (theform.elements("customer_full_list").options.length > selidx){
			    thefullobj.value = theform.elements("customer_full_list").options[selidx].value;
			}
		  }else{
		    var thecodeobj=theform.elements("intro_type");
			thecodeobj.value = theform.elements("customer_short_list").options[selidx].value;
		  }
		}
		break;
	case "fee":
		theno=document.active_fee_no;
		selidx=theform.elements("fee_short_list").selectedIndex;
		if ((theno!="")&&(selidx>=0)){
		  var thecodeobj=theform.elements("fee_code_"+theno);
		  //var thenameobj=eval("theform."+thename+"_name");
		  thecodeobj.value = theform.elements("fee_short_list").options[selidx].value;
		  //thenameobj.value = theform.city_full_list.options[selidx].value;
		}
		break;
	case "city":
		thename=document.active_city_name;
		selidx=theform.elements("city_short_list").selectedIndex;
		if ((thename!="")&&(selidx>=0)){
		  var thecodeobj=theform.elements(thename+"_code");
		  var thenameobj=theform.elements(thename+"_name");
		  thecodeobj.value = theform.elements("city_short_list").options[selidx].value;
		  thenameobj.value = theform.elements("city_short_list").options[selidx].text;
		}
		break;
	case "vsl":
		thename=document.active_vsl_name;
		selidx=theform.elements("vsl_short_list").selectedIndex;
		if ((thename!="")&&(selidx>=0)){
		  var thecodeobj=theform.elements(thename+"_code");
		  var thenameobj=theform.elements(thename+"_name");
		  thecodeobj.value = theform.elements("vsl_short_list").options[selidx].value;
		  thenameobj.value = theform.elements("vsl_short_list").options[selidx].text;
		}
		break;
	case "state":
		selidx=theform.elements("state_short_list").selectedIndex;
		if (selidx>=0){
		  var thecodeobj=theform.elements("state_code");
		  var thenameobj=theform.elements("state_full");
		  thecodeobj.value = theform.elements("state_short_list").options[selidx].value;
		  thenameobj.value = theform.elements("state_full_list").options[selidx].value;
		}
		break;
	case "sales":
		selidx=theform.elements("sales_short_list").selectedIndex;
		if (selidx>=0){
		  var thecodeobj=theform.elements("sales_code");
		  var thenameobj=theform.elements("sales_name");
		  thecodeobj.value = theform.elements("sales_short_list").options[selidx].value;
		  thenameobj.value = theform.elements("sales_full_list").options[selidx].value;
		}
		break;
	case "skyway":
		selidx=theform.elements("skyway_short_list").selectedIndex;
		if (selidx>=0){
		  var thecodeobj=theform.elements("skyway_code");
		  var thenameobj=theform.elements("skyway_name");
		  thecodeobj.value = theform.elements("skyway_short_list").options[selidx].value;
		  thenameobj.value = theform.elements("skyway_full_list").options[selidx].value;
		}
		break;
	case "job":
		selidx=theform.elements("job_short_list").selectedIndex;
		if (selidx>=0){
		  var thecodeobj=theform.elements("small_job_no");
		  var thefullobj=theform.elements("big_job_no");
		  thecodeobj.value = theform.elements("job_short_list").options[selidx].value;
		  thefullobj.value = theform.elements("job_full_list").options[selidx].value;
		}
		break;
  }
}
function set_sel(theobj){//call:text_object.onKeyUp()
  var i=0,sellen=0,txtval="",txtlen=0;
  var theform = document.forms[0];
  //txtobj=theform.elements(theobj.name);
  selobj=theform.elements(theobj.name.replace("_code","_short"));
  hidobj=theform.elements(theobj.name.replace("_code","_hide"));
  edtobj=theform.elements(theobj.name.replace("_code","_full"));
  txtval=theobj.value.toUpperCase();
  txtlen=txtval.length;
  sellen=selobj.length;
  selobj.selectedIndex=-1;
  hidobj.selectedIndex=-1;
  edtobj.value="";
  for (i=0;i<sellen;i++){
    if (txtval == selobj.options[i].value.substr(0,txtlen).toUpperCase()){
      selobj.selectedIndex=i;
      hidobj.selectedIndex=i;
      edtobj.value=hidobj.value;
      return;
    }
  }
  for (i=0;i<sellen;i++){
    if (txtval == selobj.options[i].text.substr(0,txtlen).toUpperCase()){
      selobj.selectedIndex=i;
      hidobj.selectedIndex=i;
      edtobj.value=hidobj.value;
      return;
    }
  }
}
function set_txt(theobj){//call:select_object.onChange()
  var i=0,sellen=0;
  var theform = document.forms[0];
  txtobj=theform.elements(theobj.name.replace("_short","_code"));
  //selobj=theform.elements(theobj.name);
  hidobj=theform.elements(theobj.name.replace("_short","_hide"));
  edtobj=theform.elements(theobj.name.replace("_short","_full"));
  txtobj.value=theobj.value;
  hidobj.selectedIndex=theobj.selectedIndex;
  edtobj.value=hidobj.value;
}
function set_end(theobj){//call:text_object.onBlur()
  var theform = document.forms[0];
  selobj=theform.elements(theobj.name.replace("_code","_short"));
  theobj.value=selobj.value;
}
function max_day(year,month){
  var numDays = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
  var n=0;
  n = numDays[month-1];
  if((year % 4 == 0 && year % 100 != 0) || year % 400 == 0){
    if(month==2){
	  n++;
	}
  }
  return(n);
}
function trim_str(thestr){
  var start_at=0,end_at=0;
  end_at=thestr.length-1;
  while (thestr.charAt(start_at)==" "){
    start_at++;
  }
  while (thestr.charAt(end_at)==" "){
    end_at--;
  }
  if (start_at<end_at+1)
    return thestr.substring(start_at,end_at+1);
  else
    return "";	
}
function isNaM(theobj){
	var i=0;j=0;tmpval="",tmplen=0;
	var maillist = new Array();
	var tmplist = new Array();
	tmpval=theobj.value.replace(/\n/gi,",").replace(/\s/gi,"");
	if (tmpval==""){
		theobj.value=tmpval;
		return false;
	}
	if (tmpval.indexOf(",")==-1){
		if (tmpval.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i)==-1){
			return true;
		}else{	
			theobj.value=tmpval;
			return false;
		}
	}else{
		maillist=tmpval.split(",");
		for (i=0;i<maillist.length;i++){
			tmpval=maillist[i];
			if (tmpval!=""){
				if (tmpval.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i)==-1){
					return true;
				}else{
					tmplist[tmplist.length]=tmpval;
				}
			}
		}
		if (tmplist.length==0){
			return true;
		}else{
			tmpval=tmplist.join(",");
			theobj.value=tmpval;
			return false;
		}
	}
}
function isNaS(theobj){
  var i=0,j=0,tmpval="",tmplen=0;
  theobj.value=theobj.value.replace(/^([ \f\r\t\v]+)/gi,"").replace(/([ \f\r\t\v]+)$/gi,"");
  if (theobj.value==""){
    return true;
  }
  if (theobj.type.toLowerCase()=="text"){
  	tmpval=theobj.value;
	j=tmpval.indexOf("'");
	if (j!=-1){
	  tmplen=tmpval.length;
      for (i=j;i<tmplen;i++){
		if (tmpval.charAt(i)=="'"){
		  if (i==tmplen-1){
			return true;
		  }else{
			if (tmpval.charAt(i+1)=="'"){
			  i++;
			}else{
		      return true;
		    }
		  }
	    }
	  }
	}
  }
  return false;
}
function isNaD(theobj){
  var datestr="",datechr="",cyear="",cmonth="",cday="";
  var datelen=0,datenum=0;  
  var tDate;
  theobj.value=trim_str(theobj.value);
  if (theobj.value.indexOf("'")!=-1){
    return true;
  }
  if (theobj.value==""){
	return false;
  }
  tDate=theobj.value;
  tDate = vbIsDate(tDate,GetCookie("Date_Format"));
  if (tDate!=""){
    theobj.value=ReadFromDatabase(tDate,GetCookie("Date_Format"));
    return false;
  }else{
    return true;
  }
}
function isNaT(theobj){
  var timestr="",timechr="",chour="",cminute="",csecond="";
  var timelen=0,timenum=0;
  timestr=trim_str(theobj.value);
  timelen=timestr.length;
  if (theobj.value.indexOf("'")!=-1){
    return true;
  }
  if (timelen==0){
    theobj.value="";
	return false;
  }
  for (i=0;i<timelen;i++){
    timechr=timestr.substr(i,1);
    if ((timechr<'0')||(timechr>'9')){
	  timenum++;
	}else{
	  switch (timenum){
	    case 0:
		  chour+=timechr;
		  break;
		case 1:
		  cminute+=timechr;
		  break;
		case 2:
		  csecond+=timechr;
		  break;
		default:
		  return true;
	  }
	}
  }
  if (chour==""){
    chour="0";
  }
  if (cminute==""){
    cminute="0";
  }
  if (csecond==""){
    csecond="0";
  }
  if ((chour.length<1)||(chour.length>2)||(cminute.length<1)||(cminute.length>2)||(csecond.length<1)||(csecond.length>2)){
    return true;
  }
  if ((parseInt(chour,10)<0)||(parseInt(chour,10)>23)){
    return true;
  }else{
    if (chour.length==1){
	  chour='0'+chour;
	}
  }
  if ((parseInt(cminute,10)<0)||(parseInt(cminute,10)>59)){
    return true;
  }else{
    if (cminute.length==1){
	  cminute='0'+cminute;
	}
  }
  if ((parseInt(csecond,10)<0)||(parseInt(csecond,10)>59)){
    return true;
  }else{
    if (csecond.length==1){
	  csecond='0'+csecond;
	}
  }
  theobj.value=chour+':'+cminute+':'+csecond;
  return false;
}
function delzero(temp_str){			//delete number zero 
  var dnum_str="",ipos=0;
  dnum_str=trim_str(temp_str);
  ipos = dnum_str.indexOf("0");
  while (ipos<1){
    if (ipos==0){
      dnum_str = dnum_str.substring(1,temp_str.length);
    }else{
      break;
	}  
	ipos = dnum_str.indexOf("0");		
  }
  if (dnum_str==""){
    dnum_str = "0";
  }
  return dnum_str;
}
function isNaI(theobj){
  if (isNaS(theobj)){
    return true;
  }
  theobj.value=delzero(theobj.value);
  if (isNaN(theobj.value)){
    return true;
  }else{
    if (theobj.value.indexOf("-") != -1){
      return true;
    }
    if (theobj.value.indexOf(".") != -1){
      return true;
    }
    theobj.value=parseInt(theobj.value,10).toString();
  }
  return false;
}
function isNaF(theobj){
  if (isNaS(theobj)){
    return true;
  }
  theobj.value=delzero(theobj.value);
  if (theobj.value.length > 1){
    if (theobj.value.substr(0,1) == "."){
	  theobj.value = "0" + theobj.value;
	}
  }
  if (isNaN(theobj.value)){
    return true;
  }else{
    if (theobj.value.indexOf("-") != -1){
      return true;
    }
    theobj.value=parseFloat(theobj.value).toString();
	if (theobj.value.substr(0,1)=="."){
	  theobj.value = "0" + theobj.value;
	}
  }
  return false;
}
function isNaG(theobj){
  if (isNaS(theobj)){
    return true;
  }
  theobj.value=delzero(theobj.value);
  if (theobj.value.length > 2){
    if (theobj.value.substr(0,1) == "."){
	  theobj.value = "0" + theobj.value;
	}
    if (theobj.value.substr(0,2) == "-."){
	  theobj.value = "-0" + theobj.value.substr(1);
	}
  }
  if (isNaN(theobj.value)){
    return true;
  }else{
    if (parseFloat(theobj.value, 10)>0){
      return true;
    }
    theobj.value=parseFloat(theobj.value).toString();
	if (theobj.value.substr(0,1)=="."){
	  theobj.value = "0" + theobj.value;
	}
	if (theobj.value.substr(0,2)=="-."){
	  theobj.value = "-0" + theobj.value.substr(1);
	}
  }
  return false;
}
function FormatNumber(thenumber){
	return(Math.round(thenumber*1000)/1000);
}
function FormatMoney(thenumber){
	return(Math.round(thenumber*100)/100);
}
function lockform(locktag){
  var formlen=0,i=0;
  var theform = document.forms[0];
  if (locktag!="0"){
    formlen=theform.elements.length;
    for (i=0;i<formlen;i++){
	  switch (theform.elements[i].name){
	    case "exit_button":
		  break;
		default:
		  theform.elements[i].disabled=true;
	  }
    }
  }
}
function set_iframe(thename){
  if (document.body.scrollHeight > 0){
    if (parent.document.all.item(thename)!=null){
      if (parent.document.all.item(thename).style.display!="none"){
        parent.document.all.item(thename).height = document.body.scrollHeight;
	  }
	}
  }
}
function set_pagefoot(){
  if (document.body.scrollHeight < document.body.clientHeight){
    document.all.item("pagefoot").style.pixelTop = document.body.clientHeight - document.body.scrollHeight;
  }
}
function isOff(temp_str){
  var ipos = 0;
  ipos = temp_str.indexOf("&off=");
  if(ipos!=-1){
	return true;		//close window
  }else{
	return false;		//Don't close window
  }
}
function DateVal(theString){
  var tmpString = "";
  tmpString = vbIsDate(theString,GetCookie("Date_Format"));
  if (tmpString==""){
    return ("1970-01-01");
  }else{
    return(ReadFromDatabase(tmpString,"5")); //5:yyyy-mm-dd
  }
}
function msgbox(theMsg, theStyle){
  return(vbMsgBox(theMsg,theStyle))
}
function findmulticode(tablename,text_name){
  window.open("/include/retcode.asp?multi_tag=y&table_name=" + tablename + "&ret_name=" + text_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findcode(tablename,text_name){
  window.open("/include/retcode.asp?multi_tag=n&table_name=" + tablename + "&ret_name=" + text_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findhocode(text_name){
  window.open("/include/rethocode.asp?ret_name=" + text_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findfeecode(fee_code,fee_name){
  window.open("/include/retfeecode.asp?fee_code=" + fee_code + "&fee_name=" + fee_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findvslcode(shipid_name,vsl_name,voy_name){
  window.open("/include/retshipid.asp?shipid_name=" + shipid_name + "&vsl_name=" + vsl_name + "&voy_name=" + voy_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findshipinfo(shipid_name,vsl_name,voy_name,etd_name){
  window.open("/include/retshipid.asp?shipid_name=" + shipid_name + "&vsl_name=" + vsl_name + "&voy_name=" + voy_name + "&etd_name=" + etd_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findvslcodeac(shipid_name,vsl_name,voy_name){
  window.open("/include/retshipid_ac.asp?shipid_name=" + shipid_name + "&vsl_name=" + vsl_name + "&voy_name=" + voy_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findjobcode(jobid_name){
  window.open("/include/retjobid.asp?jobid_name=" + jobid_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findjobcodeac(jobid_name){
  window.open("/include/retjobid_ac.asp?jobid_name=" + jobid_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findbigjobcode(shipid_name){
  window.open("/include/retbigjob.asp?shipid_name=" + shipid_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findall(shipid_name,vsl_name,voy_name,carrier_name,loading_name){
  window.open("/include/retall.asp?shipid_name=" + shipid_name + "&vsl_name=" + vsl_name + "&voy_name=" + voy_name + "&carrier_name=" + carrier_name + "&loading_name=" + loading_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findjall(jobid_name,shipid_name,vsl_name,voy_name,carrier_name,loading_name){
  window.open("/include/retjall.asp?jobid_name=" + jobid_name + "&shipid_name=" + shipid_name + "&vsl_name=" + vsl_name + "&voy_name=" + voy_name + "&carrier_name=" + carrier_name + "&loading_name=" + loading_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=600,height=300");
}
function findhblno(small_job_no,hbl_name){
  window.open("/include/rethblno.asp?small_job_no=" + small_job_no + "&hbl_name=" + hbl_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=760,height=300");
}
function findcontainerno(small_job_no,agent_code,container_name){
  window.open("/include/retcontainerno.asp?small_job_no=" + small_job_no + "&agent_code=" + agent_code + "&container_name=" + container_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=300")
}
function findcustomer(customer_type,customer_name){
  window.open("/include/retcustomer.asp?type=" + customer_type + "&ret_name=" + customer_name,"","toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=620,height=300")
}
function getMonthDays(theYear, theMonth){
  var theDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
  var theMonthDays = 0;
  theMonthDays = theDays[theMonth];
  if (theMonth == 1){ //theMonth is February
    if (((theYear % 4 == 0) && (theYear % 100 != 0)) || (theYear % 400 == 0)){
      theMonthDays++;
    }
  }
  return(theMonthDays);
}
function DateScope(iType,today){
  var downlimit=" ", uplimit=" ";
  var CenturyYear = 1940;
  var nowYear = parseInt(ParseDate(today,5,0),10);
  var nowMonth = parseInt(ParseDate(today,5,1),10) - 1;
  var nowDay = parseInt(ParseDate(today,5,2),10);
  var nowDate = new Date(nowYear,nowMonth,nowDay);
  var nowYear = nowDate.getYear();
  if (nowYear < 100){
    nowYear += 1900;
    if (nowYear < CenturyYear){ //equal to jsMonthView.CenturyYear
      nowYear += 100;
    }
  }
  var nowMonth = nowDate.getMonth();
  var nowDay = nowDate.getDate();
  var curDate = nowDate;
  var curYear = nowYear;
  var curMonth = nowMonth;
  var curDay = nowDay;
  switch (iType.toString()){
    case "0": //One Month Before And After Today
	  curYear = nowYear;
	  curMonth = nowMonth - 1;
	  if (curMonth<0){
	    curYear--;
		curMonth = 11;
	  }
	  curDay = getMonthDays(curYear,curMonth);
	  if (curDay > nowDay){
	    curDay = nowDay;
	  }
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
	  curYear = nowYear;
	  curMonth = nowMonth + 1;
	  if (curMonth>11){
	    curYear++;
		curMonth = 0;
	  }
	  curDay = getMonthDays(curYear,curMonth);
	  if (curDay > nowDay){
	    curDay = nowDay;
	  }
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "1": //Last Month
	  curYear = nowYear;
	  curMonth = nowMonth - 1;
	  if (curMonth<0){
	    curYear--;
		curMonth = 11;
	  }
	  curDay = getMonthDays(curYear,curMonth);
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-1";
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "2": //This Month
	  curYear = nowYear;
	  curMonth = nowMonth;
	  curDay = getMonthDays(curYear,curMonth);
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-1";
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "3": //Last Week
	  curDate = new Date(nowYear, nowMonth, nowDay - nowDate.getDay() - 7);
      curYear = curDate.getYear();
      if (curYear < 100){
        curYear += 1900;
        if (curYear < CenturyYear){ //equal to jsMonthView.CenturyYear
          curYear += 100;
        }
      }
      curMonth = curDate.getMonth();
      curDay = curDate.getDate();
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
	  curDate = new Date(nowYear, nowMonth, nowDay - nowDate.getDay() - 1);
      curYear = curDate.getYear();
      if (curYear < 100){
        curYear += 1900;
        if (curYear < CenturyYear){ //equal to jsMonthView.CenturyYear
          curYear += 100;
        }
      }
      curMonth = curDate.getMonth();
      curDay = curDate.getDate();
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "4": //This Week
	  curDate = new Date(nowYear, nowMonth, nowDay - nowDate.getDay());
      curYear = curDate.getYear();
      if (curYear < 100){
        curYear += 1900;
        if (curYear < CenturyYear){ //equal to jsMonthView.CenturyYear
          curYear += 100;
        }
      }
      curMonth = curDate.getMonth();
      curDay = curDate.getDate();
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
	  curDate = new Date(nowYear, nowMonth, nowDay - nowDate.getDay() + 6);
      curYear = curDate.getYear();
      if (curYear < 100){
        curYear += 1900;
        if (curYear < CenturyYear){ //equal to jsMonthView.CenturyYear
          curYear += 100;
        }
      }
      curMonth = curDate.getMonth();
      curDay = curDate.getDate();
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "5": //Today
	  curYear = nowYear;
	  curMonth = nowMonth;
	  curDay = nowDay;
      downlimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      uplimit = curYear.toString() + "-" + (curMonth+1).toString() + "-" + curDay.toString();
      break;
    case "6": //empty
      downlimit = " ";
      uplimit = " ";
      break;
  }
  return(downlimit + ";" + uplimit);
}
function sel_DateScope(cboname,ldate,udate,today){
  var theform = document.forms[0];
  var iType = theform.elements(cboname).value;
  var dscope = DateScope(iType,today);
  var iPos = dscope.indexOf(";");
  var m_type = GetCookie("Date_Format");
  var lowerdate = ReadFromDatabase(dscope.substring(0, iPos), m_type);
  var upperdate = ReadFromDatabase(dscope.substring(iPos+1, dscope.length), m_type);
  theform.elements(ldate).value = lowerdate;
  theform.elements(udate).value = upperdate;
}
function ini_DateScope(cboname,ldate,udate,today){
  var theform = document.forms[0];
  var ldate_val=theform.elements(ldate).value + "";
  var udate_val=theform.elements(udate).value + "";
  if((ldate_val=="")&&(udate_val=="")){
    theform.elements(cboname).value="0";
    sel_DateScope(cboname,ldate,udate,today);
  }
}

var now = new Date();
var months = now.getMonth()+1;
var dates = now.getDate();
var hours = now.getHours();
var minutes = now.getMinutes();
var seconds = now.getSeconds();

function getCookieVal(offset){
	var endstr = document.cookie.indexOf(";", offset);
	if (endstr == -1){
		endstr = document.cookie.length;
	}
	return(unescape(document.cookie.substring(offset, endstr)));
}

function GetCookie(name){
	var arg = escape(name).replace(/_/gi,"%5F") + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen){
		var j = i + alen;
		if(document.cookie.substring(i, j) == arg){
			return getCookieVal(j);
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0){
			break; 
		}
	}
	return(null);
}
function SetCookie(name, value){
	var argv = SetCookie.arguments;
	var argc = SetCookie.arguments.length;
	var expires = (2 < argc) ? argv[2] : null;
	var path = (3 < argc) ? argv[3] : null;
	var domain = (4 < argc) ? argv[4] : null;
	var secure = (5 < argc) ? argv[5] : false;

	document.cookie = escape(name) + "=" + escape (value) +
		((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
		((path == null) ? "" : ("; path=" + path)) +
		((domain == null) ? "" : ("; domain=" + domain)) +
		((secure == true) ? "; secure" : "");
}
function DefineMonthView(theTextObject){ //the month view construct function
	var theName = "jsMV"; //the name is only one on document
	this.Name = theName; //the month view name
	this.Source = theTextObject; //the month view act on theTextObject
	this.CenturyYear = 1940; //if input two digit year, and the year add 1900 less than this.CenturyYear, then year is the year add 2000 
	this.MinYear = 1980; //year list min value
	//return year between 1000 and 9999 and <= this.MaxYear
	this.MaxYear = 2029; //year list max value
	//return year between 1000 and 9999 and >= this.MinYear
	this.Width = 300; //the month view main body's width
	this.Height = 200; //the month view main body's height
	this.AlwaysShow = true; //if IE version less than 5.5 and this attribute is false, then do'nt show month view, else always show
	this.AutoHidden = true; //if this attribute is true, then use mouse select a date after, the month view auto hide;
	this.InvalidMessage = ""; //if user input string is not a date, the string convert to it, default is empty
	this.DateFormat = "<yyyy>-<mm>-<dd>"; //the date format, must have year, month and day
	//<yy> or <yyyy> is year, <m> or <mm> is digital format month, <MMM> or <MMMMMM> is character format month, <d> or <dd> is day, other char unchanged
	//this function setting year, month and day sequence
	//for example:
	//  <yyyy>-<mm>-<dd> : 2002-04-01
	//  <yy>.<m>.<d> : 02.4.1
	//  <yyyy> Year <MMMMMM> Month <d> Day : 2002 Year April Month 1 Day
	//  <m>/<d>/<yy> : 4/1/02
	//  <MMM> <dd>, <yyyy> : Apr 01, 2002
	//  <MMMMMM> <d>,<yyyy> : April 1,2002
	//  <dd>-<MMM>-<yyyy> : 01-Apr-2002
	//  <dd>/<mm>/<yyyy> : 01/04/2002
	this.UnselectBgColor = "#FFFFFF"; //the month view default background color
	this.SelectedBgColor = "#808080"; //the selected date background color
	this.SelectedColor = "#FFFFFF"; //the selected date front color
	this.DayBdWidth = "2px"; //the day unit border width
	this.DayBdColor = this.UnselectBgColor; //the day unit border color,default is this.UnselectBgColor
	this.TodayBdColor = "#FF0000"; //denote today's date border color
	this.InvalidColor = "#808080"; //it is not current month day front color
	this.ValidColor = "#0000FF"; //it is current month day front color
	this.WeekendBgColor = this.UnselectBgColor; //the weekend background color, default is this.UnselectBgColor
	this.WeekendColor = this.ValidColor; //the weekend front color, default is  this.ValidColor
	this.YearListStyle = "width:60px; font-size:12px; font-family:Verdana;"; //the year list's style
	this.MonthListStyle = "width:100px; font-size:12px; font-family:Verdana;"; //the month list's style
	this.MonthName = new Array(); //month name list, font is include this.MonthListStyle
	this.MonthName[0] = "January";
	this.MonthName[1] = "February";
	this.MonthName[2] = "March";
	this.MonthName[3] = "April";
	this.MonthName[4] = "May";
	this.MonthName[5] = "June";
	this.MonthName[6] = "July";
	this.MonthName[7] = "August";
	this.MonthName[8] = "September";
	this.MonthName[9] = "October";
	this.MonthName[10] = "November";
	this.MonthName[11] = "December";
	this.WeekListStyle = "font-size:16px; font-weight:bolder; font-family:Times new roman;"; //the week name's style
	this.TitleStyle = "text-align:center; vertical-align:bottom; cursor:default; color:#000000; background-color:" + this.UnselectBgColor + ";"; //the month view title area's style
	this.WeekName = new Array(); //week name list, font is include this.WeekListStyle
	this.WeekName[0] = "Sun";
	this.WeekName[1] = "Mon";
	this.WeekName[2] = "Tue";
	this.WeekName[3] = "Wed";
	this.WeekName[4] = "Thu";
	this.WeekName[5] = "Fri";
	this.WeekName[6] = "Sat";
	this.MonthGridStyle = "border-width:1px; border-style:solid; border-color:#000000;"; //the month view main body's default style
	this.HeaderStyle = "height:32px; background-color:buttonface;"; //the month view header area's style
	this.DayListStyle = "cursor:hand; font-size:12px; font-family:Verdana; text-align:center; vertical-align:middle;"; //the month view day area's style
	this.DayStyleName = new Array(); //the mouse over or out a day style name
	this.DayStyleOver = new Array(); //the mouse over a day style value, style name from the DayStyleName
	this.DayStyleOut = new Array(); //the mouse out a day style value, style name from the DayStyleName
	this.DayStyleName[0] = "textDecoration";
	this.DayStyleOver[0] = "underline";
	this.DayStyleOut[0] = "none";
	this.TodayListStyle = "font-size:12px; font-family:Verdana;"; //the today tip's style
	this.TodayListTitle = "Goto Today"; //the today tip's title
	this.FooterStyle = "text-align:left; vertical-align:middle; cursor:hand; color:#000000; background-color:" + this.UnselectBgColor + ";"; //the month footer area's style
	this.TodayTitle = "Today:"; //today tip string, font is include this.TodayListStyle
	this.MonthBtStyle = "font-family:Marlett; font-size:12px; width:20px; height:20px; "; //the change month button style
	this.PreviousMonthTitle = "Goto Previous Month";
	this.PreviousMonthText = "3"; //the go previous month button text
	//font is include this.MonthBtStyle
	this.NextMonthTitle = "Goto Next Month";
	this.NextMonthText = "4"; //the go next month button text
	//font is include this.MonthBtStyle
	this.LineBgStyle = "height:10px; background-color:" + this.UnselectBgColor + "; text-align:center; vertical-align:middle;"; //the month view title area and day area compart area background style
	this.LineStyle = "width:90%; height:1px; background-color:#000000;"; //the month view title area and day area compart area front style

	this.CheckIE = function( ){//check IE version. if greater than 5.0 return true, else return false;
		var version = "";
		var navAgent = navigator.userAgent;
		var navIndex = navAgent.indexOf("MSIE");
		if (navIndex == -1){
			return(false);
		}else{
			version = navAgent.substr(navIndex + 4, 4);
			if (isNaN(parseFloat(version))){
				return(false);
			}else{
				if (parseFloat(version) > 5.0){
					return(true);
				}else{
					return(false);
				}
			}
		}
	}
	this.GetoffsetLeft = function(theObject){ //return theObject's absolute offsetLeft
		var absLeft = 0;
		var thePosition = "";
		var tmpObject = theObject;
		while (tmpObject != null){
			thePosition = tmpObject.position;
			tmpObject.position = "static";
			absLeft += tmpObject.offsetLeft;
			tmpObject.position = thePosition;
			tmpObject = tmpObject.offsetParent;
		}
		return(absLeft);
	}
	this.GetoffsetTop = function(theObject){ //return theObj's absolute offsetTop
		var absTop = 0;
		var thePosition = "";
		var tmpObject = theObject;
		while (tmpObject != null){
			thePosition = tmpObject.position;
			tmpObject.position = "static";
			absTop += tmpObject.offsetTop;
			tmpObject.position = thePosition;
			tmpObject = tmpObject.offsetParent;
		}
		return(absTop);
	}
	this.GetFormatYear = function(theYear){//format theYear to 4 digit
		var tmpYear = parseInt(theYear,10);
		if (tmpYear < 100){
			tmpYear += 1900;
			if (tmpYear < this.CenturyYear){
				tmpYear += 100;
			}
		}
		if (tmpYear < this.MinYear){
			tmpYear = this.MinYear;
		}
		if (tmpYear > this.MaxYear){
			tmpYear = this.MaxYear;
		}
		return(tmpYear);
	}
	this.GetMonthDays = function(theYear, theMonth){ //get theYear and theMonth days number
		var theDays = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
		var theMonthDay = 0
		var tmpYear = this.GetFormatYear(theYear);
		theMonthDay = theDays[theMonth];
		if (theMonth == 1){ //theMonth is February
			if (((tmpYear % 4 == 0) && (tmpYear % 100 != 0)) || (tmpYear % 400 == 0)){
				theMonthDay++;
			}
		}
		return(theMonthDay);
	}
	this.SetDateFormat = function(theYear, theMonth, theDay){//format a date to this.DateFormat
		var theDate = this.DateFormat;
		var tmpYear = this.GetFormatYear(theYear);
		var tmpMonth = theMonth;
		if (tmpMonth < 0){
			tmpMonth = 0;
		}
		if (tmpMonth > 11){
			tmpMonth = 11;
		}
		var tmpDay = theDay;
		if (tmpDay < 1){
			tmpDay = 1;
		}else{
			tmpDay = this.GetMonthDays(tmpYear, tmpMonth);
			if (theDay < tmpDay){
				tmpDay = theDay;
			}
		}
		theDate = theDate.replace(/<yyyy>/g, tmpYear.toString());
		theDate = theDate.replace(/<yy>/g, tmpYear.toString().substr(2,2));
		theDate = theDate.replace(/<MMMMMM>/g, this.MonthName[tmpMonth]);
		theDate = theDate.replace(/<MMM>/g, this.MonthName[tmpMonth].substr(0,3));
		if (theMonth < 9){
			theDate = theDate.replace(/<mm>/g, "0" + (tmpMonth + 1).toString());
		}else{
			theDate = theDate.replace(/<mm>/g, (tmpMonth + 1).toString());
		}
		theDate = theDate.replace(/<m>/g, (tmpMonth + 1).toString());
		if (theDay < 10){
			theDate = theDate.replace(/<dd>/g, "0" + tmpDay.toString());
		}else{
			theDate = theDate.replace(/<dd>/g, tmpDay.toString());
		}
		theDate = theDate.replace(/<d>/g, tmpDay.toString());
		return(theDate);
	}
	this.GetTextDate = function(theString){ //convert a date string to a date, if the string is not a date, return empty
		var i = 0, j = 0, tmpChar = "", find_tag = "";
		var start_at = 0, end_at = 0, year_at = 0, month_at = 0, day_at = 0;
		var tmp_at = 0, one_at = 0, two_at = 0, one_days = 0, two_days = 0;
		var aryDate = new Array();
		var tmpYear = -1, tmpMonth = -1, tmpDay = -1;
		var tmpDate = theString.toLowerCase();
		var defDate = "";
		//convert string month to digital month
		tmpDate = tmpDate.replace(/(\D)0(\d)/g, "$1-$2");
		for (i = 0; i < 9; i++){
			tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-00" + (i+1).toString() + "-");
		}
		for (i = 9; i < 12; i++){
			tmpDate = tmpDate.replace(this.MonthName[i].toLowerCase().substr(0,3), "-0" + (i+1).toString() + "-");
		}
		tmpDate = tmpDate.replace(/jan/g, "-001-");
		tmpDate = tmpDate.replace(/feb/g, "-002-");
		tmpDate = tmpDate.replace(/mar/g, "-003-");
		tmpDate = tmpDate.replace(/apr/g, "-004-");
		tmpDate = tmpDate.replace(/may/g, "-005-");
		tmpDate = tmpDate.replace(/jun/g, "-006-");
		tmpDate = tmpDate.replace(/jul/g, "-007-");
		tmpDate = tmpDate.replace(/aug/g, "-008-");
		tmpDate = tmpDate.replace(/sep/g, "-009-");
		tmpDate = tmpDate.replace(/oct/g, "-010-");
		tmpDate = tmpDate.replace(/nov/g, "-011-");
		tmpDate = tmpDate.replace(/dec/g, "-012-");
		//delete redundant chars
		for (i = 0; i < tmpDate.length; i++){
			tmpChar = tmpDate.charAt(i);
			if (((tmpChar < "0") || (tmpChar>"9")) && (tmpChar != "-")){
				tmpDate = tmpDate.replace(tmpChar, "-")
			}
		}
		while (tmpDate.indexOf("--") != -1){
			tmpDate = tmpDate.replace(/--/g, "-");
		}
		start_at = 0;
		end_at = tmpDate.length - 1;
		while (tmpDate.charAt(start_at) == "-"){
			start_at++;
		}
		while (tmpDate.charAt(end_at) == "-"){
			end_at--;
		}
		if (start_at < end_at+1){
			tmpDate = tmpDate.substring(start_at, end_at + 1);
		}else{
			tmpDate = "";
		}
		//get theString date format
		aryDate = tmpDate.split("-");
		if (aryDate.length != 3){
			return(defDate);
		}
		tmp_at = 0;
		for (i = 0; i < 3; i++){
			if (parseInt(aryDate[i], 10)==0){
				tmp_at++;
				year_at = i;
			}
		}
		if (tmp_at > 1){
			return(defDate);
		}
		if (tmp_at == 1){
			aryDate[year_at] = this.GetFormatYear(aryDate[year_at]).toString();
		}
		tmpDate = this.DateFormat;
		year_at = tmpDate.indexOf("<yyyy>");
		if (year_at == -1){
			year_at = tmpDate.indexOf("<yy>");
		}
		month_at = tmpDate.indexOf("<MMMMMM>");
		if (month_at == -1){
			month_at = tmpDate.indexOf("<MMM>");
		}
		if (month_at == -1){
			month_at = tmpDate.indexOf("<mm>");
		}
		if (month_at == -1){
			month_at = tmpDate.indexOf("<m>");
		}
		day_at = tmpDate.indexOf("<dd>");
		if (day_at == -1){
			day_at = tmpDate.indexOf("<d>");
		}
		//get month position
		find_tag = "000"; //start, the month position is null
		//find_tag	date_format
		//000	unknow, theString is not a date
		//001	day_year_month or year_day_month
		//010	day_month_year or year_month_day
		//100	month_day_year or month_year_dat
		for (i = 0; i < 3; i++){
			if (aryDate[i].length == 3){
				if ((aryDate[i] >= "001") && (aryDate[i] <= "012")){
					if (find_tag != "000"){
						return(defDate);
					}
					tmpMonth = parseInt(aryDate[i], 10) - 1;
					switch (i){
						case 0:
							find_tag = "100";
							one_at = parseInt(aryDate[1], 10);
							two_at = parseInt(aryDate[2], 10);
							break;
						case 1:
							find_tag = "010";
							one_at = parseInt(aryDate[0], 10);
							two_at = parseInt(aryDate[2], 10);
							break;
						case 2:
							find_tag = "001";
							one_at = parseInt(aryDate[0], 10);
							two_at = parseInt(aryDate[1], 10);
							break;
						default:;
					}
				}
			}
		}
		if (find_tag!="000"){
			one_days = this.GetMonthDays(two_at, tmpMonth);
			two_days = this.GetMonthDays(one_at, tmpMonth);
			if ((one_at > one_days) && (two_at > two_days)){
				return(defDate);
			}
			if ((one_at <= one_days) && (two_at > two_days)){
				tmpYear = this.GetFormatYear(two_at);
				tmpDay = one_at;
			}
			if ((one_at > one_days) && (two_at <= two_days)){
				tmpYear = this.GetFormatYear(one_at);
				tmpDay = two_at;
			}
			if ((one_at <= one_days) && (two_at <= two_days)){
				switch (find_tag){
					case "100": //default month,day,year
						tmpDay = one_at;
						tmpYear = this.GetFormatYear(two_at);
						if ((month_at > year_at) && (month_at > day_at)){
							if (day_at > year_at){
								tmpYear = this.GetFormatYear(one_at);
								tmpDay = two_at;
							}
						}
						break;
					case "010": //default day,month,year
						tmpDay = one_at;
						tmpYear = this.GetFormatYear(two_at);
						if (((month_at > year_at) && (month_at < day_at)) || ((month_at < year_at) && (month_at > day_at))){
							if (day_at > year_at){
								tmpYear = this.GetFormatYear(one_at);
								tmpDay = two_at;
							}
						}
						break;
					case "001": //default year,day,month
						tmpYear = this.GetFormatYear(one_at);
						tmpDay = two_at;	
						if ((month_at < year_at) && (month_at < day_at)){
							if (year_at > day_at){
								tmpDay = one_at;
								tmpYear = this.GetFormatYear(two_at);
							}
						}
						break;
					default: //default day,year
						tmpDay = one_at;
						tmpYear = this.GetFormatYear(two_at);
				}
			}
			return(new Date(tmpYear, tmpMonth, tmpDay));
		}
		find_tag = "000";
		for (i = 0; i < 3; i++){
			if (parseInt(aryDate[i], 10) > 31){
				if (find_tag!="000"){
					return(defDate);
				}
				tmpYear = this.GetFormatYear(aryDate[i]);
				switch (i){
					case 0:
						find_tag = "100";
						one_at = parseInt(aryDate[1], 10);
						two_at = parseInt(aryDate[2], 10);
						break;
					case 1:
						find_tag = "010";
						one_at = parseInt(aryDate[0], 10);
						two_at = parseInt(aryDate[2], 10);
						break;
					case 2:
						find_tag = "001";
						one_at = parseInt(aryDate[0], 10);
						two_at = parseInt(aryDate[1], 10);
						break;
					default:;
				}
			}
		}
		if (find_tag == "000"){
			if ((year_at > month_at) && (year_at > day_at)){
				find_tag = "001";
			}
			if ((year_at > month_at) && (year_at < day_at)){
				find_tag = "010";
			}
			if ((year_at < month_at) && (year_at > day_at)){
				find_tag = "010";
			}
			if ((year_at < month_at) && (year_at < day_at)){
				find_tag = "100";
			}
			switch (find_tag){
				case "100":
					tmpYear = parseInt(aryDate[0], 10);
					one_at = parseInt(aryDate[1], 10);
					two_at = parseInt(aryDate[2], 10);
					break;
				case "010":
					one_at = parseInt(aryDate[0], 10);
					tmpYear = parseInt(aryDate[1], 10);
					two_at = parseInt(aryDate[2], 10);
					break;
				case "001":
					one_at = parseInt(aryDate[0], 10);
					two_at = parseInt(aryDate[1], 10);
					tmpYear = parseInt(aryDate[2], 10);
					break;
				default:;
			}
			tmpYear = this.GetFormatYear(tmpYear);
		}
		if (find_tag == "000"){
			return(defDate);
		}else{
			if ((one_at > 12) && (two_at > 12)){
				return(defDate);
			}
			if ((one_at <= 12) && (two_at > 12)){
				if (two_at > this.GetMonthDays(tmpYear,one_at-1)){
					return(new Date(tmpYear, one_at-1, this.GetMonthDays(tmpYear,one_at-1)));
				}else{
					return(new Date(tmpYear, one_at-1, two_at));
				}
			}
			if ((one_at > 12) && (two_at <= 12)){
				if (one_at > this.GetMonthDays(tmpYear,two_at-1)){
					return(new Date(tmpYear, two_at-1, this.GetMonthDays(tmpYear,two_at-1)));
				}else{
					return(new Date(tmpYear, two_at-1, one_at));
				}
			}
			if ((one_at <= 12) && (two_at <= 12)){
				tmpMonth = one_at-1;
				tmpDay = two_at;
				if (month_at > day_at){
					tmpMonth = two_at-1;
					tmpDay = one_at;
				}
				return(new Date(tmpYear, tmpMonth, tmpDay));
			}
		}
	}
	this.CreateYearList = function(MinYear, MaxYear){ //create year list
		var theName = this.Name;
		//var theYearObject = document.all.item(theName + "_YearList");
		var theYearObject = document.getElementById(theName + "_YearList");
		if (theYearObject == null){
			return;
		}
		var theYear = 0;
		var theYearHTML = "<SELECT id=\"" + theName + "_YearList\" style=\"" + this.YearListStyle + "\" tabIndex=\"-1\"";
		theYearHTML += " onChange=\"document.jsMonthView.UpdateMonthGrid(this);\"";
		theYearHTML += " onBlur=\"document.jsMonthView.DeleteMonthGrid(false);\">";
		for (theYear = MaxYear; theYear >= MinYear; theYear--){
			theYearHTML += "<OPTION value=\"" + theYear.toString() + "\">" + theYear.toString() + "</OPTION>";
		}
		theYearHTML += "</SELECT>";
		theYearObject.outerHTML = theYearHTML;
	}
	this.CreateMonthList = function( ){ //create month list
		var theName = this.Name;
		//var theMonthObject = document.all.item(theName + "_MonthList");
		var theMonthObject = document.getElementById(theName + "_MonthList");
		if (theMonthObject == null){
			return;
		}
		var theMonth = 0;
		var theMonthHTML = "<SELECT id=\"" + theName + "_MonthList\" style=\"" + this.MonthListStyle + "\" tabIndex=\"-1\"";
		theMonthHTML += " onChange=\"document.jsMonthView.UpdateMonthGrid(this);\"";
		theMonthHTML += " onBlur=\"document.jsMonthView.DeleteMonthGrid(false);\">";
		for (theMonth = 0; theMonth < 12; theMonth++){
			theMonthHTML += "<OPTION value=\"" + theMonth.toString() + "\">" + this.MonthName[theMonth] + "</OPTION>";
		}
		theMonthHTML +="</SELECT>";
		theMonthObject.outerHTML = theMonthHTML;
	}
	this.OverDay = function(theDay){
		var i=0;
		for (i=0;i<this.DayStyleName.length;i++){
			eval("theDay.style." + this.DayStyleName[i] + " = \"" + this.DayStyleOver[i] + "\"");
		}
	}
	this.OutDay = function(theDay){
		var i=0;
		for (i=0;i<this.DayStyleName.length;i++){
			eval("theDay.style." + this.DayStyleName[i] + " = \"" + this.DayStyleOut[i] + "\"");
		}
	}
	this.SetDayList = function(theYear, theMonth, theDay, theTag){ //set the month view show a date
		var theName = this.Name;
		//var theDayObject = document.all.item(theName + "_DayList");
		var theDayObject = document.getElementById(theName + "_DayList");
		if (theDayObject == null){
			return;
		}
		theDayObject.value = theDay.toString();
		var theFirstDay = new Date(theYear, theMonth, 1);
		var theCurrentDate = new Date();
		var theWeek = theFirstDay.getDay();
		if (theWeek == 0){
			theWeek = 7;
		}
		var theLeftDay = 0;
		if (theMonth == 0){
			theLeftDay = 31;
		}else{
			theLeftDay = this.GetMonthDays(theYear, theMonth - 1);
		}
		var theRightDay = this.GetMonthDays(theYear, theMonth);
		var theCurrentDay = theLeftDay - theWeek + 1;
		var offsetMonth = -1; //the month is previous month
		var theColor = this.InvalidColor;
		var theBgColor = this.UnselectBgColor;
		var theBdColor = theBgColor;
		var WeekId = 0
		var DayId = 0;
		var theStyle = "";
		var theDayHTML = "<TABLE width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		theDayHTML += "     <TR style=\"" + this.TitleStyle + "\">";
		for (DayId = 0; DayId < 7; DayId++){
			theDayHTML += "     <TD width=\"10%\" style=\"" + this.WeekListStyle + "\">" + this.WeekName[DayId] + "</TD>";
		}
		theDayHTML += "     </TR>";
		theDayHTML += "     <TR>";
		theDayHTML += "       <TD colspan=\"7\" style=\"" + this.LineBgStyle + "\">";
		theDayHTML += "         <TABLE style=\"" + this.LineStyle + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
		theDayHTML += "           <TR><TD></TD></TR>";
		theDayHTML += "         </TABLE>";
		theDayHTML += "       </TD>";
		theDayHTML += "     </TR>";
		for (WeekId = 0; WeekId < 6; WeekId++){
			theDayHTML += "   <TR style=\"" + this.DayListStyle + "\">";
			for (DayId = 0; DayId < 7; DayId++){
				if ((theCurrentDay > theLeftDay) && (WeekId < 3)){
					offsetMonth++; //the month is current month;
					theCurrentDay = 1;
				}
				if ((theCurrentDay > theRightDay) && (WeekId > 3)){
					offsetMonth++; //the month is next month;
					theCurrentDay = 1;
				}
				switch (offsetMonth){
					case -1:
						theColor = this.InvalidColor;
						break;
					case 1:
						theColor = this.InvalidColor;
						break;
					case 0:
						if ((DayId == 0) || (DayId == 6)){
							theColor = this.WeekendColor;
						}else{
							theColor = this.ValidColor;
						}
						break;
					default:;
				}
				if ((DayId == 0) || (DayId == 6)){
					theBgColor = this.WeekendBgColor;
				}else{
					theBgColor = this.UnselectBgColor;
				}
				theBdColor = this.DayBdColor;
				if ((theCurrentDay == theDay) && (offsetMonth == 0) && (theTag == true)){
					theColor = this.SelectedColor;
					theBgColor = this.SelectedBgColor;
					theBdColor = theBgColor;
				}
				if ((theYear == theCurrentDate.getFullYear()) && (theMonth == theCurrentDate.getMonth()) && (theCurrentDay == theCurrentDate.getDate()) && (offsetMonth == 0)){
					theBdColor = this.TodayBdColor;
				}
				theStyle = "border:" + this.DayBdWidth + " solid " + theBdColor + "; color:" + theColor + "; background-color:" + theBgColor + ";";
				theDayHTML += "<TD style=\"" + theStyle + "\"";
				theDayHTML += " onMouseOver=\"document.jsMonthView.OverDay(this);\"";
				theDayHTML += " onMouseOut=\"document.jsMonthView.OutDay(this);\"";
				theDayHTML += " onMouseDown=\"document.jsMonthView.CreateMonthGrid(" + theYear.toString() + ", " + (theMonth + offsetMonth).toString() + ", " + theCurrentDay.toString() + ", true);\"";
				if (this.AutoHidden == true){
					theDayHTML += " onMouseUp=\"document.jsMonthView.DeleteMonthGrid(true);\"";
				}
				theDayHTML += ">" + theCurrentDay.toString()+ "</TD>";
				theCurrentDay++;
			}
			theDayHTML += "</TR>";
		}
		theDayHTML += "  <TR style=\"" + this.FooterStyle + "\" title=\"" + this.TodayListTitle + "\"";
		theDayHTML += " onMouseDown=\"document.jsMonthView.CreateMonthGrid(" + theCurrentDate.getFullYear().toString() + ", " + theCurrentDate.getMonth().toString() + ", " + theCurrentDate.getDate().toString() + ", true);\"";
		if (this.AutoHidden == true){
			theDayHTML += " onMouseUp=\"document.jsMonthView.DeleteMonthGrid(true);\"";
		}
		theDayHTML += ">";
		theStyle = "border:" + this.DayBdWidth + " solid " + this.TodayBdColor + "; " + this.TodayListStyle + ";";
		theDayHTML += "    <TD style=\"" + theStyle + "\">&nbsp;</TD>";
		theDayHTML += "    <TD colspan=\"6\" style=\"" + this.TodayListStyle + "\">&nbsp;" + this.TodayTitle + "&nbsp;" + this.SetDateFormat(theCurrentDate.getFullYear(), theCurrentDate.getMonth(), theCurrentDate.getDate()) + "</TD>";
		theDayHTML += "  </TR>";
		theDayHTML += "</TABLE>";
		var theMonthGrid = document.all.item(theName + "_MonthGrid");
		theMonthGrid.innerHTML = theDayHTML;
	}
	this.CreateMonthGrid = function(theYear, theMonth, theDay, theTag){ //refresh the month view to the date, main action is run this.setDayList() and set this.Source.value
		var theTextObject = this.Source;
		if (theTextObject == null){
			return;
		}
		var theName = this.Name;
		//var theYearObject = document.all.item(theName + "_YearList");
		//var theMonthObject = document.all.item(theName + "_MonthList");				
		var theYearObject = document.getElementById(theName + "_YearList");
		var theMonthObject = document.getElementById(theName + "_MonthList");
		var tmpYear = theYear;
		var tmpMonth = theMonth;
		var tmpDay = 1;
		if (tmpMonth < 0){
			tmpYear--;
			tmpMonth = 11;
		}
		if (tmpMonth > 11){
			tmpYear++;
			tmpMonth = 0;
		}
		if (tmpYear < this.MinYear){
			tmpYear = this.MinYear;
		}
		if (tmpYear > this.MaxYear){
			tmpYear = this.MaxYear;
		}
		if (theDay < 1){
			tmpDay = 1;
		}else{
			tmpDay = this.GetMonthDays(tmpYear, tmpMonth);
			if (theDay < tmpDay){
				tmpDay = theDay;
			}
		}
		theYearObject.value = tmpYear;
		theMonthObject.value = tmpMonth;
		this.SetDayList(tmpYear, tmpMonth, tmpDay, theTag);
		if (theTag==true){
			theTextObject.value = this.SetDateFormat(tmpYear, tmpMonth, tmpDay);
			theTextObject.select();
		}
	}
	this.UpdateMonthGrid = function(theObject){ //run this.CreateMonthGrid() by theObject
		var theTextObject = this.Source;
		if (theTextObject == null){
			return;
		}
		var theName = this.Name;
		//var theYearObject = document.all.item(theName + "_YearList");
		//var theMonthObject = document.all.item(theName + "_MonthList");
		//var theDayObject = document.all.item(theName + "_DayList");
		var theYearObject = document.getElementById(theName + "_YearList");
		var theMonthObject = document.getElementById(theName + "_MonthList");
		var theDayObject = document.getElementById(theName + "_DayList");
		var tmpName = theObject.id.substr(theObject.id.lastIndexOf("_"));
		switch (tmpName){
			case "_goPreviousMonth": //go previous month button
				theObject.disabled = true;
				this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) - 1, parseInt(theDayObject.value, 10), true);
				theObject.disabled = false;
				break;
			case "_goNextMonth": //go next month button
				theObject.disabled = true;
				this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10) + 1, parseInt(theDayObject.value, 10), true);
				theObject.disabled = false;
				break;
			case "_YearList": //year list
				this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10), true);
				break;
			case "_MonthList": //month list
				this.CreateMonthGrid(parseInt(theYearObject.value, 10), parseInt(theMonthObject.value, 10), parseInt(theDayObject.value, 10), true);
				break;
			default:
				return;
		}
	}
	this.DeleteMonthGrid = function(theTag){ //check document focus, if blur this.Source then delete this
		var theName = this.Name;
		//var theDivObject = document.all.item(theName + "_MonthView");
		var theDivObject = document.getElementById(theName + "_MonthView");
		if (theDivObject == null){
			return;
		}
		if (theTag == true){
			this.RevokeMonthGrid();
			return;
		}
		var tmpObject = document.activeElement;
		while (tmpObject != null){
			if (tmpObject == this.Source){
				return;
			}
			//if (tmpObject.id == theName + "_MonthView"){
			//	return;
			//}
			//if (tmpObject.id == theName + "_MonthGrid"){
			//	return;
			//}
			if (tmpObject.id == theName + "_goPreviousMonth"){
				return;
			}
			if (tmpObject.id == theName + "_goNextMonth"){
				return;
			}
			if (tmpObject.id == theName + "_YearList"){
				return;
			}
			if (tmpObject.id == theName + "_MonthList"){
				return;
			}	
			if (tmpObject.id == theName + "_DayList"){
				return;
			}
			tmpObject = tmpObject.parentElement;
		}
		if (tmpObject == null){ //delete the month view
			this.RevokeMonthGrid();
		}
	}
	this.RevokeMonthGrid = function( ){
		var theName = this.Name;
		//var theDivObject = document.all.item(theName + "_MonthView");
		var theDivObject = document.getElementById(theName + "_MonthView");
		if (theDivObject == null){
			return;
		}
		//theDivObject.outerHTML = "";
		theDivObject.style.visibility = "hidden";
		if (this.Source != null){
			var theDate = new Date(this.GetTextDate(this.Source.value));
			if (isNaN(theDate)){
				this.Source.value = this.InvalidMessage;
			}else{
				this.Source.value = this.SetDateFormat(theDate.getFullYear(), theDate.getMonth(), theDate.getDate());
			}
			this.Source = null;
		}
	}
	this.InitialMonthView = function( ){
		var theName = this.Name;
		var theTag = true;
		var theValue = this.Source.value;
		if (theValue.replace(/ /g,"")==""){
			theTag = false;
		}
		var theCurrentDate = new Date(this.GetTextDate(theValue));
		if (isNaN(theCurrentDate)){
			theCurrentDate = new Date();
			theTag = false;
		}
		var theIETag = this.CheckIE()
		var theDivHTML = "";
		//var theDivObject = document.all.item(theName + "_MonthView");
		var theDivObject = document.getElementById(theName + "_MonthView");
		if (theDivObject == null){
			theDivHTML += "<DIV id=\"" + theName + "_MonthView\" onBlur=\"document.jsMonthView.DeleteMonthGrid(false);\">";
			theDivHTML += "  <TABLE width=\"" + this.Width.toString() + "\" height=\"" + this.Height.toString() + "\" style=\"" + this.MonthGridStyle + "\" cellpadding=\"0\" cellspacing=\"0\">";
			theDivHTML += "    <TR>";
			theDivHTML += "      <TD align=\"center\" valign=\"top\">";
			theDivHTML += "        <TABLE width=\"100%\" height=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">";
			theDivHTML += "          <TR align=\"center\" style=\"" + this.HeaderStyle + "\">";
			theDivHTML += "            <TD>";
			theDivHTML += "              <INPUT type=\"button\" tabIndex=\"-1\" style=\"" + this.MonthBtStyle + "\" id=\"" + theName + "_goPreviousMonth\" value=\"" + this.PreviousMonthText + "\" title=\"" + this.PreviousMonthTitle + "\"";
			theDivHTML += " onClick=\"document.jsMonthView.UpdateMonthGrid(this);\"";
			theDivHTML += " onBlur=\"document.jsMonthView.DeleteMonthGrid(false);\">";
			theDivHTML += "            </TD>";
			theDivHTML += "            <TD>";
			theDivHTML += "              <SELECT id=\"" + theName + "_MonthList\"></SELECT>";
			theDivHTML += "            </TD>";
			theDivHTML += "            <TD>";
			theDivHTML += "              <SELECT id=\"" + theName + "_YearList\"></SELECT>";
			theDivHTML += "              <INPUT type=\"hidden\" id=\"" + theName + "_DayList\" value=\"1\">";
			theDivHTML += "            </TD>";
			theDivHTML += "            <TD>";
			theDivHTML += "              <INPUT type=\"button\" tabIndex=\"-1\" style=\"" + this.MonthBtStyle + "\" id=\"" + theName + "_goNextMonth\" value=\"" + this.NextMonthText + "\" title=\"" + this.NextMonthTitle + "\"";
			theDivHTML += " onClick=\"document.jsMonthView.UpdateMonthGrid(this);\"";
			theDivHTML += " onBlur=\"document.jsMonthView.DeleteMonthGrid(false);\">";
			theDivHTML += "            </TD>";
			theDivHTML += "          </TR>";
			theDivHTML += "          <TR>";
			theDivHTML += "            <TD colspan=\"4\" bgcolor=\"" + this.UnselectBgColor + "\">";
			theDivHTML += "              <DIV id=\"" + theName + "_MonthGrid\">&nbsp;</DIV>";
			theDivHTML += "            </TD>";
			theDivHTML += "          </TR>";
			theDivHTML += "        </TABLE>";
			theDivHTML += "      </TD>";
			theDivHTML += "    </TR>";
			theDivHTML += "  </TABLE>";
			if (theIETag == true){
				theDivHTML += "  <IFRAME frameborder=\"no\" scrolling=\"no\" src=\"/include/blank.asp\" style=\"position:absolute; top:0px; left:0px; width:" + this.Width.toString() + "; height:" + this.Height.toString() + "; z-index:-1;\"></IFRAME>"; //keep out SELECT element
			}
			theDivHTML += "</DIV>";
			document.body.insertAdjacentHTML("beforeEnd", theDivHTML);
			//theDivObject = document.all.item(theName + "_MonthView");
			theDivObject = document.getElementById(theName + "_MonthView");
			this.CreateYearList(this.MinYear, this.MaxYear);
			this.CreateMonthList();
		}
		theDivObject.style.position = "absolute";
		var tmpLeft = this.GetoffsetLeft(this.Source);		
		if (tmpLeft + this.Width > document.body.clientWidth){
			tmpLeft = tmpLeft + this.Source.offsetWidth - this.Width;
		}
		if (tmpLeft < 0){
			tmpLeft = 0;
		}
		theDivObject.style.posLeft = tmpLeft;
		theDivObject.style.posTop = this.GetoffsetTop(this.Source) + this.Source.offsetHeight;
		this.CreateMonthGrid(theCurrentDate.getFullYear(), theCurrentDate.getMonth(), theCurrentDate.getDate(), theTag);
		if ((theIETag == true)||(this.AlwaysShow == true)){
			theDivObject.style.visibility = "inherit";
		}else{
			theDivObject.style.display = "none";
		}
	}
	this.SchemeMonthView = function( ){//restore attribute to default
		return;
	}
}

function CreateMonthView(theTextObject, theScheme){ //the month view create interface, fire at element's onFocus event
  if ((theTextObject.readOnly == true)||(theTextObject.disabled == true)){
    return;
  }
  if (document.jsMonthView == null){
    document.jsMonthView = new DefineMonthView(theTextObject);
  }else{
    if (document.jsMonthView.Source == null){
      document.jsMonthView.Source = theTextObject;
	  document.jsMonthView.SchemeMonthView();
    }else{
	  return;
    }
  }
  var theFormat="";
  switch (GetCookie("Date_Format")){
    case "1":
	  theFormat="<MMM> <dd>,<yyyy>";
	  break;
	case "2":
	  theFormat="<mm>/<dd>/<yyyy>";
	  break;
	case "3":
	  theFormat="<mm>-<dd>-<yyyy>";
	  break;
	case "4":
	  theFormat="<yyyy>/<mm>/<dd>";
	  break;
	case "5":
	  theFormat="<yyyy>-<mm>-<dd>";
	  break;
	case "6":
	  theFormat="<dd>/<mm>/<yyyy>";
	  break;
	case "7":
	  theFormat="<dd>-<mm>-<yyyy>";
	  break;
	default:
	  theFormat="<MMM> <dd>,<yyyy>";
  }
  document.jsMonthView.DateFormat=theFormat;
  document.jsMonthView.AlwaysShow = false;
  document.jsMonthView.AutoHidden = true;
/*
  document.jsMonthView.Width=200;
  document.jsMonthView.Height=150;
  document.jsMonthView.YearListStyle = "width:54px; font-size:10px; font-family:Verdana;"; //the year list's style
  document.jsMonthView.MonthListStyle = "width:90px; font-size:10px; font-family:Verdana;"; //the month list's style
  document.jsMonthView.WeekListStyle = "font-size:12px; font-weight:bolder; font-family:Times new roman;"; //the week name's style
  document.jsMonthView.MonthGridStyle = "border-width:1px; border-style:solid; border-color:#000000;"; //the month view main body's default style
  document.jsMonthView.HeaderStyle = "height:24px; background-color:buttonface;"; //the month view header area's style
  document.jsMonthView.DayListStyle = "cursor:hand; font-size:10px; font-family:Verdana; text-align:center; vertical-align:middle;"; //the month view day area's style
  document.jsMonthView.TodayListStyle = "font-size:10px; font-family:Verdana;"; //the today tip's style
  document.jsMonthView.MonthBtStyle = "font-family:Marlett; font-size:10px; width:18px; height:18px; "; //the change month button style
  document.jsMonthView.LineBgStyle = "height:8px; background-color:" + document.jsMonthView.UnselectBgColor + "; text-align:center; vertical-align:middle;"; //the month view title area and day area compart area background style
*/  
  if (theScheme != null){
    eval(theScheme);
  }
  document.jsMonthView.InitialMonthView();
  theTextObject.select();
}
function DeleteMonthView(theTextObject){ //the month view delete interface, fire at element's onBlur event
  if (document.jsMonthView == null){
    return;
  }
  var winhref = window.location.href.toLowerCase();
  if (((theTextObject.name.toLowerCase() == "etd_date") 
  		&&(winhref.indexOf("bigjobedit.asp")>0))
	||(((theTextObject.name.toLowerCase() == "etd_real_date") 
			||(theTextObject.name.toLowerCase() == "eta_real_date") 
			||(theTextObject.name.toLowerCase() == "audit_to_date"))
		&&((winhref.indexOf("/hbledit.asp")>0)
			||(winhref.indexOf("/soedit.asp")>0)
			||(winhref.indexOf("/noship_soedit.asp")>0)))){
	var curdate = new Date(document.jsMonthView.GetTextDate(theTextObject.value));
	if (!isNaN(curdate)){
	  var nowdate = new Date();
	  var olddate = new Date(nowdate.getFullYear(), nowdate.getMonth()-2,nowdate.getDate());
	  var newdate = new Date(nowdate.getFullYear(), nowdate.getMonth()+2,nowdate.getDate());
      if ((curdate < olddate)||(curdate > newdate)){
	    alert("Please check this date.");
	  }
	}
  }
  document.jsMonthView.DeleteMonthGrid();
  //if (document.jsMonthView.Source == null){
  //  document.jsMonthView = null;
  //}
}

function Menu(theWidth,theHeight){
	if (window.menus == null){
		window.menus = new Array();
	}
	this.id = window.menus.length;
	this.width = theWidth||200;
	this.height = theHeight||20;
	this.left = 0;
	this.top = 0;
	this.arrow = "<span style='font:larger Marlett;'>4</span>";
	this.display = false;
	this.items = new Array();
	this.actions = new Array();
	this.menus = new Array();
	window.menus[this.id] = this;
	
	this.addItem = function(theCaption, theAction, theMenu){
		var iLen = this.items.length;
		this.items[iLen] = theCaption;
		this.actions[iLen] = theAction;
		if (theMenu!=null){
			this.menus[iLen] = theMenu.id;
		}else{
			this.menus[iLen] = null;
		}
	}
	this.getHTML = function(theLeft, theTop){
		this.left = theLeft;
		this.top = theTop;
		var MenuHTML = "";
		MenuHTML += "<DIV id='Menu" + this.id + "' class='menu' style='visibility:hidden; width:" + this.width + "px; height:" + (this.items.length * this.height) + "px; left:" + theLeft + "px; top:" + theTop + "px;'>";
		MenuHTML += "<TABLE cellpadding='0' cellspacing='0' onMouseOver='window.menus[" + this.id + "].show(0, 0);' onMouseOut='outMenu(" + this.id + ");'>";
		for (var i=0;i<this.items.length;i++){
			MenuHTML += ("<TR style='height:" + this.height + "px;' onMouseOver='overMenuItem(" + this.id + ", this)' onMouseOut='outMenuItem(" + this.id + ", this)' onClick='eval(window.menus[" + this.id + "].actions[" + i + "]);'>");
			MenuHTML += ("<TD width='12'>&nbsp;</TD><TD>" + this.items[i] + "</TD><TD width='12'>");
			if (this.menus[i]!=null){
				MenuHTML += this.arrow;
				MenuHTML += window.menus[this.menus[i]].getHTML(this.width - 3, (i * this.height) + 3);
			}else{
				MenuHTML += "&nbsp;";
			}
			MenuHTML += "</TD></TR>";
		}
		MenuHTML += "</TABLE>";
		if (checkIE()==true){
			MenuHTML += "<IFRAME frameborder=\"no\" scrolling=\"no\" src=\"/include/blank.asp\" style=\"position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:-1;\"></IFRAME>";
		}
		MenuHTML += "</DIV>";
		return(MenuHTML);
	}
	this.show = function(theLeft, theTop){
		var tmpLeft = 0, tmpTop = 0;
		//var oMenu = document.all.item("Menu" + this.id);
		var oMenu = document.getElementById("Menu" + this.id);
		if (oMenu==null){
			document.body.insertAdjacentHTML("beforeEnd", this.getHTML(theLeft, theTop));
			//oMenu = document.all.item("Menu" + this.id);
			oMenu = document.getElementById("Menu" + this.id);
		}else{
			if ((theLeft==0)&&(theTop==0)){
				tmpLeft = this.left;
				tmpTop = this.top;
			}else{
				tmpLeft = theLeft;
				tmpTop = theTop;
			}
			oMenu.style.posLeft = tmpLeft;
			oMenu.style.posTop = tmpTop;
		}
		this.display = true;
		oMenu.style.visibility = "inherit";
		hideElements();
		return;
	}
	this.hide = function( ){
		if (this.display == true){
			return;
		}
		for (var i=0;i<this.items.length;i++){
			if (this.menus[i]!=null){
				if (window.menus[this.menus[i]].display==true){
					this.display = true;
					return;
				}
			}
		}
		this.display = false;
		//document.all.item("Menu" + this.id).style.visibility = "hidden";
		document.getElementById("Menu" + this.id).style.visibility = "hidden";
		var hasMenu = false;
		for(var i=0;i<window.menus.length;i++){
			if (window.menus[i].display==true){
				hasMenu = true;
			}
		}
		if (hasMenu==false){
			showElements();
		}
		return;
	}
}
function checkIE(){
	var version = "";
	var navAgent = navigator.userAgent;
	var navIndex = navAgent.indexOf("MSIE");
	if (navIndex == -1){
		return(false);
	}else{
		version = navAgent.substr(navIndex + 4, 4);
		if (isNaN(parseFloat(version))){
			return(false);
		}else{
			if (parseFloat(version) > 5.0){
				return(true);
			}else{
				return(false);
			}
		}
	}
}
function outMenu(theMenuId){
	window.menus[theMenuId].display = false;
	setTimeout("window.menus[" + theMenuId.toString() + "].hide()",1000);
	return true;
}
function overMenuItem(theMenuId, theItem){
	var theStyle = theItem.style;
	theStyle.backgroundColor = "#6464B1";
	theStyle.color = "#FFFFFF";
	var subMenuId = window.menus[theMenuId].menus[theItem.rowIndex];
	if (subMenuId!= null){
		window.menus[subMenuId].display = true;
		//document.all.item("Menu" + subMenuId).style.visibility = "inherit";
		document.getElementById("Menu" + subMenuId).style.visibility = "inherit";
	}
	return true;
}
function outMenuItem(theMenuId, theItem){
	var theStyle = theItem.style;
	theStyle.backgroundColor = "#FFFFFF";
	theStyle.color = "#000000";
	var subMenuId = window.menus[theMenuId].menus[theItem.rowIndex];
	if (subMenuId!= null){
		window.menus[subMenuId].display = false;
		//document.all.item("Menu" + subMenuId).style.visibility = "hidden";
		document.getElementById("Menu" + subMenuId).style.visibility = "hidden";
	}
	return true;
}
function showMenu(theMenu,theLeft,theTop){
	var oMenu = null;
	for (var i=0;i<window.menus.length;i++){
		//oMenu = document.all.item("Menu"+i);
		oMenu = document.getElementById("Menu"+i);
		if (oMenu!=null){
			window.menus[i].display=false;
			oMenu.style.visibility = "hidden";
		}
	}
	theMenu.left = theLeft;
	theMenu.top = theTop;
	theMenu.show(theLeft,theTop);
	return true;
}
function hideMenu(theMenu){
	outMenu(theMenu.id);
	return true;
}

function hideElements(){
	var i = 0, elelen = 0, tmpele = null;
	if (checkIE() == false){
		var theform = eval("document.forms[0]");
		if (theform != null){
			elelen=theform.elements.length;
			for (i=0;i<elelen;i++){
				tmpele=theform.elements[i];
				if (tmpele.type=="select-one"){
					tmpele.style.visibility = "hidden";
				}
			}
			for (i=0;i<window.frames.length;i++){
				if ((window.frames[i].name!=null)&&(window.frames[i].name!="")){				
					document.all.item(window.frames[i].name).style.visibility = "hidden";
				}
			}
		}
	}
}

function showElements(){
	var i = 0, elelen = 0, tmpele = null;
	if (checkIE() == false){
		var theform = eval("document.forms[0]");
		if (theform != null){
			elelen=theform.elements.length;
			for (i=0;i<elelen;i++){
				tmpele=theform.elements[i];
				if (tmpele.type=="select-one"){
					tmpele.style.visibility = "inherit";
				}
			}
			for (i=0;i<window.frames.length;i++){
				if ((window.frames[i].name!=null)&&(window.frames[i].name!="")){
					document.all.item(window.frames[i].name).style.visibility = "inherit";
				}
			}
		}
	}
}
