﻿/*
 *  General Cross Browser Java Script Function 
 */

var RefAd = new Array();

// hide advertisement panels when screen resolution width less than 1000
function CheckScreenRes()
{
	if (document.body.clientWidth < 1000)
	{	
		for (i=0; i<RefAd.length;i++)
		{
			if (RefAd[i] != undefined) RefAd[i].style.display = 'none';
		}			
	}
}

// validate du lieu tren form eTicket
function eTicket_Validate(lang, objTicketNo, objFOID)
{
	if (objTicketNo != null && objFOID != null) { // begin If
		if (objTicketNo.value == '') 
		{
			if (lang == 'EN') alert('Please, Enter Ticket No');
			else alert('Cần Nhập Số Vé');
			objTicketNo.focus();
			return false;
		}
		
		if (objFOID.value == '') 
		{
			if (lang == 'EN') alert('Please, Enter Passenger Name');
			else alert('Cần Nhập Tên Hành Khách');
			objFOID.focus();
			return false;
		}
	}
	return true;
}
// --------------------------
// Begin Calendar
// --------------------------
// This function shows the calendar under the element having the given id.
// It takes care of catching "mousedown" signals on document and hiding the
// calendar if the click was outside.
function showCalendar(id, format, showsOtherMonths, buttonId) {
  var button = document.getElementById(buttonId);
  var el = document.getElementById(id);
  if (_dynarch_popupCalendar != null) {
    // we already have some calendar created
    _dynarch_popupCalendar.hide();                 // so we hide it first.
  } else {
    // first-time call, create the calendar.
    var cal = new Calendar(1, null, selected, closeHandler);
    // uncomment the following line to hide the week numbers
    cal.weekNumbers = false;
    /*if (typeof showsTime == "string") {
      cal.showsTime = true;
      cal.time24 = (showsTime == "24");
    }*/
    if (showsOtherMonths) {
      cal.showsOtherMonths = true;
    }
    _dynarch_popupCalendar = cal;                  // remember it in the global var
    // customize range of date enabled
    cal.setDateStatusHandler(dateStatusFunc);
    cal.setRange(today.getFullYear(), today.getFullYear() + 1);        // min/max year allowed, only allow the current and the next year.
    cal.create();
  }
 
  _dynarch_popupCalendar.setDateFormat(format);    // set the specified date format
  _dynarch_popupCalendar.parseDate(el.value);      // try to parse the text in field
  _dynarch_popupCalendar.sel = el;                 // inform it what input field we use

  // the reference element that we pass to showAtElement is the button that
  // triggers the calendar.  In this example we align the calendar bottom-right
  // to the button.
  _dynarch_popupCalendar.showAtElement(button, false);        // show the calendar
  
  //var p = Calendar.getAbsolutePos(button);
  //alert(button.offsetHeight);
  //_dynarch_popupCalendar.showAt(p.x, p.y + button.offsetHeight);        // show the calendar

  return false;
}

// And this gets called when the end-user clicks on the _selected_ date,
// or clicks on the "Close" button.  It just hides the calendar without
// destroying it.
function closeHandler(cal) {
  cal.hide();                        // hide the calendar
//  cal.destroy();
  _dynarch_popupCalendar = null;
}
// --------------------------
// End Calendar
 // --------------------------
 
 //------------------------------ BEGIN Schedule --------------------------------
 // Lay ve ngay Depart duoc chon, cap nhat hidden field
function VNASchedule_getDepartDate(objDayDepart, objMonthDepart, objHdDepart)
{
	var departDate = new Date();
	departDate.setFullYear(objMonthDepart.value.substring(3));
	departDate.setMonth(objMonthDepart.value.substring(0,2) - 1);
	departDate.setDate(objDayDepart.value);

	// Set value to validate Departure Date
	objDayDepart.value = departDate.getDate();
	var DepartMonth = departDate.getMonth() + 1;
	if (DepartMonth < 10) 
	{
		DepartMonth = "0" + DepartMonth;
	}
	objMonthDepart.value = DepartMonth + "/" + departDate.getFullYear();
	
	// Update value of hidden field hdDepart
	objHdDepart.value = departDate.getDate() + "/" + (departDate.getMonth() + 1) + "/" + departDate.getFullYear();
}


