var changeRet = true; // Added By pol 11/14/2006

function Comma(number) {
   number = numberFilter(number);
   number = '' + number;
   if (number.length > 3) {
   var mod = number.length % 3;
   var output = (mod > 0 ? (number.substring(0,mod)) : '');
   for (i=0 ; i < Math.floor(number.length / 3); i++) {
   if ((mod == 0) && (i == 0))
   output += number.substring(mod+ 3 * i, mod + 3 * i + 3);
   else
   output+= ',' + number.substring(mod + 3 * i, mod + 3 * i + 3);
}
   return (output);
}
   else return number;
}

 function bdate(bdate1) {
     var strmonth = bdate1.Month.value + "";
     var strday = bdate1.Day.value + "";
     var stryear = bdate1.Year.value + "";
     bdate1.BirthDate.value = (strmonth + strday + stryear);
     return true;
 }

//added by ptogle 29 Dec 2004
var monthArr = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];

function getMonthValue(mon) {
   for (var i=0; i<monthArr.length; i++) {
      if (monthArr[i]==mon) {
         return i;
      }
   }
}

function isNumeric(str) {
   if (str.match(/^\d+$/))
      return true;
   else
      return false;
}

function getChosenYear(typ, mon) {
   var frm = document.orbot;
   var firstMonthOnDropDown = 1;
   if (typ.match(/depart/))
      firstMonthOnDropDown = frm.departMonth.options[0].value;
   else
      firstMonthOnDropDown = frm.returnMonth.options[0].value;

   var current = new Date();
   var current_mon = current.getMonth();
   var current_day = current.getDate();
   var current_yr = current.getFullYear();
   chosenYear = current_yr;
   //month is not January and is less than the
   //first month on the dropdown
   //thus, month is after the current year
   if (firstMonthOnDropDown > 1 && mon < firstMonthOnDropDown) {
      chosenYear++;
   }

   return chosenYear;
}

function changeDate(typ) {
   var frm = document.orbot;
   if (typ.toLowerCase()=="depart") {
      //retrieve depart
      var selectedMonthYear = frm.departMonth.value;
      if (!(selectedMonthYear.indexOf(' ')<0)) { //check if Year is available
         var monthYearArr = selectedMonthYear.split(' ');
         var selectedMonth = monthYearArr[0];
         if (isNumeric(selectedMonth)) {
            selectedMonth = monthYearArr[0]/1;
            month = selectedMonth-1;
            year = getChosenYear(typ, selectedMonth);
         } else {
            month = getMonthValue(selectedMonth);
            year = getChosenYear(typ, getMonthValue(selectedMonth)+1);
         }
      } else {
         if (isNumeric(selectedMonthYear)) {
            selectedMonthYear = selectedMonthYear/1; //get the numeric equivalent of the chosen month.
            month = selectedMonthYear-1;
            year = getChosenYear(typ, selectedMonthYear);
         } else {
            month = getMonthValue(selectedMonthYear);
            year = getChosenYear(typ, getMonthValue(selectedMonthYear)+1);
         }
      }
      day = frm.departDay.options[frm.departDay.selectedIndex].text;
   } else {
      //retrieve return
      var selectedMonthYear = frm.returnMonth.value;
      if (!(selectedMonthYear.indexOf(' ')<0)) { //check if Year is available
         var monthYearArr = selectedMonthYear.split(' ');
         var selectedMonth = monthYearArr[0];
         if (isNumeric(selectedMonth)) {
            selectedMonth = monthYearArr[0]/1;
            month = selectedMonth-1;
            year = getChosenYear(typ, selectedMonth);
         } else {
            month = getMonthValue(selectedMonth);
            year = getChosenYear(typ, getMonthValue(selectedMonth)+1);
         }
      } else {
         if (isNumeric(selectedMonthYear)) {
            selectedMonthYear = selectedMonthYear/1; //get the numeric equivalent of the chosen month.
            month = selectedMonthYear-1;
            year = getChosenYear(typ, selectedMonthYear);
         } else {
            month = getMonthValue(selectedMonthYear);
            year = getChosenYear(typ, getMonthValue(selectedMonthYear)+1);
         }
      }
      day = frm.returnDay.options[frm.returnDay.selectedIndex].text;
   }
}
//end of addition

 function newWindow(fieldname) {
     c_today = new Date();
     day = c_today.getDate();
     month = c_today.getMonth();
     year = c_today.getFullYear();
     text_field = fieldname;
     mywindow=open('/asia/en/cal.html','myname','left=370,top=395,titlebar=0,resizable=no,width=205,height=195');
     mywindow.location.href = '/asia/en/cal.html';
     if (mywindow.opener == null) mywindow.opener = self;
     mywindow.focus();
}

function closeWin(){
    window.close();
    return true;
}

function stringFilter (string) {
 sfilter = string;
 filteredValues = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
 var i;
 var returnString = "";
 for (i = 0; i < sfilter.length; i++) {
	var c = sfilter.charAt(i);
	if (filteredValues.indexOf(c) != -1) returnString += c;
 }
 return returnString;
}

function numberFilter (string) {
 sfilter = string;
 filteredValues = "1234567890";
 var i;
 var returnString = "";
 for (i = 0; i < sfilter.length; i++) {
	var c = sfilter.charAt(i);
	if (filteredValues.indexOf(c) != -1) returnString += c;
 }
 return returnString;
}

//opens a popup window
function OpenFullWindow (url,width,height) {
	OpenWin = window.open(url, "CtrlWindow", "location=yes,status=yes,toolbar=yes,directories=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+ width + ",height=" + height + ",left=75,top=75");
}

//opens a popup window
function OpenWindow (url,width,height) {
	OpenWin = window.open(url, "CtrlWindow", "status=no,toolbar=no,directories=no,menubar=no,scrollbars=yes,resizable=yes,width="+ width + ",height=" + height + ",left=75,top=75");
}

//returns HTML for shared header with a different
//image dependent on if the user is logged in
function GetHeaderLogin(location, varLangCode) {
	return GetHeaderLoginForCountry(location, varLangCode, visitordata.country_code);
}
//returns HTML for shared header with a different
//image dependent on if the user is logged in
//given a location, varlangcode, varCountryCode
function GetHeaderLoginForCountry(location, varLangCode, varCountryCode) {
	var SkyMiles = get_cookie("SkyMiles");
	if (SkyMiles != "") { 
		if (location == "HOME") {
			return ('<td><img src="/asia/images/shared/header/topnav_sub_logout_'+varCountryCode+ '_' + varLangCode+ '.gif" border="0" width="465" height="29" usemap="#topnav_sub_logout_map" alt=""></td>'); 
		} else {
			return ('<td><img src="/asia/images/shared/header/topnav_sub_logout_others_' + varLangCode+ '.gif" border="0" width="465" height="29" usemap="#topnav_sub_logout_map" alt=""></td>'); 
		}
	} else {
		if (location == "HOME") {
			return ('<td><img src="/asia/images/shared/header/topnav_sub_login_'+varCountryCode+ '_' + varLangCode+ '.gif" border="0" width="465" height="29" usemap="#topnav_sub_login_map" alt=""></td>'); 
		} else {
			return ('<td><img src="/asia/images/shared/header/topnav_sub_login_others_' + varLangCode+ '.gif" border="0" width="465" height="29" usemap="#topnav_sub_login_map" alt=""></td>'); 
		}
	}
}


function GetWPWelcome(varLangCode) {
	var SkyMiles = get_cookie("SkyMiles");
	if (varLangCode != null) {
		if (varLangCode == "en") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return ('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' available miles'); 
			} else {
				return ('<span class="wplogin-name">Welcome to nwa.com/asia.</span><br>Please <a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=' +varLangCode+'">login</a> to access your SkyMiles account information.'); 
			}
		} else if (varLangCode == "sc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				// return ('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 可使用里程\n'); 
				return('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 可使用里程\n');
			} else {
				return ('<span class="wplogin-name">欢迎浏览美西北中文网站</span><br> <a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=' +varLangCode+'">登录</a>并进入环宇旅程帐号信息'); 
			}
		} else if (varLangCode == "tc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return ('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\n 吏祘纔磃璸购   '+cookie_flds[4]+' 穦<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 羆ノ计\n');
			} else {
				return ('<span class="wplogin-name">舧硑砐nwa.com/asia</span><br>叫<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=' +varLangCode+'">祅</a>琩高眤吏祘纔磃璸购眀め闽癟'); 
			}
		} else if (varLangCode == "kr") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return ('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 啊侩 付老\n');
			} else {
				return ('<span class="wplogin-name">nwa.com/kr规巩阑 券康钦聪促.</span><br>岿靛栖胶 备谅 沥焊甫 犬牢窍矫妨搁 <a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=' +varLangCode+'">肺弊牢</a>窍绞矫坷.'); 
			}
		}
		else {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');	 	
				return ('<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 啊侩 付老\n'); 
			} else {
				return ('<span class="wplogin-name">Welcome to nwa.com/asia.</span><br>Please <a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=' +varLangCode+'">login</a> to access your SkyMiles account information.'); 
			}
		}
	}
}	

//turn the subnav link row on or off by changing background/text
//color and associated arrow image
function SubNavLink(element, mode) {

	if ((document.getElementById) || (document.all)) {

		//defaults
		var arrowImage = element + "Arrow";	
		var bgColor = '#E5E6EF';
		var txtColor = '#233385';
		var arrowImg = 'arrowRightOn';
	
		//reassign background and text colors dependent on mode
		if (mode == 'over') {
			bgColor = '#CC0000';		
			txtColor = '#FFFFFF';
			arrowImg = 'arrowRightOn';
		} else if (mode == 'out') {
			arrowImg = 'arrowRightOff';			
		} else if (mode == 'over-open') {
			arrowImg = 'arrowDownOn';		
			bgColor = '#CC0000';				
			txtColor = '#FFFFFF';									
		} else if (mode == 'out-open') {
			arrowImg = 'arrowDownOff';							
		}
	
		//modern browsers
		if (document.getElementById) {	
		
			var navTxt = document.getElementById(element + "Txt");
			var arrowCell = document.getElementById(element + "ArrowCell");
	
			//change colors, swap image
			document.getElementById(element).style.backgroundColor = bgColor;
			if (arrowCell) { arrowCell.style.backgroundColor = bgColor; }
			if (document.images[arrowImage]) { SwapImage(arrowImage, arrowImg); }		
			if (navTxt) { navTxt.style.color = txtColor; }				
		
		//IE 4	
		} else if (document.all) {
			
			var navTxt = document.all(element + "Txt");
			var arrowCell = document.all(element + "ArrowCell");		
	
			//change colors, swap image
			document.all(element).style.backgroundColor = bgColor;
			if (arrowCell) { arrowCell.style.backgroundColor = bgColor; }
			if (document.images[arrowImage]) { SwapImage(arrowImage, arrowImg); }		
			if (navTxt) { navTxt.style.color = txtColor; }			
		}
	}
}

