
<!--

/***********************************************
* Auto Maximize Window Script- © Dynamic Drive (www.dynamicdrive.com)
* This notice must stay intact for use
* Visit http://www.dynamicdrive.com/ for this script and 100's more.
***********************************************/

top.window.moveTo(0,0);
if (document.all) {
top.window.resizeTo(screen.availWidth,screen.availHeight);
}
else if (document.layers||document.getElementById) {
if (top.window.outerHeight<screen.availHeight||top.window.outerWidth<screen.availWidth){
top.window.outerHeight = screen.availHeight;
top.window.outerWidth = screen.availWidth;
}
}
//-->

var objXMLHttp=null
var xmlHttp=null

function init()
{
    
    var areaf="AS"
    var areat="NA"
    var portfm=""
    var portto=""
    var i,leng

    areaf = document.myform.areaf.options[document.myform.areaf.selectedIndex].value
    areat = document.myform.areaf.options[document.myform.areat.selectedIndex].value
    
    chgoption1(areaf)
    chgoption2(areat)
    if (portfm != "")
    {
       selectop(document.myform.d_locfm_AS,portfm)
    }
    if (portto != "")
    {
       selectop(document.myform.d_locto_NA,portto)
    }
	document.myform.h_version.value = navigator.appVersion;
}

function selectop(obj,port)
{
    var i, leng
    leng = obj.options.length
    i = 0
    while (i < leng)
    {
        if(obj.options[i].value==port)
        {  obj.options[i].selected=true
           break
        }
        i++
    }
}

function chgoption1(areaf)
{   
    document.myform.d_locfm_NA.style.display="none"
    document.myform.d_locfm_AS.style.display="none"
    document.myform.d_locfm_AF.style.display="none"
    document.myform.d_locfm_EU.style.display="none"
    document.myform.d_locfm_SA.style.display="none"
    if (areaf == "NA")
    {
       document.myform.d_locfm_NA.style.display=""
    }
    else if (areaf=="SA") 
    {
    	document.myform.d_locfm_SA.style.display=""
    }
    else if (areaf == "AS")
    {
       document.myform.d_locfm_AS.style.display=""
    }
    else if (areaf == "AF")
    {
       document.myform.d_locfm_AF.style.display=""
    }
    else if (areaf == "EU")
    {
       document.myform.d_locfm_EU.style.display=""
    }
}

function chgoption2(areat)
{
    document.myform.d_locto_NA.style.display="none"
    document.myform.d_locto_AS.style.display="none"
    document.myform.d_locto_AF.style.display="none"
    document.myform.d_locto_EU.style.display="none"
    document.myform.d_locto_SA.style.display="none"

    if (areat == "NA")
    {
       document.myform.d_locto_NA.style.display=""
    }
    else if(areat=="SA")
    {
       document.myform.d_locto_SA.style.display=""
    }
    else if (areat == "AS")
    {
       document.myform.d_locto_AS.style.display=""
    }
    else if (areat == "AF")
    {
       document.myform.d_locto_AF.style.display=""
    }
    else if (areat == "EU") 
    {
       document.myform.d_locto_EU.style.display=""
    }
}

function chg(area)
{
    var areaop
    var length, i
    if (area == "areafm")
   {  
       leng = document.myform.areaf.length
       for (i = 0; i<leng; i++)
       {
           if (document.myform.areaf.options[i].selected)
           {
              areaop = document.myform.areaf.options[i].value
              chgoption1(areaop)
              break
           }
       }
    }
    else if (area == "areato")
    {
       leng = document.myform.areat.length
       for (i = 0; i<leng; i++)
       {
           if (document.myform.areat.options[i].selected)
           {
              areaop = document.myform.areat.options[i].value
              chgoption2(areaop)
              break;
           }
       }
    }
}

function GetXmlHttpObject()
{ 	
	if (window.XMLHttpRequest)
	{
	objXMLHttp=new XMLHttpRequest()
	}
	else if (window.ActiveXObject)
	{
	objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
	}
	return objXMLHttp
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
	{ 
	//document.getElementById("pp").innerHTML=xmlHttp.responseText 
	} 
} 

function GoSubmit() {
	document.myform.h_Submit.click();
	document.myform.action = "schedule_point_search_01.asp";
	document.myform.submit = true;
}

function GoReset() {
	document.myform.h_Reset.click();
}

function CheckDate() {
 
             if((document.myform.t_datefm.value == "") || (document.myform.t_dateto.value == "")){
                  alert("Please input date range.");
                  return false;
             }
             
             if(document.myform.t_datefm.value.length != 10){
                alert("From date length is invalid!");
                return false;
             }
             
	if (document.myform.t_datefm.value.substring(4,5) != "/" || document.myform.t_datefm.value.substring(7,8) != "/") {
	    alert ("The value of date range format is YYYY/MM/DD .");
	    return false;
	} 

	if(!isDateFormat(document.myform.t_datefm.value)){
	    return false;
	}
	
             if(document.myform.t_dateto.value.length != 10){
                alert("To date length is invalid!");
                return false;
             }
	
	if (document.myform.t_dateto.value.substring(4,5) != "/" || document.myform.t_dateto.value.substring(7,8) != "/") {
		alert ("The value of date range  format is YYYY/MM/DD .");
		return false;
	}
	
	if(!isDateFormat(document.myform.t_dateto.value)){
	    return false;
	}
	
	return true;
}

function isDateFormat(sdate){
 var strMonth = "";
 var strYear = "";
 var strDay = "";
 var daysInMonth = DaysArray(12);

       strYear = sdate.substring(0,4);
       if(!isInteger(strYear)){
           alert("Year is invalid !");
           return false;
       }
       strMonth = sdate.substring(5,7);
       if (strMonth.charAt(0)=="0" && strMonth.length>1) 
          strMonth=strMonth.substring(1);
      
       if(!isInteger(strMonth)){
           alert("Month is invalid !");
           return false;
       }
       strDay = sdate.substring(8,10);
       if (strDay.charAt(0)=="0" && strDay.length>1) 
          strDay=strDay.substring(1);
       
       if(!isInteger(strDay)){
           alert("Day is invalid !");
           return false;
       }

       year = parseInt(strYear);
       month = parseInt(strMonth);
       day = parseInt(strDay);

       if (month < 1 || month > 12){
           alert("Please enter a valid month.");
           return false;
       }
       if (day < 1 || day > 31 || (month == 2 && day > daysInFebruary(year)) || day > daysInMonth[month]){
           alert("Please enter a valid day.");
           return false;
       }
       
       return true;
}
function isInteger(s){
var i;
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (((c < "0") || (c > "9")))
           return false;
    }
    return true;
}
function daysInFebruary (year){
    return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
}

function DaysArray(n) {
   for (var i = 1; i <= n; i++) {
        this[i] = 31;
        if (i == 4 || i == 6 || i == 9 || i == 11) {
           this[i] = 30;
        }
        if (i == 2) {
           this[i] = 29;
       }
   } 
   return this;
}