// Lay ve ngay Return duoc chon, cap nhat hidden field
function VNASchedule_getReturnDate(objDayReturn, objMonthReturn, objHdReturn)
{
	var returnDate = new Date();
	returnDate.setFullYear(objMonthReturn.value.substring(3));
	returnDate.setMonth(objMonthReturn.value.substring(0,2) - 1);
	returnDate.setDate(objDayReturn.value);
		
	// validate return date   
	objDayReturn.value = returnDate.getDate();
	var ReturnMonth = returnDate.getMonth() + 1;
	if (ReturnMonth < 10)
	{ 
		ReturnMonth = "0" + ReturnMonth;
	}
	objMonthReturn.value = ReturnMonth + "/" + returnDate.getFullYear();
	
	// Update value of hidden field hdReturn
	objHdReturn.value = returnDate.getDate() + "/" + (returnDate.getMonth() + 1) + "/" + returnDate.getFullYear();
}

// This function gets called when the end-user clicks on some date.
function VNASchedule_selected(cal, date, objDepartDay, objDepartMonth, objDepartDOW, objHdDepart, objReturnDay, objReturnMonth, objReturnDOW, objHdReturn, DOW, bReturnChanged) {
  cal.sel.value = date; // just update the date in the input field.
  if (cal.dateClicked && (cal.sel.id == objHdReturn.id || cal.sel.id == objHdDepart.id))
  {
	// If this is return date
	if (cal.sel.id == objHdReturn.id) {
		if ((objReturnDay != null) && (objReturnMonth!=null)) 
		{
			objReturnDay.value = date.substr(0,2) * 1;
			objReturnMonth.value = date.substr(3,7);
			
			// Cap nhat DOW cho ReturnDate
			var returnDate = new Date();
			returnDate.setFullYear(objReturnMonth.value.substring(3));
			returnDate.setMonth(objReturnMonth.value.substring(0,2) - 1);
			returnDate.setDate(objReturnDay.value);						
			
			objReturnDOW.value = DOW[returnDate.getDay()];
			
			// Cap nhat bien bReturnChanged
			bReturnChanged = true;
		}
	}
	
	// If this is depart date
	if (cal.sel.id == objHdDepart.id) {
		if ((objDepartDay != null) && (objDepartMonth!=null)) 
		{
			objDepartDay.value = date.substr(0,2) * 1;
			objDepartMonth.value = date.substr(3,7);
			// tang gia tri ngay ve
			VNASchedule_ReturnDayIncr(objDepartDay, objDepartMonth, objDepartDOW, objHdDepart, objReturnDay, objReturnMonth, objReturnDOW, objHdReturn, DOW, bReturnChanged);
		}
	}
	
    // if we add this call we close the calendar on single-click.
    // just to exemplify both cases, we are using this only for the 1st
    // and the 3rd field, while 2nd and 4th will still require double-click.
    cal.callCloseHandler();
  }
}

// Begin ReturnDayIncr() function -- Tang gia tri ngay ve len 2 ngay so voi ngay di
function VNASchedule_ReturnDayIncr(objDayDepart, objMonthDepart, objDepartDOW, objHdDepart, objDayReturn, objMonthReturn, objReturnDOW, objHdReturn, DOW, bReturnChanged) { // begin function
	if (objDayDepart != null && objMonthDepart != null) {
		var departDate = new Date();
		departDate.setFullYear(objMonthDepart.value.substring(3));
		departDate.setMonth(objMonthDepart.value.substring(0,2) - 1);
		departDate.setDate(objDayDepart.value);				
		// cap nhat DOW cho DepartDate
		objDepartDOW.value = DOW[departDate.getDay()];

		// Set value to validate Departure Date
		objDayDepart.value = departDate.getDate();
		var DepartMonth = departDate.getMonth() + 1;
		if (DepartMonth < 10) 
		{
			DepartMonth = "0" + DepartMonth;
		}
		objMonthDepart.value = DepartMonth + "/" + departDate.getFullYear();
		
		// Update value of hidden field hdDepart
		objHdDepart.value = departDate.getDate() + "/" + (departDate.getMonth() + 1) + "/" + departDate.getFullYear();
		
		// if Return Date is changed by user
		if (bReturnChanged) return;	
		
		// ensure that return date is always greater than departure date
		var returnDate = new Date(departDate);
		returnDate.setDate(departDate.getDate() + 3); 
		
		// cap nhat DOW cho ReturnDate
		objReturnDOW.value = DOW[returnDate.getDay()];
		
		objDayReturn.value = returnDate.getDate();
		var ReturnMonth = returnDate.getMonth() + 1;
		if (ReturnMonth < 10)
		{ 
			ReturnMonth = "0" + ReturnMonth;
		}
		objMonthReturn.value = ReturnMonth + "/" + returnDate.getFullYear();

		// Update value of hidden field hdReturn
		objHdReturn.value = returnDate.getDate() + "/" + (returnDate.getMonth() + 1) + "/" + returnDate.getFullYear();

		// reset return date check value
		bReturnChanged = false;
	} // end If
} // end function
// End ReturnDayIncr() function 