//replace a given img src with passed reference
function SwapImage(imgDocID,imgObjName) {
 if (document.images) {
		document.images[imgDocID].src = eval(imgObjName + ".src")
 }
}

/* run-time */

/* preload sub nav arrow images */
if (document.images) {
	 var arrowRightOn = new Image(13,14);
	 arrowRightOn.src = "/asia/images/shared/subnav/arrow_right_on.gif";
	 var arrowRightOff = new Image(13,14);
	 arrowRightOff.src = "/asia/images/shared/subnav/arrow_right_off.gif";
	 var arrowDownOn = new Image(13,14);
	 arrowDownOn.src = "/asia/images/shared/subnav/arrow_down_on.gif";
	 var arrowDownOff = new Image(13,14);
	 arrowDownOff.src = "/asia/images/shared/subnav/arrow_down_off.gif";			 
}

function leapto(form) {
	var myindex=form.dest.selectedIndex
	location.href=(form.dest.options[myindex].value);
}

function Cookie(document, name, hours, path, domain, secure)
{
	// All the predefined properties of this object begin with 'N'
	// to distinguish them from other properties which are the values to
	// be stored in the cookie.
    
	name = 'nwa';
	domain = '.nwa.com';
	this.Ndocument = document;
    	this.Nname = name;
    	if (hours)
        	this.Nexpiration = new Date((new Date()).getTime() + hours*3600000);
    	else this.Nexpiration = null;
    	if (path) this.Npath = path; else this.Npath = null;
    	if (domain) this.Ndomain = domain; else this.Ndomain = null;
    	if (secure) this.Nsecure = true; else this.Nsecure = false;
}

// This function is the store() method of the Cookie object
function _Cookie_store()
{
	// First, loop through the properties of the Cookie object and
    	// put together the value of the cookie.  Since cookies use the
    	// equals sign and semicolons as separators, we'll use colons
    	// and ampersands for the individual state variables we store
    	// within a single cookie value.  Note that we escape the value
    	// of each state variable, in case it contains punctuation or other
    	// illegal characters.
    	var cookieval = "";
    	for(var prop in this) {
        	// ignore properties with names that begin with 'N' and also methods
        	if ((prop.charAt(0) == 'N') || ((typeof this[prop]) == 'function'))
            		continue;
        	if (cookieval != "") cookieval += '&';
       		cookieval += prop + ':' + escape(this[prop]);
	}

	// Now that we have the value of the cookie, put together the
    	// complete cookie string, which includes the name, and the various
    	// attributes specified when the Cookie object was created.
    	var cookie = this.Nname + '=' + cookieval;
    	if (this.Nexpiration)
        	cookie += '; expires=' + this.Nexpiration.toGMTString();
    	if (this.Npath) cookie += '; path=' + this.Npath;
    	if (this.Ndomain) cookie += '; domain=' + this.Ndomain;
    	if (this.Nsecure) cookie += '; secure';

    	// Now store the cookie by setting the magic Document.cookie property
    	this.Ndocument.cookie = cookie;
}

	// This function is the load() method of the Cookie object
	function _Cookie_load()
		{
    			// First, get a list of all cookies that pertain to this document.
    			// We do this by reading the magic Document.cookie property
    			var allcookies = this.Ndocument.cookie;
     
			if (allcookies == "") return false;

		  	// Now extract just the named cookie from that list.
    			var start = allcookies.indexOf(this.Nname + '=');
    			if (start == -1) return false;   // cookie not defined for this page.
    			start += this.Nname.length + 1;  // skip name and equals sign.
    			var end = allcookies.indexOf(';', start);
    			if (end == -1) end = allcookies.length;
    			var cookieval = allcookies.substring(start, end);
			// Now that we've extracted the value of the named cookie, we've
    			// got to break that value down into individual state variable
    			// names and values.  The name/value pairs are separated from each
    			// other with ampersands, and the individual names and values are
    			// separated from each other with colons.  We use the split method
    			// to parse everything.
			// THIS CODE WILL NOT WORK WITH IE3.0
   			//var a = cookieval.split('&');
   			var a = ie3split(cookieval,"&");   // break it into array of name/value pairs
   			for(var i=0; i < a.length; i++)        // break each pair into an array
   			{
     				//a[i] = a[i].split(':');    
     				a[i] = ie3split(a[i],":");
   			}
 
			//USE THIS INSTEAD
			// Now that we've parsed the cookie value, set all the names and values
    			// of the state variables in this Cookie object.  Note that we unescape()
    			// the property value, because we called escape() when we stored it.
    			for(var i = 0; i < a.length; i++) {
        			this[a[i][0]] = unescape(a[i][1]);
    			}

		    // We're done, so return the success code
    		return true;
	}

function ie3split(stringtosplit, splitchar)
{
	var orgstring = stringtosplit;
	var ie3splitarray = new Array();
	var j = 0;
	while (orgstring.indexOf(splitchar) != -1)

	{
		ie3splitarray[j] = orgstring.substring(0,orgstring.indexOf(splitchar));
		orgstring=orgstring.substring(orgstring.indexOf(splitchar)+1,orgstring.length);
		j++;
	}
	ie3splitarray[j] = orgstring;
	return ie3splitarray;
}

	// This function is the remove() method of the Cookie object.
	function _Cookie_remove()
	{
    		var cookie;
    		cookie = this.Nname + '=';
    		if (this.Npath) cookie += '; path=' + this.Npath;
    		if (this.Ndomain) cookie += '; domain=' + this.Ndomain;
    		cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';

		this.Ndocument.cookie = cookie;
	}
	
	function nwati(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/talk/index.html";
			}
		}
	}
	
	function bizperks(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/bizperks.html";
			}
		}
		
	}
	
	function Nwapr(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {			
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/travel/nwapr/index.html";
			}
		}
	}
	
	function emailexpress(varLangCode)
	{
		serverName = "https://www.nwa.com";
		if (varLangCode == "sc")
		{
			location.href = serverName + "/prefs/cn/sc/NWAEmail";
		}
		else if (varLangCode == "kr")
		{
			location.href = serverName + "/prefs/kr/kr/NWAEmail";
		}
		else if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} 
			else {
				location.href = serverName + "/prefs/" + visitordata.country_code + "/" + varLangCode + "/NWAEmail";
			}
		}
	}

	function checkin(varLangCode)
	{

		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/checkin/index.html";
			}
		}
	}

	function NwaTimeTable(varLangCode)
	{
		if (visitordata.country_code != null && varLangCode != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/timetable/index.html";
			}
		}
		else
			location.href = serverName + "/alliance/";
	}

	function HomePage(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/home.html";
			}
		}
	}
	
	/*******************************************************
	 * comment on 20061120                                 *
	 *													   *
	function awardRes (varHead, varLangCode, varTail)
	{
		if (visitordata.country_code != null) 
		{
			if (visitordata.country_code == "asia") 
			{
				location.href = serverName + "/asia";
			} 
			else 
			{
				if (varLangCode == "en")
				{	if ((visitordata.country_code == "my" || visitordata.country_code == "id")) 
					{
						location.href = varHead + "/ap/" + varTail;
					}
					else 
					{
						location.href =  varHead + "/" + visitordata.country_code +"/" + varTail;
					}
				}
				else if (varLangCode == "kr" || varLangCode == "sc" || varLangCode == "tc")
				{
					location.href =  varHead + "/" + visitordata.country_code +"/" + varTail;
				}
				else 
				{
					location.href = serverName + "/asia";
				}
			}
		}
		else 
		{
				location.href = serverName + "/asia";
		}
		
	}
	*/	
	
	function awardRes (varHead, varLangCode, varTail)
	{
	var country_code_cap = visitordata.country_code.toUpperCase();
	var lang_code_bkeng = "";
	if (varLangCode == "en"){
		lang_code_bkeng = "en";
	}
	else if (varLangCode == "kr"){
		lang_code_bkeng = "ko";
	}
	else if (varLangCode == "tc" || varLangCode == "sc"){
		lang_code_bkeng = "zh";
	}
	
	if (visitordata.country_code != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			
			if (type == "WWR") { //WWR - Shop for flight
				if ((visitordata.country_code == "my" || visitordata.country_code == "id")) {
					//location.href = "http://www.nwa.com/asia/en/bookingform.html";
					location.href = "http://asiares.nwa.com/?siteCode=AP&lang=en";
				}
				else {
					location.href = "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng;
				}
			}
			else { // ATR - Award Travel Reservations
				//if ((visitordata.country_code == "my" || visitordata.country_code == "id")) {
					//location.href =  "http://www.nwa.com/asia/en/bookingform.html";
				//}
				//else {
				{
					location.href =  "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng + "&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
			}
		}
	}
	else {
			location.href = serverName + "/alliance/";
	}
		
	}
	
	
	
	function localizePage(varLangCode, varPage)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/" + varPage;
			}
		}
	}
	
	function Octopus(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				if (varLangCode == "kr") {
					location.href = serverName + "/kr/kr/travel/octopus/index.html";
				} else {
					location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/travel/octopus/index.html";
				}
			}
		}
	}
	
	
	function gprequest(varLangCode)
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = "https://www.nwa.com/asia";
			} else {
				location.href = "https://www.nwa.com/" + visitordata.country_code + "/" + varLangCode + "/grouprequest/";
			}
		}
	}
	
	function gprequest_agency(varLangCode)
	{/*
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = "http://www.nwa.com/asia";
			} else {
				location.href = "http://www.nwa.com/" + visitordata.country_code + "/" + varLangCode + "/grouprequest/";
			}
		}
		*/
		
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/grouprequest/";
			}
		}
	}
	
	function grouptravel(varLangCode)
	{	
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = "https://www.nwa.com/asia/" + varLangCode + "/grouprequest/group_travel_forms.html";
			}
		}
	}
	
	function meetingtravel(varLangCode)
	{	
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = "https://www.nwa.com/asia/" + varLangCode + "/grouprequest/meeting_travel_forms.html";
			}
		}
	}
	
	function grouptravel_agency(varLangCode)
	{	
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = "https://www.nwa.com/" + visitordata.country_code + "/" + varLangCode + "/group_travel_forms.html?w=1";
			}
		}
	}
	
	function meetingtravel_agency(varLangCode)
	{	
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = "https://www.nwa.com/" + visitordata.country_code + "/" + varLangCode + "/meeting_travel_forms.html?w=1";
			}
		}
	}
	
	
	function AgentGo()
	{
		if (visitordata.country_code != null) {
			if (visitordata.country_code == "asia") {
				location.href = serverName + "/asia";
			} else {
				location.href = "http://agents.nwa.com/" + visitordata.country_code;
			}
		}
	}


