﻿function getScrollXY() {
  var scrOfX = 0, scrOfY = 0;
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scrOfY = window.pageYOffset;
    scrOfX = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scrOfY = document.body.scrollTop;
    scrOfX = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    //IE6 standards compliant mode
    scrOfY = document.documentElement.scrollTop;
    scrOfX = document.documentElement.scrollLeft;
  }
  return [ scrOfX, scrOfY ];
}

function getWindowSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  return [ myWidth, myHeight ];
}



function btnCityClick(preID){
    
    var objDiv=document.getElementById(preID+"divCity")
    var objTable=document.getElementById(preID+"tblCity")
    var objFrame=document.getElementById(preID+"frmCity")
    objDiv.style.top="10px";
    objDiv.style.left="10px";
    objDiv.style.visibility="visible"
    objDiv.style.display="block"
    objFrame.style.width=objTable.clientWidth;
    objFrame.style.height=objTable.clientHeight;
}

function btnAirportClick(preID){
    var objDiv=document.getElementById(preID+"divAirport")
    var objTable=document.getElementById(preID+"tblAirport")
    var objFrame=document.getElementById(preID+"frmAirport")
/*
    var objCriteria=document.getElementById(preID.split('_')[0] +"_pnlCriteria")
    var rslt=document.getWhere(objCriteria);
    objDiv.style.top=rslt[1].toString()+"px";
    objDiv.style.left=rslt[0].toString()+"px";
*/    
    objDiv.style.top="10px";
    objDiv.style.left="10px";
    objDiv.style.visibility="visible"
    objDiv.style.display="block"
    objFrame.style.width=objTable.clientWidth;
    objFrame.style.height=objTable.clientHeight;
}

function btnDistrictClick(preID){
    var objDiv=document.getElementById(preID+"divDistrict")
    var objTable=document.getElementById(preID+"tblDistrict")
    var objFrame=document.getElementById(preID+"frmDistrict")
    objDiv.style.top="10px";
    objDiv.style.left="10px";
    objDiv.style.visibility="visible"
    objDiv.style.display="block"
    objFrame.style.width=objTable.clientWidth;
    objFrame.style.height=objTable.clientHeight;
}

function airportClose(preID){
    objTable=document.getElementById(preID+"_divAirport")
    objTable.style.display="none";
    objTable.style.visibility="hidden";
}

function districtClose(preID){
    objTable=document.getElementById(preID+"_divDistrict")
    objTable.style.display="none";
    objTable.style.visibility="hidden";
}
document.getWhere= function (who){
    var T= 0, L= 0;
    while(who!=null){
	    if(who.offsetLeft!=undefined){
	        L += who.offsetLeft;
	        T += who.offsetTop;
	    }
	    who= who.offsetParent;
    }
    return [L, T];
}

function citySelect(obj,preID){
    objTable=document.getElementById(preID+"divCity")
    objTable.style.visibility="visible"
    
    if (obj.selectedIndex>=0){
        cityName=obj.options[obj.selectedIndex].value
        objTable=document.getElementById(preID+"divCity")
        objTable.style.visibility="hidden"
        objCity=document.getElementById(preID+"txtCity")
        objCity.value=cityName;
    }
}

function getCityName(objID){
    objCity=document.getElementById(objID+"_txtCity")
    return objCity.value.split('[')[0];
}    
function setCityName(objID,cityNameValue){
    objCity=document.getElementById(objID+"_txtCity")
    objCity.value=cityNameValue;
}    
function majorCitySelect(preID){
    objCity=document.getElementById(preID+"_txtCity")
    objMajor=document.getElementById(preID+"_majorCity")
    objCity.value=objMajor.value;
    cityClose(preID);
}
function cityClose(preID){
    objTable=document.getElementById(preID+"_divCity")
    objTable.style.display="none";
    objTable.style.visibility="hidden";
}