// Khoi tao gia tri cac control phuc vu hien thi ngay thang
function initializeDateControls(objDayDepart, objMonthDepart, objDOWDepart, objHdDepart, objDOWReturn, objHdReturn, DOW) {
	if (objDayDepart != null && objMonthDepart != null) {
		var departDate = new Date();
		departDate.setFullYear(objMonthDepart.value.substring(3));
		departDate.setMonth(objMonthDepart.value.substring(0,2) - 1);
		departDate.setDate(objDayDepart.value);		

		// cap nhat DOW cho DepartDate
		objDOWDepart.value = DOW[departDate.getDay()];

		// Update value of hidden field hdDepart
		objHdDepart.value = departDate.getDate() + "/" + (departDate.getMonth() + 1) + "/" + departDate.getFullYear();
			
		var returnDate = new Date();
		returnDate.setFullYear(objMonthReturn.value.substring(3));
		returnDate.setMonth(objMonthReturn.value.substring(0,2) - 1);
		returnDate.setDate(objDayReturn.value);				
		
		// cap nhat DOW cho ReturnDate
		objDOWReturn.value = DOW[returnDate.getDay()];
		
		// Update value of hidden field hdReturn
		objHdReturn.value = returnDate.getDate() + "/" + (returnDate.getMonth() + 1) + "/" + returnDate.getFullYear();
	} // end If
}

function VNASchedule_SetReturnDisabled(objDOWReturn, objDayReturn, objMonthReturn, objOneway, objLinkReturnDate) { // begin function 
	if (objDOWReturn!= null && objOneway != null && objDayReturn != null && objMonthReturn != null) {     
		if (objOneway.checked) {
			objDOWReturn.disabled = true;
			objDayReturn.disabled = true;
			objMonthReturn.disabled = true;
			objLinkReturnDate.onclick = null;
		}
		else {
			objDOWReturn.disabled = false;
			objDayReturn.disabled = false;
			objMonthReturn.disabled = false;
			objLinkReturnDate.onclick = returnDateClicked;
		}
	} // end If        
} // end function        
//-- End SetRowVisible() function

//-- Begin DateValidate function -- Validate gia tri ngay duoc chon, tranh de nhung ngay khong co thuc
function VNASchedule_DateValidate(bReturnChanged, objDayReturn, objMonthReturn, objReturnDOW, objHdReturn, DOW) { // begin function
	// set value to detect when return date changed
	bReturnChanged = true;
	if (objDayReturn != null && objMonthReturn != null) { // begin If
		var returnDate = new Date();
		returnDate.setFullYear(objMonthReturn.value.substring(3));
		returnDate.setMonth(objMonthReturn.value.substring(0,2) - 1);
		returnDate.setDate(objDayReturn.value);
				
		// cap nhat DOW cho ReturnDate
		objReturnDOW.value = DOW[returnDate.getDay()];
		
		// Set value to validate Return Date
		objDayReturn.value = returnDate.getDate();
		var ReturnMonth = returnDate.getMonth() + 1;
		if (ReturnMonth < 10)
		{ 
			ReturnMonth = "0" + ReturnMonth;
		}
		objMonthReturn.value = ReturnMonth + "/" + returnDate.getFullYear();
		
		// Update value of hidden field hdReturn
		objHdReturn.value = returnDate.getDate() + "/" + (returnDate.getMonth() + 1) + "/" + returnDate.getFullYear();

	} // end If
} // end function
//-- End DateValidate() function