function Reservations(type, lang)
{
	// lang : EN_US
	//varLangCode: en, sc, tc, kr
	var country_code_cap = visitordata.country_code.toUpperCase();
	var lang_code_bkeng = "";
	if (lang == "EN_US"){
		lang_code_bkeng = "en";
	}
	else if (lang == "KO"){
		lang_code_bkeng = "ko";
	}
	else if (lang == "ZH_TW" || lang == "ZH_CN"){
		lang_code_bkeng = "zh";
	}
	else if (lang == "JA"){
		lang_code_bkeng = "ja";
	}
	
	if (visitordata.country_code != null) {
		if (visitordata.country_code == "asia" || visitordata.country_code == "") {
			location.href = serverName + "/booknwa";
		} else {			
			if (type == "WWR") { //WWR - Shop for flight
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					location.href = "http://www.nwa.com/asia/en/bookingform.html";
				}
				else {
					location.href = "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng;
				}
			}
			else if (type == "PKC")
			{ // PKC
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					location.href = "http://asiares.nwa.com/?siteCode=AP&lang=en&awardtravelsearch&discountCommand.perkChoiceSelected=true";
				}
				else{
					location.href =  "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng + "&awardtravelsearch&discountCommand.perkChoiceSelected=true";
				}
			}
			else 
			{ // ATR - Award Travel Reservations
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					location.href = "http://asiares.nwa.com/?siteCode=AP&lang=en&searchRequest.worldPerksAwardFlight=on";
				}
				else{
					location.href =  "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng + "&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
			}
			
		}
	}
	else {
			location.href = serverName + "/booknwa";
	}
}

function ReservationsPopup(type, lang)
{
	// lang : EN_US
	//varLangCode: en, sc, tc, kr
	var country_code_cap = visitordata.country_code.toUpperCase();
	var lang_code_bkeng = "";
	if (lang == "EN_US"){
		lang_code_bkeng = "en";
	}
	else if (lang == "KO"){
		lang_code_bkeng = "ko";
	}
	else if (lang == "ZH_TW" || lang == "ZH_CN"){
		lang_code_bkeng = "zh";
	}
	else if (lang == "JA"){
		lang_code_bkeng = "ja";
	}

	var url = "";
	
	if (visitordata.country_code != null) {
		if (visitordata.country_code == "asia" || visitordata.country_code == "") {
			url = serverName + "/booknwa";
		} else {			
			if (type == "WWR") { //WWR - Shop for flight
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					url = "http://www.nwa.com/asia/en/bookingform.html";
				}
				else {
					url = "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng;
				}
			}
			else if (type == "PKC")
			{ // PKC
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					url = "http://asiares.nwa.com/?siteCode=AP&lang=en&awardtravelsearch&discountCommand.perkChoiceSelected=true";
				}
				else{
					url =  "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng + "&awardtravelsearch&discountCommand.perkChoiceSelected=true";
				}
			}
			else 
			{ // ATR - Award Travel Reservations
				if (visitordata.country_code == "my" || visitordata.country_code == "id") {
					url = "http://asiares.nwa.com/?siteCode=AP&lang=en&searchRequest.worldPerksAwardFlight=on";
				}
				else{
					url =  "http://asiares.nwa.com/?siteCode=" + country_code_cap + "&lang=" + lang_code_bkeng + "&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
			}
			
		}
	}
	else {
			url = serverName + "/booknwa";
	}

	OpenFullWindow (url, 800, 600);
}

function Reservations_BKENG(type, varLangCode)
{
	//varLangCode: en, sc, tc, kr
	if (visitordata.country_code != null) {
		
		var countrycode = visitordata.country_code; 
		countrycode = countrycode.toUpperCase()
		
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/booknwa";
		}
		else if ((visitordata.country_code == "my" || visitordata.country_code == "id")) {
		//	location.href = "http://www.nwa.com/asia/en/bookingform.html";
			location.href = "http://asiares.nwa.com/?siteCode=AP&lang=en";
		}
		else {
			if (type =="SFF"){
				if (varLangCode == "en"){
					location.href = "http://asiares.nwa.com/?siteCode="+countrycode+"&lang="+varLangCode;
				}
				else if (varLangCode == "kr"){
					location.href = "http://asiares.nwa.com/?siteCode=KR&lang=ko";
				}
				else if (varLangCode == "sc"){
					location.href = "http://asiares.nwa.com/?siteCode=CN&lang=zh";
				}
				else if (varLangCode == "tc"){
					if (visitordata.country_code == "tw")
					{
						location.href = "http://asiares.nwa.com/?siteCode=TW&lang=zh";
					}
					else {
						location.href = "http://asiares.nwa.com/?siteCode=HK&lang=zh";
					}
				}
			}
			else if (type =="ATR"){
				if (varLangCode == "en"){
					location.href = "http://asiares.nwa.com/?siteCode="+countrycode+"&lang="+varLangCode+"&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
				else if (varLangCode == "kr"){
					location.href = "http://asiares.nwa.com/?siteCode=KR&lang=ko&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
				else if (varLangCode == "sc"){
					location.href = "http://asiares.nwa.com/?siteCode=CN&lang=zh&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
				}
				else if (varLangCode == "tc"){
					if (visitordata.country_code == "tw")
					{
						location.href = "http://asiares.nwa.com/?siteCode=TW&lang=zh&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
					}
					else {
						location.href = "http://asiares.nwa.com/?siteCode=HK&lang=zh&searchRequest.worldPerksAwardFlight=on&searchBy=awardtravelsearch";
					}
				}
			}
		}
	}
	else {
			location.href = serverName + "/booknwa";
	}
}
//end

// functiond added - Raymond 26 AUG 2003
/*
function BookingLinks(type, lang)
{	
	//lang : EN_US
	//varLangCode : en, sc, tc, kr
	if (visitordata.country_code != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			if (type == "Book") {
				if ((visitordata.country_code == "my" || visitordata.country_code == "id")) {
					location.href = "http://www.nwa.com/asia/en/bookingform.html";
				}
				else {
					location.href = "http://book.nwa.com/" + visitordata.country_code + "/booking/asp/availabilityQuery.asp?AWARDS=NO&TYPE=NEW&language=" + lang;
				}
			}		
			else if (type == "WPM") 
				location.href = "http://book.nwa.com/" + visitordata.country_code + "/booking/asp/availabilityQuery.asp?AWARDS=YES&TYPE=NEW&language="+lang;
			
		
			else if (type == "PRF") 			
				location.href = "http://book.nwa.com/" + visitordata.country_code + "/booking/asp/login.asp?afterlogin=3&language="+lang;
		}
	}
	else {
			location.href = serverName + "/alliance/";
	}	
}*/

function ReservationHelp(varLangCode)
{
	if (visitordata.country_code != null && varLangCode != null) {	
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			newin(serverName + "/" + visitordata.country_code + "/" + varLangCode + "/booking/help.html");
		}
	}
}

// function added - Raymond 19 AUG 2003
function fvIsEmpty(inValue) {
// Returns TRUE if inValue is empty, or only contains spaces/newline characters
	re = /^\s*$/;
	return re.test(inValue);
}
/* pol -removed 12132006
function reloadEnableButton(myForm) {
	if (myForm.AWARDS.value == "YES") {
		enableButton(false,myForm);
	} else {
		enableButton(true,myForm);
	}
}
function enableButton(enable,myForm)
{	
	
	//if (typeof document.getElementById('returnMonth') != 'undefined') {	
	//if (typeof document.getElementById('returnMonth')
	if (myForm.returnMonth) {	
		myForm.returnMonth.options.disabled = (!enable);
		myForm.returnDay.options.disabled = (!enable);
		//myForm.classOfService.options.disabled = (!enable); - pol
	}
		
	var obj1 = document.all?document.all.retCalendar:document.getElementById("retCalendar");
	var obj2 = document.all?document.all.multiFgt:document.getElementById("multiFgt");
	
	if (!enable) {

		obj2.onclick = "";
		obj2.href = "javascript:void(0)";
		
		//myForm.returnMonth.disabled = true;
		//myForm.returnDay.disabled = true;
		//myForm.classOfService.disabled = true;
		//myForm.TRIP_TYPE[0].checked = true;
		//myForm.TRIP_TYPE[1].disabled = true;
		
	} else {
		obj2.onclick = "javascript:multiFlight(document.orbot)";
		obj2.href = "javascript:multiFlight(document.orbot)";
	
		if (myForm.returnMonth) {	
			myForm.returnMonth.disabled = false;
			myForm.returnDay.disabled = false;
			//myForm.classOfService.disabled = false;
		}
	
		//myForm.TRIP_TYPE[1].disabled = false;
	}
	
}
*/

               function padout(number) { return (number < 10) ? '0' + number : number; }

               function restart() {
                       text_field1.selectedIndex = day-1;
                       text_field2.selectedIndex = (month - month1 + (12 * (month < month1))) + 0;
                        if (text_field3 != null)
                           text_field3.selectedIndex = text_field2.selectedIndex;
                        mywindow.close();
                }
	
	        function changeReturn(myForm) {
					var myForm2 = document.orbot;
  	                myForm2.returnMonth.selectedIndex = myForm2.departMonth.selectedIndex;
	        }
		
	        function moreOptions(myForm) {	
			/*
	                myForm.action.value="populate";
					checkForm(myForm);
					myForm.SEARCH_TYPE.disabled = true;
			*/
				changeDateFormat(myForm);

				var tripMethodByPrice = document.getElementById('searchMethodByPrice');
				var offsiteValue = document.orbot.offsite;
				offsiteValue.value = false;

				if (document.orbot.siteCode.value != "AP") {
					tripMethodByPrice.value = "schedulesearch";
				}

				//myForm.SEARCH_TYPE.disabled = true;
				myForm.submit();
  	        }
		
		function multiFlight(myForm) {
			/*
			myForm.action.value="populate";	                
	        checkForm(myForm);
			myForm.SEARCH_TYPE.value = "4";
			myForm.RETDATE.disabled=true;	
			*/

			changeDateFormat(myForm);

			var typeRoundTrip = document.getElementById('typeRoundTrip');
			var typeOneWay = document.getElementById('typeOneWay');
			var offsiteValue = document.orbot.offsite;
			offsiteValue.value = false;
			typeRoundTrip.value="multicity";
			//myForm.SEARCH_TYPE.value = "4";
			
			myForm.submit();
		}
		
		function lessOptions(myForm) {
			//checkForm(myForm);

			changeDateFormat(myForm);

			//checkForm2(myForm);
			
			myForm.submit();
		}
