
var isNav, isIE, IE6

	isIE = (document.all) ? 1 : 0;
    isNav = (document.layers) ? 1 : 0;
    ver4 = (isIE || isNav) ? 1 : 0;
	IE6 = isIE&&document.getElementById?true:false;

var coll = ""
var styleObj = ""

if (ver4) {
	if (isIE || IE6){
		coll = "all."
		styleObj = ".style"
	}
}

function getObjHeight(obj) {
	if (isNav) {
		return obj.clip.height
	} else {
		return obj.clientHeight
	}
}

function getObjWidth(obj) {
	if (isNav) {
		return obj.clip.width
	} else {
		return obj.clientWidth
	}
}

function getInsideWindowWidth() {
	if (isNav) {
		return window.innerWidth
	} else {
		return document.body.clientWidth
	}
}

function getInsideWindowHeight() {
	if (isNav) {
		return window.innerHeight
	} else if (IE6) {
		return document.getElementById("docBody").offsetHeight;
	} else {
		return document.body.clientHeight
	}
}

function shiftTo(obj, x, y) {
	if (isNav) {
		obj.moveTo(x,y)
	} else {
		obj.pixelLeft = x
		obj.pixelTop = y
	}
}

function setSize(obj, x, y) {
	if (isNav) {
		obj.clip.width = x
		obj.clip.height = y
	} else {
		obj.pixelWidth = x
		obj.pixelHeight = y
	}
}

function getObjectTop(obj) {
	if (isNav) {
		return obj.top
	} else {
		return obj.pixelTop
	}
}

function getObjectLeft(obj) {
	if (isNav) {
		return obj.left
	} else {
		return obj.pixelLeft
	}
}

function centerIt() {
		windowHeight = getInsideWindowHeight();
		windowWidth = getInsideWindowWidth();


//Adjusting Home Centre Object Object
		var objCenter = eval("document." + coll + "centerContent" + styleObj)
		var contentObjCenter = eval("document." + coll + "centerContent")
		var xCenter = Math.round((getInsideWindowWidth()/2) - (getObjWidth(contentObjCenter)/2))
		var yCenter = Math.round((getInsideWindowHeight()/2) - (getObjHeight(contentObjCenter)/2)) + 20
		shiftTo(objCenter, xCenter, yCenter-10)
		
		
		
//Adjusting rightBottom Object
		var obj = eval("document." + coll + "abBottom" + styleObj)
		var contentObj = eval("document." + coll + "abBottom")
		var x = 0
		var y = windowHeight - 51
		shiftTo(obj, x, y)
		
		obj.visibility="visible"
		objCenter.visibility="visible"
}

function handleResize() {
	if (isNav) {
		location.reload()
	} else {
		centerIt()
	}
}

function formSubmit(objForm, pageAction) {
		objForm.action = pageAction;
		objForm.submit();
}

function StringTrim(trimstring){
	var TestString = trimstring;
	var SpaceChar  = " ";
	while (TestString.charAt(0) == SpaceChar) {TestString = TestString.substr(1)};
	while (TestString.charAt(TestString.length-1) == SpaceChar) {TestString = TestString.substr(0,TestString.length-1)};
	return TestString;
}

function trackPacket(ID, Forwarder){
newWindow = window.open("/tracking/pageRedirect.asp?forwardingID=" + ID + "&awbForwarderAWBNo=" + Forwarder , "subWind")
newWindow.focus()
}

var dtCh= "/";
var minYear=1900;
var maxYear=2100;

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 stripCharsInBag(s, bag){
	var i;
    var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    for (i = 0; i < s.length; i++){   
        var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
}

function daysInFebruary (year){
	// February has 29 days in any year evenly divisible by four,
    // EXCEPT for centurial years which are not also divisible by 400.
    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
}

function isDate(dtStr){
	var daysInMonth = DaysArray(12)
	var pos1=dtStr.indexOf(dtCh)
	var pos2=dtStr.indexOf(dtCh,pos1+1)
	var strMonth=dtStr.substring(0,pos1)
	var strDay=dtStr.substring(pos1+1,pos2)
	var strYear=dtStr.substring(pos2+1)
	strYr=strYear
	if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
	if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
	for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
	}
	month=parseInt(strMonth)
	day=parseInt(strDay)
	year=parseInt(strYr)
	if (pos1==-1 || pos2==-1){
		alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]){
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
		alert("Please enter a valid 4 digit year between "+minYear+" and "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false){
		alert("Please enter a valid date")
		return false
	}
return true
}

function ValidDateForm(txtDate){
	var dt
	eval("dt=document.upex." + txtDate)
	if (isDate(dt.value)==false){
		dt.focus()
		return false
	}
    return true
 }