//-- Form validate
function VNASchedule_FormValidate(lang, objAPFrom, objAPTo, objDayDepart, objMonthDepart, objDayReturn, objMonthReturn, objOneway) { // begin function
	// AirportValidate() function -- Thong bao khi chon 2 san bay trung nhau
	if (objAPFrom != null && objAPTo != null) { // begin If
		if (objAPFrom.value == '') 
		{
			if (lang == 'EN') alert('Please Select A Flight Origin City');
			else alert('Cần chọn một Điểm đi');
			objAPFrom.focus();
			return false;
		}
		
		if (objAPTo.value == '') 
		{
			if (lang == 'EN') alert('Please Select A Flight Destination City');
			else alert('Cần chọn một Điểm đến');			
			objAPTo.focus();
			return false;
		}
		
		if (objAPFrom.value == objAPTo.value) 
		{
			if (lang == 'EN') alert('Flight Origin City And Flight Destination City Must Be Different');
			else alert('Điểm đi và Điểm đến không được trùng nhau');	
			objAPTo.focus();
			return false;
		}
	} // end If
	
	// Date Validate
	if (objDayDepart != null && objMonthDepart != null && objOneway != null) {
		if (objOneway.checked == false) {
			var departDate = new Date();
			departDate.setFullYear(objMonthDepart.value.substring(3));
			departDate.setMonth(objMonthDepart.value.substring(0,2) - 1);
			departDate.setDate(objDayDepart.value);		

			var returnDate = new Date();
			returnDate.setFullYear(objMonthReturn.value.substring(3));
			returnDate.setMonth(objMonthReturn.value.substring(0,2) - 1);
			returnDate.setDate(objDayReturn.value);				
			
			if (returnDate < departDate) {
				if (lang == 'EN') alert('Return Date Must Be After Departure Date');
				else alert('Giá trị Ngày về không được nhỏ hơn giá trị Ngày đi');	
				objDayReturn.focus();
				return false;
			}
		}
	} // end If
	
	return true;
} // end function

//-- AirportValidate() function -- Thong bao khi chon 2 san bay trung nhau
function VNASchedule_AirportValidate(lang, objAPFrom, objAPTo) { // begin function
	if (objAPFrom != null && objAPTo != null) { // begin If	
		if (objAPFrom.value == objAPTo.value) {
			if (lang == 'EN') alert('Flight Origin City And Flight Destination City Must Be Different');
			else alert('Điểm đi và Điểm đến không được trùng nhau');
			objAPTo.focus();
			return void(0);
		}
	} // end If
} // end function
// -------------------------- END SCHEDULE --------------------------
 
 
 //++
// cross browser get object by id or name.  if the name is
// not a string, it is passed by unchanged since it can't be an id.
// if it is a string, it tries DOM first, then IE 4/5 then Netscape 4
// if forceIEBehavior is true and the getElementById
// fails, routine will try to find a name instead of IE
//--
function getObj( name, forceIEBehavior )
{
    var newObj;
    if ( typeof name == "string" ) {
        if (document.getElementById) {
            newObj = document.getElementById(name);
            if ( newObj == null && forceIEBehavior != null & forceIEBehavior ) {
                var newObjArray = document.getElementsByName( name );
                if ( newObjArray != null && newObjArray.length > 0 ) 
                    newObj = newObjArray[ 0 ];
            }else{
                var newObjArray = document.getElementsByName( name );
                if ( newObjArray != null && newObjArray.length > 0 ) 
                    newObj = newObjArray[ 0 ];
            }
        }
        else if (document.all) {
            newObj = document.all[name];
        }
        else if (document.layers) {
            newObj = document.layers[name];
        }
    }
    else
        newObj = name;
    return newObj;
}


//++
// cross browser get all objects with the same name in an array.
// tries DOM first, then IE 4/5 then Netscape 4
//--
function getObjArray( name )
{
    var newObjArray;
    if ( typeof name == "string" ) {
        if (document.getElementById) {
			 newObjArray = document.getElementsByName(name);
        }
        else if(document.getElementsByName)
            newObjArray = document.getElementsByName(name);
        else if (document.all)
            newObjArray = document.all[name];
        else if (document.layers)
            newObjArray = document.layers[name];
    }
    else
        newObjArray = name;
    return newObjArray;
}
//++
// cross browser update inner HTML object
// --
function doUpdateHtml(obj,text) {
	if(obj.innerHTML != null)
		obj.innerHTML = text;
	else if(obj.insertAdjacentHTML != null) {
		obj.insertAdjacentHTML("beforeEnd",text);
	}
	else if(document.createElement != null) {
	
	}
}
function doUpdateText(obj,text) {
	if(obj.innerText != null)
		obj.innerText = text;
	else if(obj.innerHTML != null)
		obj.innerHTML = text;
	else if(obj.insertAdjacentHTML != null) {
		obj.insertAdjacentHTML("beforeEnd",text);
	}
	else if(document.createElement != null) {
	}
}
function doGetText(obj) {
	if(obj.innerText != null)
		return obj.innerText;
	else if(obj.innerHTML != null)
		return obj.innerHTML;
}


//++
// cross browser get style object by id or name.
// tries DOM first, then IE 4/5 then Netscape 4
// if forceIEBehavior is true and the getElementById
// fails, routine will try to find a name instead of IE
//--
function getStyle( name, forceIEBehavior )
{
    var myObj = getObj( name, forceIEBehavior );
    return myObj == null ? null : myObj.style;
}