/*	
		function DateForm(myForm) {
			// DATE_FORMAT 1: dd/mm/yy
			// DATE_FORMAT 2: yy/mm/dd
			// DATE_FORMAT 3: mm/dd/yy
			var today1 = new Date();
			 curMonth = today1.getMonth() + 1;
			 curDYear  = today1.getFullYear();
			 curRYear  = today1.getFullYear();
			if (myForm.DEPDATE0) {
				if (curMonth > myForm.departMonth.value) {
					curDYear = curDYear + 1;
				}
				if (myForm.DATE_FORMAT.value == "1") {
					myForm.DEPDATE0.value = myForm.departDay.value + "/" + myForm.departMonth.value + "/" + curDYear.toString().substring(2,4);
				} else if (myForm.DATE_FORMAT.value == "2")
				{
					myForm.DEPDATE0.value = curDYear.toString().substring(2,4) + "/" + myForm.departMonth.value + "/" + myForm.departDay.value;
				} else if (myForm.DATE_FORMAT.value == "3")
				{
					myForm.DEPDATE0.value = myForm.departMonth.value + "/" + myForm.departDay.value + "/" + curDYear.toString().substring(2,4);
				} 
			}
			if (myForm.RETDATE) {
				if (curMonth > myForm.returnMonth.value) {
					curRYear = curRYear + 1;
				}
				if (myForm.DATE_FORMAT.value == "1") {
					myForm.RETDATE.value = myForm.returnDay.value + "/" + myForm.returnMonth.value + "/" + curRYear.toString().substring(2,4);
				} else if (myForm.DATE_FORMAT.value == "2")
				{
					myForm.RETDATE.value = curRYear.toString().substring(2,4) + "/" + myForm.returnMonth.value + "/" + myForm.returnDay.value;
				} else if (myForm.DATE_FORMAT.value == "3")
				{
					myForm.RETDATE.value =  myForm.returnMonth.value + "/" + myForm.returnDay.value + "/" + curRYear.toString().substring(2,4) ;
				}
			}
		}

		function checkForm(myForm) {
			//myForm.action.value = "submit";
			//DateForm(myForm);
			for (i=0;i<myForm.length;i++) {
				if (myForm.elements[i].name == "SEARCHON" && myForm.elements[i].type == "radio" && myForm.elements[i].checked) {
					if (myForm.elements[i].value == "awardTravelSearch") {
						myForm.AWARDS.value = "YES";
						myForm.AWARD_LEVEL.value = "261";
						// erase
						myForm.RETDATE.value = "";
						myForm.returnDay.value = "";
						myForm.returnMonth.value = "";
						myForm.FARETYPE.value = "";		
						myForm.RETDATE.disabled=true;
						myForm.returnDay.disabled=true;
						myForm.returnMonth.disabled=true;
						myForm.FARETYPE.value = "ECONOMY";
						//myForm.SEARCH_TYPE.value = "0";
						myForm.SEARCH_TYPE.disabled = true;
						myForm.SEARCHON[0].disabled = true;
						myForm.SEARCHON[1].disabled = true;
						myForm.SEARCHON[2].disabled = true;
					} else {
						myForm.AWARDS.value = "NO";
						//myForm.SEARCHON[1].value = "price";
						myForm.AWARD_LEVEL.value = "";
						myForm.AWARD_LEVEL.disabled=true;
						/*
						if (myForm.classOfService[0].selected) {
							myForm.FARETYPE.value = "BUSINESS"
						} else {
							myForm.FARETYPE.value = "ECONOMY"
						}
						*//*
					}
				}
			}
			
			if (myForm.TRIP_TYPE) {
				if(myForm.TRIP_TYPE[1].checked) {
				// One-way
					myForm.SEARCH_TYPE.value = "0";
					myForm.RETDATE.value = "";
					myForm.returnDay.value = "";
					myForm.returnMonth.value = "";
					myForm.RETDATE.disabled = true;
					myForm.returnDay.disabled = true;
					myForm.returnMonth.disabled = true;
				} else if(myForm.TRIP_TYPE[0].checked) {
					myForm.SEARCH_TYPE.value = "1";
				}
			}			
			
		                if ((myForm.action.value == "populate")/* && (fvIsEmpty(myForm.TO0.value)) *//*) { // - pol
		                	myForm.errorCheck.value="OFF";
		                }
		                else {
		                	myForm.errorCheck.disabled = true;	
		                }
		                	
			//disable non-use value
			myForm.departMonth.disabled = true;
			myForm.departDay.disabled = true;
			myForm.DATE_FORMAT.disabled = true;
			if (myForm.TRIP_TYPE) {
				myForm.TRIP_TYPE.disabled = true;			
				myForm.returnMonth.disabled = true;
				myForm.returnDay.disabled = true;
				//myForm.classOfService.disabled = true;
				myForm.TRIP_TYPE[0].disabled = true;
				myForm.TRIP_TYPE[1].disabled = true;
			}	
			
		}
	*/
function newWindow(location, myForm, fieldname1,fieldname2,fieldname3,evnt) {
   if (myForm.TRIP_TYPE) {
      if (myForm.TRIP_TYPE[1].disabled == true && location == "2") {
         // nothing to do
      } else {
         //if-else block added by ptogle 29 Dec 2004
         if (fieldname1.name.match(/depart/) != null)
            changeDate('depart');
         else
            changeDate('return');
         text_field1 = fieldname1;
         text_field2 = fieldname2;
         text_field3 = fieldname3;
         var properties = "left=" + (evnt.screenX + 20);
         properties += ",top=" + (evnt.screenY + 1);
         properties += ",titlebar=0,resizable=no,width=205,height=195";

         mywindow=open('/asia/en/cal.html','myname',properties);
         mywindow.location.href = '/asia/en/cal.html';

         if (mywindow.opener == null) mywindow.opener = self;
         mywindow.focus();
      }
   }
   else {
      //if-else block added by ptogle 29 Dec 2004
      if (fieldname1.name.match(/depart/) != null)
         changeDate('depart');
      else
         changeDate('return');
      text_field1 = fieldname1;
      text_field2 = fieldname2;
      text_field3 = fieldname3;
      var properties = "left=" + (evnt.screenX + 20);
      properties += ",top=" + (evnt.screenY + 1);
      properties += ",titlebar=0,resizable=no,width=205,height=195";

      mywindow=open('/asia/en/cal.html','myname',properties);
      mywindow.location.href = '/asia/en/cal.html';

      if (mywindow.opener == null) mywindow.opener = self;
      mywindow.focus();
   }
}


//function added - Cyrus 03 Sep 2002
function buyandgiftmiles(varLangCode) {
	if (visitordata.country_code=="jp" && varLangCode=="en") {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=EJP";
	}
	else if (/*visitordata.country_code=="jp" && */varLangCode=="ja") {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=JPN";
	}
	else if (/*(visitordata.country_code=="tw" || visitordata.country_code=="hk") && */varLangCode=="tc") {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=TCH";
	}
	else if (/*visitordata.country_code=="cn" && */varLangCode=="sc") {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=SCH";
	}
	else if (/*visitordata.country_code=="kr" &&*/ varLangCode=="kr") {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=KOR";
	}
	else {
		location.href="https://buymiles.nwa.com/purchase.asp?lang=EAS";
	}
}
//end

      // Added function for checkin prefills
     // function checkinset() {
     //    var SkyMiles = get_cookie("SkyMiles");
     //    if (SkyMiles != "") {
     //       var cookie_flds = SkyMiles.split('&');
     //       document.form0.FirstName.value = cookie_flds[2];
     //       document.form0.LastName.value = cookie_flds[1];
     //       document.form0.WP.value = cookie_flds[0];
     //    }
         // start flyout code
     //    DQM_handleOnload();
     // }

function setform(s) {
  with (document.forms.wpform) {
     document.forms.wpform.action = "https://www.nwa.com/cgi-bin/rres_info.pro";
     WpNum.value = account.value;
     LastName.value = name.value;
     Pin.value=pin.value;
  }
}

