
function setCookie2(name, value, expires, path, domain, secure)
{	
    var cookieName = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
    // alert(cookieName);
    document.cookie = cookieName;
}

// not every page includes cookie.js, that's why we need to have getCookie2 function here
function getCookie2(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

// post uri
var postURI = getCookie2('postURICookie');

/*
// client mac
var clientMac = getCookie2('clientMac');

// session cookie
var sessionID = getCookie2('sessionID');

if (!sessionID){
	// create new session id
	var sessionExpireTime = new Date((new Date()).getTime() + 30*60*1000);	// expires after 30 minutes 
	sessionID = clientMac + '-' + sessionExpireTime.getTime();
	
	setCookie2('sessionID',sessionID, sessionExpireTime,'/','.concoursecommunications.com',null);
}

// Add webtrends scripts
var webtrendIncludeScript = document.createElement('script');
webtrendIncludeScript.src = webTrendsInclude + '?cid=' + sessionID + '&hid=' + window.location.hostname + '&pid=' + document.title +'&vid=' + airportCode;
webtrendIncludeScript.type = 'text/javascript';
var head2 = document.getElementsByTagName('HEAD').item(0)
head2.appendChild(webtrendIncludeScript);
// ealert(webtrendIncludeScript.src);
*/

function writeBanner(page,banner){
	document.write('<a href="' + bannerClickThroughPath + '?airport=' + airportCode + '&page=' + page + '&banner=' + banner +'"><img alt="" border="0" src="' + bannerPath + '?airport=' + airportCode + '&page=' + page + '&banner=' + banner + '" style="background-color: #FFFFFF"></a>');
}

function writeHeaderMap(){

	  document.write('<map name="Map">');
	  document.write('<area shape="rect" coords="-1,0,43,27" href="');
	  document.write(postURI);
	  document.write('">');
	  document.write('<area shape="rect" id="priceLink" coords="46,-1,91,25" href="' + rootPath + airportCode + '/price.html">');
	  document.write('<area shape="rect" id="supportLink" coords="93,0,165,27" href="' + rootPath + airportCode + '/support.html">');
	  document.write('</map>');

}

function writeNavLinks(){
	
		// document.write('<a href="' + rootPath + airportCode + '/accountinfo.html" class="bodyGray">My Account</a><br>');
		document.write('<a href="' + nnuSite + '/' + airportCode + '/xregister?postURI=' + postURI + '" class="bodyGray">Sign Up</a><br>');
		document.write('<a href="' + rootPath + airportCode + '/coupon.html" class="bodyGray">Have a Coupon?</a><br>');
		document.write('<a href="' + rootPath + airportCode + '/partners.html" class="bodyGray">Partners</a><br>');
		document.write('<a href="' + rootPath + airportCode + '/map_overview.asp?loccode=' + airportCode + '" class="bodyGray">Hotspot Coverage</a><br>');
		document.write('<a href="' + rootPath + airportCode + '/privacy.html" class="bodyGray">Privacy</a><br>');
		document.write('<a href="' + rootPath + airportCode + '/contact.html" class="bodyGray">Contact Us</a><br>');
}

function writeLargeTitle(){

	document.write(largeTitle);

}

function writeNNUFormHeader(){

	document.write('<form name="login_form" action="' + nnuSite + '/' + airportCode + '/xlogin?postURI=' + postURI + '">');
}

function writeEmailFormHeader(){

	document.write('<form name="remindMe" action="' + rootPathScript + 'sendemail.asp" method="post">');
	document.write('<input type=hidden name=airport value="' + airportCode + '">');
}

function writeSmallTitle(){

	document.write(smallTitle);

}

/*
// pop up pre auth msg when a partner is selected
function popPartnerPreAuthMsg(form){
	
	// alert(typeof(hashPreAuthMsg)); //.get(form.ispSelect.options[form.ispSelect.selectedIndex].value));
	
	// Check if we need to replace the landing page	
	var preAuthMsg = hashPreAuthMsg.get(form.ispSelect.options[form.ispSelect.selectedIndex].value);	
	
	if (typeof(preAuthMsg) != 'undefined' && preAuthMsg != ""){			
		 return confirm(preAuthMsg);
	}
	return true;

}
*/

function popPartnerPreAuthMsg(form){
	
	if (form.ispSelect.options[form.ispSelect.selectedIndex].value == '@t-mobile.us'){
			return confirm("Welcome T-Mobile HotSpot US Subscribers.\n\nA roaming charge of $4.99 for one day of access at this airport will\n be charged to your account.  The roaming access expires 24 hours\n from first login. Questions? Please call T-Mobile HotSpot Customer\nCare at 877.822.SPOT (7768).");
		}
	return true;
}

function appendRealm(form){
	
	if (form.user.value.length == 0 || form.password.value.length == 0 ) return false;	// no user name
	
	if (form.user.value.indexOf(form.ispSelect.options[form.ispSelect.selectedIndex].value) == -1){		
	
		// pop pre auth msg
		var agree=popPartnerPreAuthMsg(form);
		// alert(!agree);
		if (!agree) return false;
		
		// Check if we need to replace the landing page
		/*
		var landingPage = hash.get(form.ispSelect.options[form.ispSelect.selectedIndex].value);
		
		if (typeof(landingPage) != 'undefined' && landingPage != ""){
			// Has re-defined landing page value for the roaming partner			
			//alert(document.login.dst.value);
			document.getElementById("dst").value= landingPage;			
			//alert(document.login.dst.value);
		}
		*/
		if (form.ispSelect.options[form.ispSelect.selectedIndex].value == '@t-mobile.us'){
			form.dst.value= secureRootPath2 + airportCode + "/welcometmobile.html";				
			//alert('tmobile');
		}

		if (form.ispSelect.options[form.ispSelect.selectedIndex].value == "bci/"){
			//alert(form.dst);
			form.dst.value = secureRootPath2 + airportCode + "/welcomesbc.html";				
			//alert('sbc');
		}
		
		// Has suffix realm? (usually start with @
				
		if (form.ispSelect.options[form.ispSelect.selectedIndex].value.indexOf("@") != -1){
			//alert('post');
			form.user.value  = form.user.value + form.ispSelect.options[form.ispSelect.selectedIndex].value;
		}else{
			//alert('pre');
			form.user.value  = form.ispSelect.options[form.ispSelect.selectedIndex].value + form.user.value; 		
		}
	}
	return true;
}

function appendAAURealm(form){
	
	if (form.user.value.indexOf('AAU/') == -1){
		
		form.user.value  = "AAU/" + form.user.value; 		
		
	}

}

function setCode(form){

	form.action = rootPathScript + 'ProcessCoupon.asp?postURI=' + postURI;	
	form.location.value  = airportCode; 		
}

function writeHeaderWithBanner(page){
	header(page);
}


function writeHeader(){	
	header(null);
}
	

function header(page){

	
		document.write('<body>');
		document.write('<table width="760" border="0" align="center" cellpadding="0" cellspacing="0" background="images/topBarBlueBk.gif">');
		document.write('  <tr>');
		document.write('    <td width="16"><img src="images/topBarBlueLeft.gif" width="16" height="38"></td>');
		document.write('    <td width="190">&nbsp;</td>');
		document.write('    <td width="159" valign="top"><img src="images/topnav.gif" width="159" height="28" border="0" usemap="#Map"></td>');
		document.write('    <td width="379">&nbsp;</td>');
		document.write('    <td width="16" align="right"><img src="images/topBarBlueRight.gif" width="16" height="38"></td>');
		document.write('  </tr>');
		document.write('</table>');
		document.write('<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">');
		document.write('  <tr>');
		document.write('    <td rowspan="2"><a href="' + airportLogoLink  + '"><img src="images/logo.gif" width="206" height="88" border="0" align="absmiddle"></a></td>');
		document.write('     <td width="417" height="55" valign="middle"><span class="headerTitleBlue_msp">');

		writeLargeTitle();

		document.write('	</span><br>      </td>');		
		document.write('    <td width="135" rowspan="8" valign="top"><table width="135" border="0" align="left" cellpadding="0" cellspacing="0">');
		document.write('      <tr>');
		document.write('        <td colspan="2"><img src="images/spacer.gif" width="1" height="5"></td>');
		document.write('      </tr>');
		document.write('      <tr>');
		document.write('        <td>&nbsp;</td>');
		if (page != null) {
			document.write('        <td>');
			//document.write('TEST');
			document.write('           <table border="0" cellpadding="0" cellspacing="5">');
			document.write('             <tr height="88">');
			document.write('               <td>');
			writeBanner(page,'FIRST'); 			
			document.write('               </td>');
			document.write('             </tr>');
			document.write('             <tr height="270">');
			document.write('               <td>');
			writeBanner(page,'SECOND');			
			document.write('               </td>');
			document.write('             </tr>');
			document.write('             <tr height="88">');
			document.write('               <td>');			
			writeBanner(page,'THIRD');
			document.write('               </td>');
			document.write('             </tr>');
			document.write('           </table>');
			document.write('        </td>');
		}else{
			document.write('        <td>&nbsp;</td>');	 
		}
		document.write('      </tr>');
		document.write('      <tr>');
		document.write('        <td colspan="2"><img src="' + secureRootPath2 + '/' + airportCode + '/images/' + airportCode + '_spacer.gif" width="1" height="5"></td>');
		document.write('      </tr>');
		document.write('      <tr>');
		document.write('        <td width="8">&nbsp;</td>');
		document.write('        <td>&nbsp;</td>');
		document.write('      </tr>');
		document.write('    </table></td>');
		document.write('  </tr>');
		document.write('  <tr>');
		document.write('    <td height="33" valign="top"><span class="headerTitleGray">');

		writeSmallTitle();

		document.write('	</span></td>');
		document.write('  </tr>');
		document.write('  <tr>');
		document.write('    <td colspan="2"><img src="images/spacer.gif" width="8" height="6" align="absmiddle"></td>');
		document.write('  </tr>');
		/*
		document.write('  <tr>');
		document.write('    <td colspan="2"><span class="headerSmallGrayDark"><img src="images/spacer.gif" width="8" height="22" align="absmiddle"></span></td>');
		document.write('  </tr>');	
		document.write('  <tr>');
		document.write('    <td colspan="2"><img src="images/spacer.gif" width="8" height="6" align="absmiddle"></td>');
		document.write('  </tr>');
		*/

}

function writeFooter(){

	document.write('<tr>');
	document.write('    <td colspan="2"><table width="100%" height="20"  border="0" cellpadding="0" cellspacing="0">');
	document.write('      <tr>');
	document.write('        <td height="20"><img src="images/horizDotsRow.gif" width="623" height="20"></td>');
	document.write('      </tr>');
	document.write('    </table></td>');
	document.write('  </tr>');
	document.write('  <tr>');
	document.write('    <td colspan="2" align="left" valign="top"><table width="100%" height="155"  border="0" cellpadding="0" cellspacing="0">');
	document.write('      <tr>');
	document.write('        <td width="10" rowspan="3">&nbsp;</td>');
	document.write('        <td height="60" valign="top"><a href="http://www.concoursecommunications.com/pv_passengers.html" target="_blank"><img src="images/poweredBy.gif" width="105" height="60" border="0" align="top"></a></td>');
	document.write('        <td width="10" rowspan="3">&nbsp;</td>');
	document.write('        <td width="10" rowspan="3">&nbsp;</td>');
	document.write('        <td width="191" rowspan="3" valign="top"><span class="bodyOrangeStrong">Free Sites!</span>');

	writeFreeLinks();

	document.write('		</td>');
	document.write('        <td width="10" rowspan="3">&nbsp;</td>');
	document.write('        <td width="10" rowspan="3">&nbsp;</td>');
	document.write('        <td width="191" rowspan="3" valign="top">');

	writeNavLinks();

	document.write('		</td>');
	document.write('      </tr>');
	document.write('      <tr>');
	document.write('        <td height="35" valign="top" class="copyright">&copy;2004 Concourse Communications Group, LLC &bull; All Rights Reserved</td>');
	document.write('      </tr>');
	document.write('      <tr>');
	document.write('        <td height="60" valign="middle">&nbsp;</td>');
	document.write('      </tr>');
	document.write('    </table></td>');
	document.write('  </tr>');
	document.write('</table>');

	writeHeaderMap();

	document.write('</body>');

}

function writeSingleSession(){

	document.write('<tr>');
	document.write('    <td colspan="2" valign="top"><table width="623" height="217" border="0" align="center" cellpadding="0" cellspacing="0">');
	document.write('      <tr>');
	document.write('        <td width="201" align="left" valign="top"><table width="301" height="217" border="0" align="left" cellpadding="0" cellspacing="0" bgcolor="#FFFFCC">');
	document.write('          <tr>');
	document.write('            <td colspan="2"><img src="images/spacer.gif" width="1" height="10"></td>');
	document.write('          </tr>');
	document.write('          <tr>');
	document.write('            <td><img src="images/spacer.gif" width="1" height="1"></td>');
	document.write('            <td  valign="top"><img src="images/singleSessionUsers.gif" height="39"></td>');
	document.write('          </tr>');
	document.write('          <tr>');
	document.write('            <td width="10" height="133" rowspan="3">&nbsp;</td>');
	document.write('            <td height="40" valign="bottom" class="bodyBlack">I\'d like to sign on for a ');
	document.write('          one-time <br>session <a href="' + rootPath + airportCode + '/price.html" class="bodyOrangeLink">@ $6.95</a></td>');
	document.write('          </tr>');
	document.write('          <tr>');
	document.write('            <td height="31" valign="middle"><a href="' + nnuSite + '/' + airportCode + '/xregister?postURI=' + postURI + '"  onclick="surveyPopup();"><img src="images/signon_orange.gif" alt="Single Session Users Sign On" name="signOn" width="60" height="19" border="0" align="top" id="signOn"></a></td>');
	document.write('          </tr>');


}

function writeRedirectXML(){

	document.write('<!--');
	document.write('<?xml version="1.0" encoding="UTF-8"?>');
	document.write('<WISPAccessGatewayParam');
	document.write('  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"');
	document.write('  xsi:noNamespaceSchemaLocation="http://www.acmewisp.com/WISPAccessGatewayParam.xsd">');
	document.write('  <Redirect>');
	document.write('    <AccessProcedure>1.0</AccessProcedure>');
	document.write('    <AccessLocation>12</AccessLocation>');
	document.write('    <LocationName>');
	document.write(smallTitle);
	document.write('    </LocationName>');
	document.write('    <LoginURL>%link-login%</LoginURL>');
	document.write('    <MessageType>100</MessageType>');
	document.write('    <ResponseCode>0</ResponseCode>');
	document.write('  </Redirect>');
	document.write('</WISPAccessGatewayParam>');
	document.write('-->');

}


// Parse query string
function PageQuery(q) {
	if(q.length > 1) this.q = q.substring(1, q.length);
	else this.q = null;
	this.keyValuePairs = new Array();
	if(q) {
		for(var i=0; i < this.q.split("&").length; i++) {
			this.keyValuePairs[i] = this.q.split("&")[i];
		}
	}
	
	this.getKeyValuePairs = function() { return this.keyValuePairs; }
	this.getValue = function(s) {
		for(var j=0; j < this.keyValuePairs.length; j++) {
			if(this.keyValuePairs[j].split("=")[0] == s)
				return this.keyValuePairs[j].split("=")[1];
		}
		return false;
	}
	this.getParameters = function() {
		var a = new Array(this.getLength());
		for(var j=0; j < this.keyValuePairs.length; j++) {
			a[j] = this.keyValuePairs[j].split("=")[0];
		}
		return a;
	}
	this.getLength = function() { return this.keyValuePairs.length; } 
}

function queryString(key){
	var page = new PageQuery(window.location.search); 
	return unescape(page.getValue(key)); 
}

function writeDestination(){

	document.write('<input type="hidden" name="dst" value="' + queryString("dst") + '">');
}