//++
// cross browser routine to hide an element
//--
function hideElement( name )
{
	if ( document.getElementById )
		getStyle( name ).visibility="hidden";
	else if ( document.layers )
		getObj( name ).visibility = "hide";
}

//++
// cross browser routine to show an element
//--
function showElement( name )
{
	if ( document.getElementById )
		getStyle( name ).visibility="visible"
	else if ( document.layers )
		getObj( name ).visibility = "show";
}

//++
// cross browser routine to hide/show an element
//--
function menuElementStatus( name )
{
	if ( document.getElementById ){
		if(getStyle( name ).visibility == "visible")
			return true
		else
			return false
	}else if ( document.layers ){
		if(getObj( name ).visibility == "show")
			return true
		else
			return false
	}
}



/*
 *  Menus and Navigation
 */
var currentlyHovering_Main = false;

function doMenu(pId,pEvt) {
    currentlyHovering = true;

    var pEvent= (window.event) ? window.event : pEvt;
    
    if (window.event)event.cancelBubble=true;
	else if (pEvent.stopPropagation)pEvent.stopPropagation()

    setTimeout('doPopulateCheck('+pId+','+(pEvent.type=="click")+','+(pEvent.type=="mouseover")+')',500);
}

function doPopulateCheck(pId,pblnClickStatus,pblnmouseoverStatus) {

    if (!currentlyHovering_Main){
        doPopulateMenu(pId,pblnClickStatus,pblnmouseoverStatus);
    }
}

function doHideMenus(){
	var objSubMenu;
	for (i=0;i<9;i++) {
		objSubMenu ='menuItem' + i.toString();
		if(getObj(objSubMenu)){
			if (menuElementStatus( objSubMenu ) ){
				hideElement( objSubMenu );
				var navElement = getObj('navItem' + i.toString());
				if (navElement != null) {
						if (navElement.className.indexOf("On") != -1) 
						navElement.className = navElement.className.substring(0, (navElement.className.length-2));
				}
				return;
			}
		}
	}
}

function doPopulateMenu(pId,pblnClickStatus,pblnmouseoverStatus){
        doHideMenus();
        var objMenu = getObj('navItem' + pId);
        var strSubMenu = 'menuItem' + pId;
    
        if (pblnClickStatus==true && (!menuElementStatus( strSubMenu )) || pblnmouseoverStatus==true){
            objMenu.className = objMenu.className + "On";
            showElement( strSubMenu );
        }	
        else if (pblnClickStatus==true){
            if (objMenu.className.indexOf("On") != -1) {
                    objMenu.className = objMenu.className.substring(0, (objMenu.className.length-2));
            }
            hideElement( strSubMenu );
        }
}

function doHideSubMenu(pId){
	var objMId = getObj('navItem' + pId)
	var objSMId = getObj('menuItem' + pId)
	
	if (!currentlyHovering) {
		if (typeof objSMId !="undefined" && objSMId.style.visibility =="visible"){
			if (objMId.className.indexOf("On") != -1) {
				objMId.className = objMId.className.substring(0, (objMId.className.length-2));
				hideElement( 'menuItem' + pId );
				strVal = getObj('selectedMenu').value;
				if(getObj('navItem' +strVal)){
					objNavSelected = getObj('navItem' +strVal);
					if(objNavSelected.className != objNavSelected.clasName+"On")
						objNavSelected.className = objNavSelected.className + "On";
					showElement( 'menuItem'+strVal);
					currentlyHovering = true;
				}
			}
		}
	}
}
/*---------------Start Used for Menu Generation -----------------*/
function doHideMenu(pId) {
	//menu disappear speed onMouseout (in miliseconds)
    currentlyHovering=false;
    setTimeout("doHideCheck("+pId+")",500);
}

function doHideCheck(pId) {
    if (!currentlyHovering){
    	setTimeout("doHideSubMenu("+pId+")",1000);
    }
}

function doPersistHover(pId) {
	currentlyHovering = true;
    currentlyHovering_Main = true;
}

function doNotPersistHover(pId) {
    currentlyHovering_Main = false;
	 //menu disappear speed onMouseout (in miliseconds)
    if (currentlyHovering){
        currentlyHovering = false;
        setTimeout("doHideSubMenu("+pId+")",1500);
    }
}

function setMenu(pId){
	getObj('selectedMenu').value=pId;
}
/*---------------End Used for Menu Generation -----------------*/