function get_WP_display_info(varLangCode) {
	var SkyMiles = get_cookie("SkyMiles");
   	if (varLangCode != null) {
		if (varLangCode == "en") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">SkyMiles</td></tr></table>\n			<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td>\n<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' available miles\n</td>\n</tr>\n<tr>\n<td>&nbsp;</td>\n</tr>\n<tr>\n<td valign="middle" align="center"><a href="https://www.nwa.com/cgi-bin/rres_info.pro?lang=en"><img src="/asia/images/shared/buttons/button_viewreservations.gif" border="0" width="107" height="15" alt="View Reservations"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en"><img src="/asia/images/shared/buttons/button_viewaccount.gif" border="0" width="79" height="15" alt="View Account"></a></td>\n</tr>\n</table>\n');
			}
			return ('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">SkyMiles Login</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td><form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en" name="wpform">SkyMiles Number<br><input type="text" size="8" name="account" maxlength="12" class="inputText"><input type="hidden" name="WpNum" value=""><input type="hidden" name="LastName" value=""><input type="hidden" name="Pin" value=""><input type="hidden" name="lang" value="en"><input type="hidden" name="referer" value="1"><input type="hidden" name="First" value="1"></td>\n<td>Last Name<br><input type="text" size="8" name="name" maxlength="40" class="inputText"></td>\n</tr>\n<tr>\n<td colspan="2" class="pad-no-top">PIN<br><input type="password" size="5" maxlength="4" name="pin"><input type="checkbox" name="save_pin" value="Y" checked /><small>Remember PIN</small>&nbsp;&nbsp;&nbsp;&nbsp;<span class="gtLink">&gt;</span> <a href="https://www.nwa.com/asia/en/skymiles/pinhelp.html">PIN Help</a></td>\n</tr>\n<tr>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewreservations.gif" border="0" width="107" height="15" alt="View Reservations" onClick="setform(this)";></td>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewaccount.gif" border="0" width="79" height="15" alt="View Account"></form></td>\n</tr>\n</table>\n');
		} else if (varLangCode == "sc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">环宇里程优惠计划</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td>\n<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 可使用里程\n</td>\n</tr>\n<tr>\n<td>&nbsp;</td>\n</tr>\n<tr>\n<td valign="middle" align="center"><a href="https://www.nwa.com/cgi-bin/rres_info.pro?lang=sc"><img src="/asia/images/shared/buttons/button_viewreservations_sc.gif" border="0" alt="View Reservations"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=sc"><img src="/asia/images/shared/buttons/button_viewaccount_sc.gif" border="0" alt="View Account"></a></td>\n</tr>\n</table>\n');
			}
			return ('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">环宇里程优惠计划登陆 </td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td><form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=sc" name="wpform">会员号码<br><input type="text" size="8" name="account" maxlength="12" class="inputText"><input type="hidden" name="WpNum" value=""><input type="hidden" name="LastName" value=""><input type="hidden" name="Pin" value=""><input type="hidden" name="lang" value="sc"><input type="hidden" name="referer" value="1"><input type="hidden" name="First" value="1"></td>\n<td>姓<br><input type="text" size="8" name="name" maxlength="40" class="inputText"></td>\n</tr>\n<tr>\n<td colspan="2" class="pad-no-top">密码<br><input type="password" size="5" maxlength="4" name="pin"><input type="checkbox" name="save_pin" value="Y" checked /><small>记住密码</small><span class="gtLink">&gt;</span>&nbsp;&nbsp;<a href="https://www.nwa.com/asia/sc/skymiles/pinhelp.html">密码帮助</a></td>\n</tr>\n<tr>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewreservations_sc.gif" border="0" alt="View Reservations" onClick="setform(this)";></td>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewaccount_sc.gif" border="0" alt="View Account"></form></td>\n</tr>\n</table>\n');
		} else if (varLangCode == "tc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">吏祘纔磃璸购</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td>\n<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\n 吏祘纔磃璸购   '+cookie_flds[4]+' 穦<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 羆ノ计\n</td>\n</tr>\n<tr>\n<td>&nbsp;</td>\n</tr>\n<tr>\n<td valign="middle" align="center"><a href="https://www.nwa.com/cgi-bin/rres_info.pro?lang=tc"><img src="/asia/images/shared/buttons/button_viewreservations_tc.gif" border="0" alt="View Reservations"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=tc"><img src="/asia/images/shared/buttons/button_viewaccount_tc.gif" border="0" alt="View Account"></a></td>\n</tr>\n</table>\n');
			}
			return ('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">祅吏祘纔磃璸购</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td><form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=tc" name="wpform">穦腹絏<br><input type="text" size="8" name="account" maxlength="12" class="inputText"><input type="hidden" name="WpNum" value=""><input type="hidden" name="LastName" value=""><input type="hidden" name="Pin" value=""><input type="hidden" name="referer" value="1"><input type="hidden" name="First" value="1"><input type="hidden" name="lang" value="tc"></td>\n<td>﹎ん璣ゅ<br><input type="text" size="8" name="name" maxlength="40" class="inputText"></td>\n</tr>\n<tr>\n<td colspan="2" class="pad-no-top">醚盞絏<br><input type="password" size="5" maxlength="4" name="pin"><input type="checkbox" name="save_pin" value="Y" checked /><small>癘盞絏</small>&nbsp;&nbsp;&nbsp;&nbsp;<span class="gtLink">&gt;</span> <a href="https://www.nwa.com/asia/tc/skymiles/pinhelp.html">盞絏弧</a></td>\n</tr>\n<tr>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewreservations_tc.gif" border="0" alt="View Reservations" onClick="setform(this)";></td>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewaccount_tc.gif" border="0" alt="View Account"></form></td>\n</tr>\n</table>\n');
		} else if(varLangCode == "kr") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				return('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">岿靛栖胶</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td>\n<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' 啊侩 付老\n</td>\n</tr>\n<tr>\n<td>&nbsp;</td>\n</tr>\n<tr>\n<td valign="middle" align="center"><a href="https://www.nwa.com/cgi-bin/rres_info.pro?lang=kr"><img src="/asia/images/shared/buttons/button_viewreservations_kr.gif" border="0" alt="View Reservations"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=kr"><img src="/asia/images/shared/buttons/button_viewaccount_kr.gif" border="0" alt="View Account"></a></td>\n</tr>\n</table>\n');
			}
			return ('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader">\n<tr>\n<td class="formHeader">岿靛栖胶 锅龋</td>\n</tr>\n</table>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td><form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=kr" name="wpform">岿靛栖胶 锅龋\n<br><input type="text" size="8" name="account" maxlength="12" class="inputText"><input type="hidden" name="WpNum" value=""><input type="hidden" name="LastName" value=""><input type="hidden" name="Pin" value=""><input type="hidden" name="referer" value="1"><input type="hidden" name="First" value="1"><input type="hidden" name="lang" value="kr"></td>\n<td>己<br><input type="text" size="8" name="name" maxlength="40" class="inputText"></td>\n</tr>\n<tr>\n<td colspan="2" class="pad-no-top">PIN<br><input type="password" size="5" maxlength="4" class="inputText-small" name="pin"><input type="checkbox" name="save_pin" value="Y" checked /><small>PIN 历厘</small>&nbsp;&nbsp;<span class="gtLink">&gt;</span><a href="https://www.nwa.com/asia/kr/skymiles/pinhelp.html">PIN 档框富</a></td>\n</tr>\n<tr>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewreservations_kr.gif" border="0" alt="View Reservations" onClick="setform(this)";></td>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewaccount_kr.gif" border="0" alt="View Account"></form></td>\n</tr>\n</table>\n');
		}
	} else {
		if (SkyMiles != "") {
			var cookie_flds = SkyMiles.split('&');
			return('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">SkyMiles</td></tr></table>\n			<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td>\n<span class="wplogin-name">'+cookie_flds[2]+' '+cookie_flds[1]+'</span><br>\nSkyMiles '+cookie_flds[4]+' member<br>\n<img src="/asia/images/shared/bullet_wpmiles.gif" border="0" width="10" height="10" alt="">'+Comma(cookie_flds[6])+' available miles\n</td>\n</tr>\n<tr>\n<td>&nbsp;</td>\n</tr>\n<tr>\n<td valign="middle" align="center"><a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en"><img src="/asia/images/shared/buttons/button_viewaccount.gif" border="0" width="79" height="15" alt="View Account"></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rres_info.pro?lang=en"><img src="/asia/images/shared/buttons/button_viewreservations.gif" border="0" width="107" height="15" alt="View Reservations"></a></td>\n</tr>\n</table>\n');
		}
		return ('<table border="0" width="230" cellpadding="3" cellspacing="0" bgcolor="#B1B4C5" class="formHeader"><tr><td class="formHeader">SkyMiles Login</td></tr></table>\n<img src="/asia/images/shared/spacer_white.gif" border="0" width="230" height="1" alt=""><br>\n<table border="0" width="230" cellpadding="5" cellspacing="0" class="formTable">\n<tr>\n<td><form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en" name="wpform">SkyMiles Number<br><input type="text" size="8" name="account" maxlength="12" class="inputText"><input type="hidden" name="WpNum" value=""><input type="hidden" name="LastName" value=""><input type="hidden" name="Pin" value=""><input type="hidden" name="lang" value="en"><input type="hidden" name="referer" value="1"><input type="hidden" name="First" value="1"></td>\n<td>Last Name<br><input type="text" size="8" name="name" maxlength="40" class="inputText"></td>\n</tr>\n<tr>\n<td colspan="2" class="pad-no-top">PIN<br><input type="password" size="5" maxlength="4" name="pin"><input type="checkbox" name="save_pin" value="Y" checked /><small>Remember PIN</small>&nbsp;&nbsp;&nbsp;&nbsp;<span class="gtLink">&gt;</span> <a href="https://www.nwa.com/asia/en/skymiles/pinhelp.html">PIN Help</a></td>\n</tr>\n<tr>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewreservations.gif" border="0" width="107" height="15" alt="View Reservations" onClick="setform(this)";></td>\n<td align="center"><input type="image" src="/asia/images/shared/buttons/button_viewaccount.gif" border="0" width="79" height="15" alt="View Account"></form></td>\n</tr>\n</table>\n');
	}
}



		
		var stylesheet = "/includes/css/styles.css";
		if (document.layers) { stylesheet = "/includes/css/styles_ns4.css"; }		
		document.write('<link rel="stylesheet" type="text/css" href="' + stylesheet + '" />');	
	


// Function appened on 1/9/2003
function Newsc(varLangCode)
{
	if (visitordata.country_code != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			location.href = "/" + visitordata.country_code + "/" + varLangCode + "/corpinfo/newsc/index.html";
		}
	}
	
}


function NwaNewsc(varLangCode)
{
        if (visitordata.country_code != null) {
	if (visitordata.country_code == "asia") {
		location.href = serverName + "/asia";
	} else {
		location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode +"/corpinfo/newsc/index.html";
	}
        } else {
                location.href = serverName + "/alliance/";
        }
}

function NwaCareer(varLangCode)
{
        if (visitordata.country_code != null && varLangCode != null) {
	if (visitordata.country_code == "asia") {
		location.href = serverName + "/asia";
	} else {
	                location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/corpinfo/career/index.html";
	}
        }
        else
        {
                location.href = serverName + "/alliance/";
        }
        
}

function NwaTimeTable(varLangCode)
{
	if (visitordata.country_code != null && varLangCode != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/timetable/index.html";
		}
	}
	else {
		location.href = serverName + "/alliance/";
	}
}

function NwaWPStayMiles(varLangCode)
{
	if (visitordata.country_code != null && varLangCode != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			location.href = serverName + "/" + visitordata.country_code + "/" + varLangCode + "/offers/wpstaymiles/index.shtml";
		}
	}
	else {
		location.href = serverName + "/alliance/";
	}
}

//2005-06-09 - Airport Self-Service Check-In Kiosks
function selfCheckin(varLangCode)
{
	if (visitordata.country_code != null && varLangCode != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		}	
		else
			location.href = serverName + "/asia/" + varLangCode + "/services/electrav/sckiosk.html";
		
	}
	else {
		location.href = serverName + "/alliance/";
	}
	
}
function newin (url)
{
popWindow = window.open(url,"popWindow","toolbar=no,directories=no,status=no,scrollbars=yes,resizable=no,menubar=no, width=730, height=550")
popWindow.opener = self;
popWindow.focus();
}
// End append