/*---------------Start Used for Setting Footer Height()) -----------------*/

//Get highest height and Set Footer height
  function setFooterHeight(){
    //list of outer content DIV ids
    var box = new Array("left","middle","right"); 
    //determine the tallest div
    for(x=0;x<box.length;x++){ 
        h = getObj(box[x]).offsetHeight;
        for(y=0;y<box.length;y++){
            test_h = getObj(box[y]).offsetHeight;
            if(h<test_h){ 
                h = test_h;
            }
        }  
    }
    if(h < 400){
        h=800;
    }
    //set the height of all divs to the tallest
    for(x=0;x<box.length;x++){
        getObj(box[x]).style.height = h +"px"; 
    }
  }
  
/*---------------End Used for Setting Footer Height  -----------------*/


/*---------------Start Used for Button -----------------*/  

function doRollover(elID) {
	var midEl = getObj(elID + "Middle");
	var leftEl = getObj(elID + "Left");
	var rightEl = getObj(elID + "Right");
	
	if (midEl.className.indexOf("Roll") == -1) {
		midEl.className = midEl.className + "Roll";
		leftEl.className = leftEl.className + "Roll";
		rightEl.className = rightEl.className + "Roll";
	}
}

function doRestore(elID) {
	var midEl = getObj(elID + "Middle");
	var leftEl = getObj(elID + "Left");
	var rightEl = getObj(elID + "Right");
	
	if (midEl.className.indexOf("Roll") != -1) {
		midEl.className = midEl.className.substring(0, (midEl.className.length-4));
		leftEl.className = leftEl.className.substring(0, (leftEl.className.length-4));
		rightEl.className = rightEl.className.substring(0, (rightEl.className.length-4));
	}
}

/*---------------End Used for Button  -----------------*/


//---------------------------------------------------------------------------------------------------------------------------------------------------------------------

function leftNavClick(id, numNav) {
	var selNav = document.getElementById("leftNav" + id);
	if (selNav.className == "parent") {
		// close currently selected
		for (var i=0; i<numNav; i++) {
			document.getElementById("leftNav" + i).className = "parent";
			if (document.getElementById("leftNav" + i + "Children") != null) {
				document.getElementById("leftNav" + i + "Children").style.display = "none";
			}
		}
		selNav.className = "parentselected";
		document.getElementById("leftNav" + id + "Children").style.display = "";
	}
	return false;
}

function statusNavClick(id, numTabs, isKF) {
	var elStatusNavPrefix = "statusNav";
	var elStatusBodyPrefix = "statusBody";
	if (isKF != null && isKF == true) {
		elStatusNavPrefix += "KF";
	}
	
	var sNavElement = getObj("statusNav" + id);
	if (sNavElement.className != elStatusNavPrefix + "On") {
		for (var i=0; i<numTabs; i++) {
			getObj("statusNav" + i).className = elStatusNavPrefix + "Off";
			getObj("statusBody" + i).style.display = "none";  // hide body under inactive tabs
		}
		if (id < numTabs-1) {
			sNavElement.className = elStatusNavPrefix + "On";  // active tab
			getObj("statusNav" + (id+1)).className = elStatusNavPrefix + "OffAfterOn";  // set tab left of active to special style
		} else {
			// last element
			sNavElement.className = elStatusNavPrefix + "OnLast";
		}
		getObj(elStatusBodyPrefix + id).style.display = "block";  // show body under active tab
	}
}

function checkboxClick(id) {
	cb = getObj(id);
	if(cb.click != null && cb.click != "undefined")
		cb.click();
		
	cb.checked = !cb.checked;
}

function radioClick(id, val) {
	r = getObj(id);
	if(r.click != null && r.click != "undefined")
		r.click();
		
	r.checked = true;
}