function resCentre(varLangCode)
{
	if (visitordata.country_code != null && varLangCode != null) {
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			if ((visitordata.country_code == "my" || visitordata.country_code == "id")) {
				location.href = "/" + visitordata.country_code + "/" + varLangCode + "/travel/reser/main.html";
			}
			else {
				location.href = "/asia/" + varLangCode +"/travel/reser/main.html";
			}
		}
	}	
}

function NwaCheckin()
{
	if (visitordata.country_code != null)	{
		if (visitordata.country_code == "asia") {
			location.href = serverName + "/asia";
		} else {
			location.href = "http://www.nwa.com/cki-bin/intlcki.pro?loadactivatetrans&LANGUAGE=en_" + visitordata.country_code;
		}
	}
	else {
		location.href = "http://www.nwa.com/cki-bin/intlcki.pro?loadactivatetrans&LANGUAGE=en";
	}
}

//default stylesheet name
var stylesheet = "/includes/css/styles.css";
var serverName = "http://www.nwa.com";

//netscape 4 browsers use a different stylesheet
if (document.layers) {
	stylesheet = "/includes/css/styles_ns4.css";
}

document.write('<link rel="stylesheet" type="text/css" href="' + stylesheet + '" />');		

function select_field(){
	for (i=0; i<total; i++){
		if (cookie_value == cmap[i][1]){
			document.form1.path.selectedIndex=cmap[i][0]-1;
		}
	}
}

new Cookie();
Cookie.prototype.store = _Cookie_store;
Cookie.prototype.load = _Cookie_load;
Cookie.prototype.remove = _Cookie_remove;

var visitordata = new Cookie(document, "nwa", 240, "/");
visitordata.load();
var myURL = self.location.toString();
myURL = myURL.substring(myURL.indexOf(location.host) + location.host.length,myURL.length);
var myCountry = myURL.substring(1, myURL.indexOf("/",1));
var myLang = "";
if (myURL.indexOf("/en/") > -1) {
	myLang = "en";
} else if (myURL.indexOf("/kr/") > -1) {
	myLang = "kr";
} else if (myURL.indexOf("/sc/") > -1) {
	myLang = "sc";
} else if (myURL.indexOf("/tc/") > -1) {
	myLang = "tc";
}

if (myCountry != "cn" && myCountry != "gs" && myCountry != "hk" && myCountry != "id" && myCountry != "jp" && myCountry != "kr" && myCountry != "my" && myCountry != "ph" && myCountry != "sg" && myCountry != "tw" && myCountry != "th") {
	myCountry = "asia";
}

if (visitordata.country_code == null || !visitordata.country_code || (visitordata.country_code != myCountry && myCountry != "asia")) {
	var visitordata = new Cookie(document, "nwa", 240, "/");
	visitordata.country_code = myCountry;
	visitordata.lang_code = myLang;
	visitordata.store();
}

function pnrFilter (string) {
   sfilter = string;
   var i;
   var returnString = "";
   for (i = 0; i < sfilter.length; i++) {
      var c = sfilter.charAt(i);
      if (c == "0") { returnString += "O"; }
      else if (c == "1") { returnString += "I"; }
      else { returnString += c; }
   }
   return returnString;
}

function setCheckInType() {
   var optnum = document.forms.form0.checkInType.selectedIndex;
   var checkInTypeArr=['RL','WP','ET'];
   //var checkInTypeArr=['RL','WP','CC'];
   var checkInType=checkInTypeArr[optnum];
   document.forms.form0.RL.value = "";
   document.forms.form0.ET.value = "";
		if (optnum==0){
			document.getElementById('RL').style.display="inline";
        	document.getElementById('WP').style.display="none";
			document.getElementById('ET').style.display="none";
			document.forms.form0.WP.value = "";
			document.forms.form0.RL.focus();
		}
		else if (optnum==1){
			document.getElementById('WP').style.display="inline";
			document.getElementById('RL').style.display="none";
			document.getElementById('ET').style.display="none";
			document.forms.form0.WP.focus();
		}
		else if (optnum==2){
			document.getElementById('WP').style.display="none";
			document.getElementById('RL').style.display="none";
			document.getElementById('ET').style.display="inline";
			document.forms.form0.WP.value = "";
            document.forms.form0.ET.focus();
		}
}

function checkinset() {
        var SkyMiles = get_cookie("SkyMiles");
        if (SkyMiles != "") {
                var cookie_flds=SkyMiles.split('&');
                document.form0.LastName.value=cookie_flds[1];
                document.form0.WP.value=cookie_flds[0];
//                document.form1.WpNum.value=cookie_flds[0];
//                document.form1.LastName.value=cookie_flds[1];
//                document.form1.Pnr.value='';
        }
        if (document.form0.WP.value == ""){
                document.form0.checkInType.selectedIndex="0";
                document.getElementById('WP').style.display="none";
                document.getElementById('RL').style.display="inline";
                document.getElementById('ET').style.display="none";
        }
        else{
                document.form0.checkInType.selectedIndex="1";
                document.getElementById('WP').style.display="inline";
                document.getElementById('RL').style.display="none";
                document.getElementById('ET').style.display="none";
        }
 // DQM_handleOnload();
}


// Added by pol 
function futureDate(daysOut){
	var today = new Date();
	var todayInMS = today.getTime(); // today in MilliSeconds
	var nextDate = todayInMS + (60 * 60 * 24 * daysOut * 1000);
	return new Date(nextDate);
}
function init() {
	this.today = new Date();
	var departDate = futureDate(7);
	var returnDate = futureDate(14);

	var departDateMonth = departDate.getMonth();
	var departDateDay = departDate.getDate();
	var departDateYear = departDate.getFullYear();

	this.link1 = document.getElementById('dateLink1');
	this.link2 = document.getElementById('dateLink2');

	this.departMonth = document.getElementById('departMonth');
	this.departDay = document.getElementById('departDay');

	this.departMonth.selectedIndex = departDateMonth;
	this.departDay.selectedIndex = departDateDay-1;

	var returnDateMonth = returnDate.getMonth();
	var returnDateDay = returnDate.getDate();
	var returnDateYear = returnDate.getFullYear();

	this.returnMonth = document.getElementById('returnMonth');
	this.returnDay = document.getElementById('returnDay');

	this.returnMonth.selectedIndex = returnDateMonth;
	this.returnDay.selectedIndex = returnDateDay-1;
/*
	cal1 = new YAHOO.widget.Calendar2up("cal1","container1",(departDateMonth+1)+"/"+departDateYear,(departDateMonth+1)+"/"+departDateDay+"/"+departDateYear);
	cal1.title = "Departure date:";
	cal1.setChildFunction("onSelect",setDate1);
	for (var i = 0 ; i < cal1.pages.length; i++){
                                cal1.pages[i].minDate=today;
                                cal1.pages[i].maxDate=futureDate(352);
	}
	cal1.render();
	cal2 = new YAHOO.widget.Calendar2up("cal2","container2",(returnDateMonth+1)+"/"+returnDateYear,(returnDateMonth+1)+"/"+returnDateDay+"/"+returnDateYear);
	cal2.title = "Return date:";
	cal2.setChildFunction("onSelect",setDate2);
	for (var i = 0 ; i < cal2.pages.length; i++){
                                cal2.pages[i].minDate=today;
                                cal2.pages[i].maxDate=futureDate(352);
	}
	cal2.render();
*/
}

function checkForm2(myForm) {

	var tripTypeOneWay = document.getElementById('typeOneWay');
	var tripTypeRoundTrip = document.getElementById('typeRoundTrip');
	var wpFlag = document.getElementById('wpAwardFlag'); // If Price - best available search, If Schedule - regular schedule search
	var tripMethodByPrice = document.getElementById('searchMethodByPrice');
	var tripMethodByPriceSchedule = document.getElementById('searchMethodByPriceSchedule');
/*
	if (tripTypeOneWay.checked) {
		//myForm.SEARCH_TYPE.value = "0";
		//myForm.RETDATE.value = "";
		//myForm.returnDay.value = "";
		//myForm.returnMonth.value = "";
		//myForm.RETDATE.disabled = true;
		myForm.returnDay.disabled = true;
		myForm.returnMonth.disabled = true;
	}

	if (tripMethodByPriceSchedule.checked) {
		tripMethodByPrice.value = "schedsearchwithprice";
		//alert(tripMethodByPrice.value);
		//tripMethodByPriceSchedule.checked = false;
		//tripMethodByPriceSchedule.value = "lowfaresearch";
	}
*/
	return;
}

function wpAwardFlagChange () {
	var typeRoundTrip = document.getElementById('typeRoundTrip');
	var typeOneWay = document.getElementById('typeOneWay');
	var wpAward = document.getElementById('wpAwardFlag');

	typeOneWay.checked = false;
	typeRoundTrip.checked = true;

	if (!wpAward.checked) {
		wpAward.value= "off";
		if (typeOneWay.checked) {
			checkReturnDisable();
		}
	}
	else {
		wpAward.value= "on";
		alert(wpAward.value);
		checkReturnEnable();
	}
	
}


function changeDateFormat(myForm) {
	var siteCode = document.getElementById("siteCode");
	var dMonth = document.getElementById("departMonth");
	var dDay = document.getElementById("departDay");
	var rMonth = document.getElementById("returnMonth");
	var rDay = document.getElementById("returnDay");
	var dDate = document.getElementById("sRdepartDate");
	var rDate = document.getElementById("sRarriveDate");
	
	/*
	 * I will insert a code that will check if it would be 2006 or 2007
	 *	
	 */
	var current = new Date();
	var current_yr = current.getFullYear();
	var current_mon = current.getMonth();

	var dYear = current_yr;
	var rYear = current_yr;

	if (dMonth.options[dMonth.selectedIndex].value < (current_mon + 1)) {
		dYear += 1;
	}
	dYear = dYear.toString();

	if (rMonth.options[rMonth.selectedIndex].value < (current_mon + 1)) {
		rYear += 1;
	}
	rYear = rYear.toString();

	if (siteCode.value == "CN") {
		dDate.value = (dYear.substring(2,4))+"-"+dMonth.value+"-"+dDay.value;
		rDate.value = (rYear.substring(2,4))+"-"+rMonth.value+"-"+rDay.value;
	}
	else if (siteCode == "JP" || siteCode == "KR" || siteCode == "PH" || siteCode == "GS" || siteCode == "TW") {
		dDate.value = dMonth.value+"/"+dDay.value+"/"+(dYear.substring(2,4));
		rDate.value = rMonth.value+"/"+rDay.value+"/"+(rYear.substring(2,4));
	}
	else {
		dDate.value = dDay.value+"/"+dMonth.value+"/"+(dYear.substring(2,4));
		rDate.value = rDay.value+"/"+rMonth.value+"/"+(rYear.substring(2,4));
	}

	/*
	dMonth.value = "";
	dDay.value = "";
	rMonth.value = "";
	rDay.value = "";
	*/

}


function get_WP_display_info_asia(varLangCode) {
	var SkyMiles = get_cookie("SkyMiles");
   	if (varLangCode != null) {
		if (varLangCode == "en") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				var TierLevel = cookie_flds[4];
                if (TierLevel.toLowerCase() == "base") {
		            TierLevel = '';
	            }
   	            var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">SkyMiles </div>';
	            var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                          cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                          '<font class="arial10Bold36363"><br>SkyMiles '+TierLevel+' Member<br>'+Comma(cookie_flds[6])+' Available Miles</font>'+ 
	                          '<a href="/asia/en/skymiles/track/index.html">'+
	                          '<p><img src="/skymiles/images/button_manage_my_account.gif" alt="Manage My Account" border="0"></a>&nbsp;'+     
	                          '&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en"><img src="/skymiles/images/button_view_account.gif" border="0" alt="View Account"></a>'+
	                          '<p><a href="javascript:logout_worldperks_home()">Logout of SkyMiles<span class="gtLink">&gt;</span></a></div> '+
	                          '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                          '</div> ' ; 
                return retval;
			}
	        var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">SkyMiles ';
	        wpheadstart += ' Login</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
	        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
	        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en" name="wpform">'+
		        '<font class="arial12Bold363636">SkyMiles Number</font><br>'+
		        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
		        '<input type="hidden" name="WpNum" value="">' + 
		        '<input type="hidden" name="LastName" value="">' + 
		        '<input type="hidden" name="Pin" value="">' + 
		        '<input type="hidden" name="referer" value="1">' + 
		        '<input type="hidden" name="First" value="1">' + 
		        '<input type="hidden" name="wp_num">' + 
		        '<input type="hidden" name="wp_pin" value="">' + 
		        '<input type="hidden" name="Login" value="">' + 
		        '</div></td>'+
		        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">Last Name<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
		        '</tr></table>'+
			    '<table  class="b0cp0cs0" border="0"><tr>' + 
			    '<td class="pad-no-top" valign="bottom" width="20%"><div class="indent5"><font class="arial12Bold363636">PIN</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
			    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr>Remember PIN</nobr></td>' + 
			    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span><a href="/asia/en/skymiles/pinhelp.html"><nobr>PIN Help</nobr></a></div></td>' + 
      			'<td class="pad-no-top"><input type="image" name="submit" src="/skymiles/images//button_view_account.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' + 
		        '</form>'+
	         	'<table border="0"><tr><td >' + 
		    	'<div width="60%" class="indent5">' + 
			    '<hr width="60%" align="left"><font class="arial12Bold363636">Enroll in SkyMiles</font><br><font class="arial10363636">Begin earning miles that will quickly add up to</font><br><font class="arial10363636">Award Travel</font><br><A href="/asia/en/skymiles/enroll/index.html"></font> <font class="arial10363636">&gt;Enroll Now</a></font></div>'+
		        '</td></tr></table>' + 
		        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
	            return retval;
		} else if (varLangCode == "sc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				var TierLevel = cookie_flds[4];
                if (TierLevel.toLowerCase() == "base") {
		            TierLevel = '';
	            }
   	            var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">我的NWA资料 </div>';
	            var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                          cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                          '<font class="arial10Bold36363"><br>环宇里程优惠计划 '+TierLevel+ '会员<br>'+Comma(cookie_flds[6])+' 可使用里程 </font>'+ 
	                          '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=sc">'+
	                          '<p><img src="/asia/images/shared/buttons/button_manage_my_account_sc.gif" alt="Manage My Account" border="0"></a>&nbsp;'+      
	                          '&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=sc"><img src="/asia/images/shared/buttons/button_viewaccount_sc.gif" border="0" alt="View Account"></a>'+
	                          '<p><span class="gtLink">&gt; </span><a href="javascript:logout_worldperks_home()">退出</a></div> '+
	                          '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                          '</div> ' ; 
                return retval;
            }
	        var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">环宇里程优惠计划会员登录</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
	        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
	        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=sc" name="wpform">'+
		        '<font class="arial12Bold363636">会员号码</font><br>'+
		        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
		        '<input type="hidden" name="WpNum" value="">' + 
		        '<input type="hidden" name="LastName" value="">' + 
		        '<input type="hidden" name="Pin" value="">' + 
		        '<input type="hidden" name="referer" value="1">' + 
		        '<input type="hidden" name="First" value="1">' + 
		        '<input type="hidden" name="wp_num">' + 
		        '<input type="hidden" name="wp_pin" value="">' + 
		        '<input type="hidden" name="Login" value="">' + 
		        '</div></td>'+
		        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">姓<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
		        '</tr></table>'+
			    '<table  class="b0cp0cs0" border="0"><tr>' + 
			    '<td class="pad-no-top" valign="bottom" width="25%"><div class="indent5"><font class="arial12Bold363636">密码</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
			    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr>记住密码</nobr></td>' + 
			    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span> <a href="/asia/sc/skymiles/pinhelp.html "><nobr>密码帮助</nobr></a></div></td>' + 
      			'<td class="pad-no-top"><input type="image" name="submit" src="/asia/images/shared/buttons/button_viewaccount_sc.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' + 
		        '</form>'+
	         	'<table border="0"><tr><td >' + 
		    	'<div width="60%" class="indent5">' + 
			    '<hr width="60%" align="left"><font class="arial12Bold363636">加入“环宇里程优惠计划”</font><br><font class="arial10363636">开始累积里数，兑换奖励旅行。</font><br>&gt; <A href="/asia/sc/skymiles/enroll/index.html"></font> <font class="arial10363636">立即加入</a></font></div>'+
		        '</td></tr></table>' + 
		        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
	            return retval;

		} else if (varLangCode == "tc") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				var TierLevel = cookie_flds[4];
                if (TierLevel.toLowerCase() == "base") {
		            TierLevel = '';
	            }
   	            var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">иNWA戈 </div>';
	            var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                          cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                          '<font class="arial10Bold36363"><br>吏祘纔磃璸购'+TierLevel+'穦<br>'+Comma(cookie_flds[6])+' 羆ノ计</font>'+ 
	                          '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=tc">'+
	                          '<p><img src="/asia/images/shared/buttons/button_manage_my_account_tc.gif" alt="Manage My Account" border="0"></a>&nbsp;'+      	  
					          '&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=tc"><img src="/asia/images/shared/buttons/button_viewaccount_tc.gif" border="0" alt="View Account"></a>'+
	                          '<p><span class="gtLink">&gt; </span><a href="javascript:logout_worldperks_home()">祅</a></div> '+
	                          '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                          '</div> ' ; 
                return retval;
            }
	        var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">祅吏祘纔磃璸购</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
	        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
	        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=tc" name="wpform">'+
		        '<font class="arial12Bold363636">穦腹絏</font><br>'+
		        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
		        '<input type="hidden" name="WpNum" value="">' + 
		        '<input type="hidden" name="LastName" value="">' + 
		        '<input type="hidden" name="Pin" value="">' + 
		        '<input type="hidden" name="referer" value="1">' + 
		        '<input type="hidden" name="First" value="1">' + 
		        '<input type="hidden" name="wp_num">' + 
		        '<input type="hidden" name="wp_pin" value="">' + 
		        '<input type="hidden" name="Login" value="">' + 
		        '</div></td>'+
		        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">﹎ん璣ゅ<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
		        '</tr></table>'+
			    '<table  class="b0cp0cs0" border="0"><tr>' + 
			    '<td class="pad-no-top" valign="bottom" width="25%"><div class="indent5"><font class="arial12Bold363636">醚盞絏</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
			    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr>癘盞絏</nobr></td>' + 
			    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span> <a href="/asia/tc/skymiles/pinhelp.html"><nobr>盞絏弧</nobr></a></div></td>' + 
      			'<td class="pad-no-top"><input type="image" name="submit" src="/asia/images/shared/buttons/button_viewaccount_tc.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' + 
		        '</form>'+
	         	'<table border="0"><tr><td >' + 
		    	'<div width="60%" class="indent5">' + 
			    '<hr width="60%" align="left"><font class="arial12Bold363636">吏祘纔磃璸购</font><br><font class="arial10363636">秨﹍仓縩祘传笴贱纘</font><br>&gt; <A href="/asia/tc/skymiles/enroll/index.html"></font> <font class="arial10363636">ㄨ</a></font></div>'+
		        '</td></tr></table>' + 
		        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
	            return retval;
		} else if(varLangCode == "kr") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				var TierLevel = cookie_flds[4];
                if (TierLevel.toLowerCase() == "base") {
		            TierLevel = '';
	            }
   	            var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">唱狼 NWA 沥焊  </div>';
	            var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                          cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                          '<font class="arial10Bold36363"><br>岿靛栖胶 '+TierLevel+ '雀盔<br>'+Comma(cookie_flds[6])+' 啊侩 付老</font>'+ 
	                          '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=kr">'+
	                          '<p><img src="/asia/images/shared/buttons/button_manage_my_account_kr.gif" alt="Manage My Account" border="0"></a>&nbsp;'+    
	                          '&nbsp;&nbsp;<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=kr"><img src="/asia/images/shared/buttons/button_viewaccount_kr.gif" border="0" alt="View Account"></a>'+
	                          '<p><span class="gtLink">&gt; </span><a href="javascript:logout_worldperks_home()">肺弊酒眶</a></div> '+
	                          '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                          '</div> ' ; 
                return retval;
            }
	        var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">岿靛栖胶 肺弊牢</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
	        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
	        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=kr" name="wpform">'+
		        '<font class="arial12Bold363636">岿靛栖胶 锅龋</font><br>'+
		        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
		        '<input type="hidden" name="WpNum" value="">' + 
		        '<input type="hidden" name="LastName" value="">' + 
		        '<input type="hidden" name="Pin" value="">' + 
		        '<input type="hidden" name="referer" value="1">' + 
		        '<input type="hidden" name="First" value="1">' + 
		        '<input type="hidden" name="wp_num">' + 
		        '<input type="hidden" name="wp_pin" value="">' + 
		        '<input type="hidden" name="Login" value="">' + 
		        '</div></td>'+
		        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">己<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
		        '</tr></table>'+
			    '<table  class="b0cp0cs0" border="0"><tr>' + 
			    '<td class="pad-no-top" valign="bottom" width="40%"><div class="indent5"><font class="arial12Bold363636">PIN</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
			    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr> PIN 历厘</nobr></td>' + 
			    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span> <a href=" https://www.nwa.com/asia/kr/skymiles/pinhelp.html "><nobr> PIN 档框富</nobr></a></div></td>' + 
      			'<td class="pad-no-top"><input type="image" name="submit" src="/asia/images/shared/buttons/button_viewaccount_kr.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' + 
		        '</form>'+
	         	'<table border="0"><tr><td >' + 
		    	'<div width="60%" class="indent5">' + 
			    '<hr width="60%" align="left"><font class="arial12Bold363636">岿靛栖胶 啊涝</font><br><font class="arial10363636">焊呈胶 咯青阑 困茄 付老 利赋阑</font><br><font class="arial10363636">矫累窍技夸. </font><br>&gt; <A href="/asia/kr/skymiles/enroll/index.html"></font> <font class="arial10363636">瘤陛 啊涝</a></font></div>'+
		        '</td></tr></table>' + 
		        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
	            return retval;

		} else if (varLangCode == "jp") {
			if (SkyMiles != "") {
				var cookie_flds = SkyMiles.split('&');
				var TierLevel = cookie_flds[4];
                if (TierLevel.toLowerCase() == "base") {
		            TierLevel = '';
	            }
   	            var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">$B%o!<%k%I%Q!<%/%9(B  </div>';
	            var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                          cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                          '<font class="arial10Bold36363"><br>$B%o!<%k%I%Q!<%/%9(B '+TierLevel+'$B2q0w(B<br>'+Comma(cookie_flds[6])+' $B;HMQ2DG=%^%$%k;D?t(B'+ 
	                          '<a href="/asia/jp/skymiles/direct/index.html">'+
	                          '<p><img src="/asia/jp/skymiles/images/button_manage_my_account.gif" alt="Manage My Account" border="0"></a>&nbsp;&nbsp;'+   
	                          '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=jp"><img src="/asia/jp/skymiles/images/button_view_account.gif" border="0" alt="View Account"></a>'+
	                          '<p><span class="gtLink">&gt; </span><a href="javascript:logout_worldperks_home()">$B%m%0%"%&%H(B</a></div> '+
	                          '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                          '</div> ' ; 
                return retval;
            }
	        var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">$B%o!<%k%I%Q!<%/%9$X$N%m%0%$%s(B</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
	        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
	        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=jp" name="wpform">'+
		        '<font class="arial12Bold363636">$B%o!<%k%I%Q!<%/%9(B<br>$B2q0wHV9f(B</font><br>'+
		        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
		        '<input type="hidden" name="WpNum" value="">' + 
		        '<input type="hidden" name="LastName" value="">' + 
		        '<input type="hidden" name="Pin" value="">' + 
		        '<input type="hidden" name="referer" value="1">' + 
		        '<input type="hidden" name="First" value="1">' + 
		        '<input type="hidden" name="wp_num">' + 
		        '<input type="hidden" name="wp_pin" value="">' + 
		        '<input type="hidden" name="Login" value="">' + 
		        '</div></td>'+
		        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">$B@+(B <br>(Last Name)<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
		        '</tr></table>'+
			    '<table  class="b0cp0cs0" border="0"><tr>' + 
			    '<td class="pad-no-top" valign="bottom" width="20%"><div class="indent5"><font class="arial12Bold363636">PIN</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
			    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr>PIN$B$r(BPC$B$KJ]B8$9$k(B<onnobr></td>' + 
			    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span><a href="http://www.nwa.com/asia/jp/skymiles/pinhelp.html"><nobr>PIN $B$K$D$$$F(B<nobr></a></div></td>' + 
      			'<td class="pad-no-top"><input type="image" name="submit" src="/asia/jp/skymiles/images/button_view_account.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' +
		        '</form>'+
	         	'<table border="0"><tr><td >' + 
		    	'<div width="60%" class="indent5">' + 
		       '<hr width="60%" align="left">' +
                     '<font class="arial12Bold363636">$B%o!<%k%I%Q!<%/%9F~2q?=9~$_(B</font>' +
                     '<br><font class="arial10363636">$B%^%$%k$rCy$a$FFCE5N99T$r$*3Z$7$_$/$@$5$$!*(B</font>' +
                     '<br><A href="/cgi-bin/jp/wp_enroll.pro"><font class="arial10363636">&gt;$BF~2q?=9~$_(B</font></a></div>' +
                       '</td></tr></table>' + 
		        '</td></tr></table>' + 
		        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
	            return retval;
		}	
	} else {
		if (SkyMiles != "") {
			var cookie_flds = SkyMiles.split('&');
			var TierLevel = cookie_flds[4];
               if (TierLevel.toLowerCase() == "base") {
		           TierLevel = '';
	           }
   	           var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">SkyMiles </div>';
	           var retval =  wpheadstart+'</font></div></div> <div class="wpFormLoggedIn" height="100%"><div class="indent5"><font class="arial12Bold363636">'+
	                         cookie_flds[2]+' '+cookie_flds[1]+'</font>'+
	                         '<font class="arial10Bold36363"><br>SkyMiles '+TierLevel+' Member<br>'+Comma(cookie_flds[6])+' Available Miles</font>'+ 
	                     /*  '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en">'+
	                         '<p><img src="/skymiles/images/button_manage_my_account.gif" alt="Manage My Account" border="0"></a>&nbsp;'+  */
	                         '<a href="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en"><img src="/skymiles/images/button_view_account.gif" border="0" alt="View Account"></a>'+
	                         '<p><a href="javascript:logout_worldperks_home()">Logout of SkyMiles<span class="gtLink">&gt;</span></a></div> '+
	                         '<div class="bottom-rightmore"></div><div class="bottom-leftmore"></div> ' +
	                         '</div> ' ; 
               return retval;
		}
	    var wpheadstart = '<div class="wpFormHeader"><div class="wpFormHeaderText"><div class="indent5"><font class="arial14Boldffffff">SkyMiles ';
        wpheadstart += ' Login</font></div></div></div><div class="wpFormNotLoggedIn"><table border="0" class="b0cp0cs0">';
        var retval = wpheadstart +' <tr><td width="50%"><div class="indent5">'+
        	'<form method="post" action="https://www.nwa.com/cgi-bin/rwp_acctsum.pro?lang=en" name="wpform">'+
	        '<font class="arial12Bold363636">SkyMiles Number</font><br>'+
	        '<input type="text" size="8" name="account" maxlength="12" class="inputText" tabindex="40">' +
	        '<input type="hidden" name="WpNum" value="">' + 
	        '<input type="hidden" name="LastName" value="">' + 
	        '<input type="hidden" name="Pin" value="">' + 
	        '<input type="hidden" name="referer" value="1">' + 
	        '<input type="hidden" name="First" value="1">' + 
	        '<input type="hidden" name="wp_num">' + 
	        '<input type="hidden" name="wp_pin" value="">' + 
	        '<input type="hidden" name="Login" value="">' + 
	        '</div></td>'+
	        '<td valign="top" class="pad-no-top" ><font class="arial12Bold363636">Last Name<br></font><input type="text" size="8" name="name" maxlength="40" class="inputText" tabindex="41"></td>' + 
	        '</tr></table>'+
		    '<table  class="b0cp0cs0" border="0"><tr>' + 
		    '<td class="pad-no-top" valign="bottom" width="20%"><div class="indent5"><font class="arial12Bold363636">PIN</font><br><input type="password" size="5" maxlength="4" name="pin" class="inputText-small" tabindex="42"></div></td>' + 
		    '<td valign="bottom"><input type="checkbox" name="save_pin" value="Y" checked /><nobr>Remember PIN</nobr></td>' + 
		    '</tr><tr><td><div class="indent5"><span class="gtLink">&gt;</span><a href="http://www.nwa.com/skymiles/pinhelp.shtml"><nobr>PIN Help</nobr></a></div></td>' + 
   			'<td class="pad-no-top"><input type="image" name="submit" src="/skymiles/images//button_view_account.gif" border="0" alt="View Account" align="right" value="" tabindex="44"></td></tr></table>' + 
	        '</form>'+
         	'<table border="0"><tr><td >' + 
	    	'<div width="60%" class="indent5">' + 
		    '<hr width="60%" align="left"><font class="arial12Bold363636">Enroll in SkyMiles</font><br><font class="arial10363636">Begin earning miles that will quickly add up to</font><br><font class="arial10363636">Award Travel</font><br><A href="/skymiles/enroll"></font> <font class="arial10363636">&gt;Enroll Now</a></font></div>'+
	        '</td></tr></table>' + 
	        '<div class="bottom-right"></div><div class="bottom-left"></div></div></div>';
            return retval;
	}
}