function MM_preloadImages() {
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

/*
 *  Interstitial
 */
function doInterstitialSubmit(formName, msg) {
    // TODO: check for Safari
    if(null != formName)
    {
    	var form = getObj(formName);
    	if(form != null) form.submit();
    	else {
    		alert("Unable to submit form.");
    		return false;
    	}
    }

    
    var bd = getObj('content2col');
    if (null==bd || "undefined"==bd) bd = getObj('content3col');
    if (null==bd || "undefined"==bd) bd = getObj('contentCategory');
    
    var hd = getObj('header');
    var ft = getObj('footer');
    if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("rv:1.7")!=-1) {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    else if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1) {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    // default to IE
    else {
        hd.style.display="none";
        if (null!=bd && "undefined"!=bd){
        	 bd.style.display="none";
       	}
    }
    var subMsg = "";
    //See if any additional arguments were passed in
    if(arguments.length > 2) {
    	subMsg = arguments[2];
    }

    doUpdateText(getObj('interstitialText'),msg);
    doUpdateText(getObj('interstitialSubText'),subMsg);
    getObj('interstitialWindow').style.display = "block";


    return false;
}

/*
 *  Interstitial for popup
 */
function doInterstitialSubmitPopup(formName, msg) {
    // TODO: check for Safari
    if(null != formName)
    {
    	var form = getObj(formName);
    	if(form != null) form.submit();
    	else {
    		alert("Unable to submit form.");
    		return false;
    	}
    }


    var bd = getObj('contentPopup');

    if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1 && navigator.userAgent.toLowerCase().indexOf("rv:1.7")!=-1) {
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    else if (navigator.userAgent.toLowerCase().indexOf("gecko")!=-1) {
        if (null!=bd && "undefined"!=bd) bd.style.display="none";
    }
    // default to IE
    else {
        if (null!=bd && "undefined"!=bd){
        	 bd.style.display="none";
       	}
    }
    var subMsg = "";
    //See if any additional arguments were passed in
    if(arguments.length > 2) {
    	subMsg = arguments[2];
    }

    doUpdateText(getObj('interstitialText'),msg);
    doUpdateText(getObj('interstitialSubText'),subMsg);
    getObj('interstitialWindow').style.display = "block";


    return false;
}


/*Start of Global Corporate purpose script*/
function opencorptravellink(){
//window.open('http://202.40.225.14/OneToOne/ScriptPublisher/ScrptPub.dll?ESPJ=10126&ESPTP=11039&ESPW=SIADB&DisableDSGNCache=1',"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
window.open('http://ctl.singaporeair.com.sg/OneToOne/ScriptPublisher/ScrptPub.dll?ESPJ=10126&ESPTP=11039&ESPW=SIADB&DisableDSGNCache=1',"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
}
/*End of Global Corporate purpose script*/


/*Start of TS KrisShop purpose script*/
function linkToPDF(pdfName,newBrowserInstance){
   window.open(pdfName,"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=700,height=400,top=150,left=100')
}
/*
* Open up a new child window with the designation content
* @param url -- The url of the file you would like to load (REQUIRED)
* @param name -- The name of the window to open, will default to popupWindow if not supplied (OPTIONAL)
* @param height -- The height of the window to open, should only be used if absolutely necessary (OPTIONAL)
* @param width -- The width of the window to open, should only be used if absolutely necessary (OPTIONAL)
*/

function makePopupWindow(url, name,height, width) {
	if (null==name || "undefined"==name) name = "popupWindow";
	if (null==height || "undefined"==height) height = 600;
	if (null==width || "undefined"==width) width = 600;
    var sFullPath = "";
    if(url.indexOf("http://") > -1)
    	sFullPath = url;
    else { //Must be a relative path
        var sProtocol = self.location.protocol;
	    var sHost     = self.location.host;
	    var sPath     = self.location.pathname;
	    var aUrl      = sPath.split("/");
	    //var surl = "http: + // + lapsxd30:8881 + / + saatest/ + en_UK"

	    //Add the context root if not there
	    if(url.indexOf(WEBAPP_CONTEXT) == -1) 
	    	sFullPath = WEBAPP_CONTEXT;
   	    if(url.indexOf(LOCALE_CONTEXT) == -1) 
	    	sFullPath += "/" + LOCALE_CONTEXT;
		sFullPath = sFullPath + url;
    }
    var sUrl = SHOWPOPUPACTIONURL;
    if(sUrl.indexOf("?") > -1)
    	sUrl += "&";
    else
    	sUrl += "?";
    
    sUrl += "method=window&windowUrl=" + sFullPath;
    
 	var winOptions = "toolbar=no,location=yes,directories=no,status=no,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,width=" + width +",height=" + height + ",top=10,left=100";
	window.open(sUrl,name,winOptions);
}
/* Added for using popup actions jspx */
function makeActionPopupWindow(url, name,height, width){
	if (null==name || "undefined"==name) name = "popupWindow";
	if (null==height || "undefined"==height) height = 600;
	if (null==width || "undefined"==width) width = 600;
    var sUrl = SHOWPOPUPACTIONURL;
    
    if(sUrl.indexOf("?") > -1)
    	sUrl += "&";
    else
    	sUrl += "?";
    
    sUrl += "method=window&windowUrl=" + url;
    
 	var winOptions = "toolbar=no,location=yes,directories=no,status=no,menubar=yes,resizable=yes,copyhistory=no,scrollbars=yes,width=" + width +",height=" + height + ",top=10,left=100";
	window.open(sUrl,name,winOptions);
}
/*End of TS KrisShop purpose script*/

function openDisplayETWindow(url){
    var sProtocol = self.location.protocol;
    var sHost     = self.location.host;
    var sPath     = self.location.pathname;
    var aUrl      = sPath.split("/");
    //var surl = "http: + // + lapsxd30:8881 + / + saatest/ + en_UK"
    var sFullPath =sProtocol+"//"+sHost+aUrl[0]+"/"+aUrl[1]+"/"+aUrl[2]+url;
 	var winOptions = "toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=yes,copyhistory=no,scrollbars=yes,width=700,height=300,top=150,left=100";
	window.open(sFullPath,"popupWindow",winOptions);
}
/*Start of Global Open URL script*/
function openURL(url, name,height, width){
window.open(url,"",'toolbar=yes,location=yes,directories=yes,status=yes,menubar=yes,resizable=yes,copyhistory=yes,scrollbars=yes,width=600,height=500,top=150,left=100');
}
/*End of Global Open URL script*/


SetCookieValue('cookieValueCheck','True','','/','','');

function GetCookieValue() {	
	
		var strName = "cookieValueCheck";
		if (document.cookie.indexOf(strName) == -1)
		{
			return false;
		}
		else
		{
		cookieStart = document.cookie.indexOf(strName);
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		}
		if (cookieValue = "True")
		{
			SetCookieValue('cookieValueCheck','false','','/','','');
			return true;
		}
	}
function SetCookieValue(name,value,expires,path,domain,secure)
	{
		var strDNS = GetDNSValue();
	    	document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        	( (path) ? ";path=" + path : "") +
	        //( (domain) ? ";domain=" + domain : "") +
        	( (domain) ? ";domain=" + strDNS : "") +
	        ( (secure) ? ";secure" : "");
		    return true
	}
function GetDNSValue()
	{
		cookieDomain = document.location.hostname;
	}
function GetCookie() {
	//alert("in GetCookie");
		var strName = "MYIMAGE";
		if (document.cookie.indexOf(strName) == -1)
		{
   			return false;
		}
		else
		{
		cookieStart = document.cookie.indexOf(strName);
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		}
		//alert("in GetCookie"+cookieValue);
			return true;

	}


function CheckCookiesEnabled()        
{			//	alert("in CheckCookiesEnabled");
	
	var images = new Array(3);
		images[0] = "first_01.jpg";
		images[1] = "first_02.jpg";
		images[2] = "first_03.jpg";

		if (GetCookie() ){			
		cookieStart = document.cookie.indexOf("MYIMAGE");
		cookieValStart = (document.cookie.indexOf("=", cookieStart) + 1);
		cookieValEnd = document.cookie.indexOf(";", cookieStart);
		if (cookieValEnd == -1)
			{
			cookieValEnd = document.cookie.length;
			}
		cookieValue = document.cookie.substring(cookieValStart, cookieValEnd);
		//alert("cookieValue is "+cookieValue);
		if(cookieValue == images[0])
			{
			//document.getElementById("imagesetup1").className="image2";
			SetCookie('MYIMAGE','first_02.jpg','','/','','');
			}
			if(cookieValue == images[1])
			{
		//	document.getElementById("imagesetup1").className="image3"
			SetCookie('MYIMAGE','first_03.jpg','','/','','');
			}
			if(cookieValue == images[2])
			{
		//	document.getElementById("imagesetup1").className="image1"
			SetCookie('MYIMAGE','first_01.jpg','','/','','');
			}
		
		
		}
		 else {	
			// document.getElementById("imagesetup1").className="image1"
			SetCookie('MYIMAGE','first_01.jpg','','/','','');
   			return false;	
   		}	
		
}  

function SetCookie(name,value,expires,path,domain,secure)
	{
		//alert("in SetCookie");
		var strDNS = GetDNS();
	    	document.cookie = name + "=" +escape(value) +
	        ( (expires) ? ";expires=" + expires.toGMTString() + 1000*60*20 : "") +
        	( (path) ? ";path=" + path : "") +
	        //( (domain) ? ";domain=" + domain : "") +
        	( (domain) ? ";domain=" + strDNS : "") +
	        ( (secure) ? ";secure" : "");
		    return true
	}
function GetDNS()
	{
		cookieDomain = document.location.hostname;
	}	