// Reads 'nwa' cookie to get the lang and country code. Then retruns MYNWAInfo URL for the page requested as input.
function getMyNWAInfoURL(pageName) {

    var urlValue = get_cookie('nwa');
    location.href = "/prefs/ap/en/" + pageName;

    if (urlValue) {
        var x = urlValue.split('&');
        var countryCode = "";
        var langCode = "";
        for (var i=0; i < x.length; i++) {

             var y = x[i].split(':');
             if (y.length >= 2) {
                if (y[0] == 'country_code') countryCode = y[1];
                if (y[0] == 'lang_code') langCode = y[1];
             }

        } // End of For Loop

       if (langCode != "" && countryCode != "")
          location.href = "/prefs/" + countryCode + "/" + langCode + "/" + pageName;


    } // End of if (urlValue)

} // End of funtion

// Reads 'nwa' cookie and returns the contact us link for specific country and language
function getContactUsURL() {

    var urlValue = get_cookie('nwa');
    location.href = "/cn/en/talk/contact.html";

    if (urlValue) {
       var x = urlValue.split('&');
       var countryCode = "";
       var langCode = "";
       for (var i=0; i < x.length; i++) {

           var y = x[i].split(':');
           if (y.length >= 2) {
              if (y[0] == 'country_code') countryCode = y[1];
              if (y[0] == 'lang_code') langCode = y[1];
           }

       } // End of For Loop

       if (langCode != "" && countryCode != "") {
          if (langCode == "jp" && countryCode == "jp")
             location.href = "/" + countryCode + "/" + langCode + "/contactus/index.html";
          else
             location.href = "/" + countryCode + "/" + langCode + "/talk/contact.html";
       }

    } // End of if (urlValue)

}  // End of funtion

