/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/*************************

* This variable is not for fade effect
* This is the path to the external server, where the login and the related pages are placed

**********************/

//
var baseURL="http://www.onezone.ca/wifi/";
var websiteURL="http://www.onezone.ca/wifi/";
var regURL="https://register.prontonetworks.com/registration/Main.jsp?";

var portalURL="https://register.prontonetworks.com";


//Ranga added
 var portalPage="";

//

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
function formCheck(){
if(!document.forms[0].userId.value){
alert("Please enter your USERNAME to log in.");
document.forms[0].userId.focus();
return false;
}
if(!document.forms[0].password.value){
alert("Please enter your PASSWORD to log in.");
document.forms[0].password.focus();
return false;
}
return true;
}
var error1="Sorry, this account already logged in.<br>Please try again after few minutes.";
var error2="You are already logged into another terminal.";
var error3="This service is not supported under current license agreement.";
var error4="Sorry, Credit Card Authorization failed.<br>Please use different credit card.";
var error5="Sorry, there was an error. <br>Unable to process your request at this moment.<br>Please try again later.";
var error6="Sorry, that CARD/PIN number was not accepted<br>or it is expired";
var error7="Sorry, that account has no subscription or prepaid plans.<br>You need to renew your account by purchasing a new plan."; 
var error8="Sorry, that user account is either suspended or cancelled.<br>Please contact customer support.";
var error9="Sorry, that account cannot be allowed at this location.";
var error10="Sorry, that account does not exist..<br>Please sign up for new account";
var error11="Sorry, that password was not accepted.<br>Please try again."
var error12="Sorry, this WISP is not enabled for Premium SMS based authentication."
var error13="Sorry, this WISP is not enabled for Premium USB key based authentication."
var error14="Sorry, that service plan is only permitted to access the internet via the device in which it was registered on"
var error15="Sorry, you are not allowed to use this device";
var error16="Sorry, this location is not enabled for Premium SMS based authentication.";
var error17="Sorry, that user account has been cancelled. <br />Please setup new account";
var error18="Sorry, that user account has been suspended.<br>Please contact customer support.";
var error19="Sorry, the previous posting was failed.<br>Please contact customer support.";
var error20="Sorry, please enter valid CARD Number and PIN Number.";
var error21="Sorry, your 1 hour preview has expired, please select a new plan from the registration link below.";
var error22="Sorry, authentication failed due to Internal Error. Please contact customer support.";
var error23="Sorry, please check the information provided and login again. Please contact customer support if problem persist.";
var error24="Sorry, not all information provided for login. Please enter the required information and login again. Please contact customer support if problem persist.";
var error25="Sorry, please check your username and password and try again.";
var error26="Sorry, Username/password is missing. Please provide and try again.";
var error27="Sorry, there is some problem in registering. Please try again later.";
var error28="Sorry, no prepaid card is available for this WISP. Please contact customer support.";
var error29="Sorry, no realm details found.<br>Please contact customer support.";
var error30="Sorry, no Service Level Agreements(SLA) found. Please contact customer support.";
var error31="Sorry, no matching WISP found for this domain.<br>Please contact customer support.";
var error32="Sorry, Roaming is not enabled.";
var error33="Sorry, that CARD and PIN number has been cancelled.";
var error34="Sorry, purchase not completed. The Billing Server cannot be reached. Please try again later";
var error35="Sorry, realm Plan is not present. Kindly contact Customer Care.";
var error36="Sorry, the current plan associated to your account does not have permission to be used at this location. Please buy and/or use a prepaid plan that has permission to be used at this location.";
var error37="There is no active plan associated to your Access credentials. Please buy and/or use a prepaid plan that has permission to be used at this location.";
var error38="Password is required.";
function SearchStringSplitter()
{
   var nameValue = new Array();
   var searchStr = unescape(location.search.substring(1));
   if (searchStr)
   {
       var formElement = searchStr.split("&");

       var tmpArray = new Array();
       for (k = 0; k < formElement.length; k++) {
            tmpArray = formElement[k].split("=");
            nameValue[tmpArray[0]] = tmpArray[1];
       }
   }
   return nameValue;
}
var srchData 	= SearchStringSplitter();
var wisp_id 	= srchData.wispId;
var nas_id 		= srchData.nasId;
var new_Reg		= srchData.newReg;
var free_Plan   = srchData.freePlan;
//Retreving the error value from "ProntoAuthentication_error.html"
var error_code 	= srchData.errorCode;
var session_id= srchData.sessionId;
var redirect_UserId=srchData.redirectUserId;
var redirect_Password=srchData.redirectPassword;
var auto_Submit=srchData.autoSubmit;
var plan_ExpMsg=srchData.planExpMsg;
var pronto_txn_id=srchData.cm;
var pg_txn_id=srchData.tx;
var pg_txn_st=srchData.st;



/*TEST DATA --- TO BE DELETED*/
/*wisp_id='5338';
nas_id='00:1b:24:78:ab:82';
new_Reg='Y';*/
/********************************/

var newUser  = baseURL+"newuser.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var buyTime = baseURL+"buytime.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var myAccount = baseURL+"myaccount.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg=N";
var homeLink = baseURL+"wifi_login.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var successPage = baseURL+"wifi_checkaccount.html?wispId="+wisp_id+"&sessionId="+session_id+"&nasId="+nas_id+"&newReg="+new_Reg; 

var price=baseURL+"pricing.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var faq=baseURL+"faqs.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var customer=baseURL+"customersupport.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var link=baseURL+"links.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var media=baseURL+"mediacenter.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var medianr=baseURL+"media_newsrelease.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var mediaqa=baseURL+"media_QA.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var mediapho=baseURL+"media_photography.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var mediacm=baseURL+"media_coveragemap.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var mediatec=baseURL+"media_techpack.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var mediabrol=baseURL+"media_broll.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var privacy=baseURL+"privacypolicy.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
var howto=baseURL+"how_to.html?wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;

function openLink(type)
{
	switch(type){
		case "nu":{
			window.location.href =newUser;
			break;
		}
		case "bt":{
			window.location.href =buyTime;
			break;
		}
		case "ma":{
			window.location.href =myAccount;
			break;
		}
		case "home":{
			window.location.href =homeLink;
			break;
		}
		case "sp":{
			window.location.href =successPage;
			break;
		}
		case "price":{
			window.location.href =price;
			break;
		}
		case "faq":{
			window.location.href =faq;
			break;
		}
		case "customer":{
			window.location.href =customer;
			break;
		}
		case "link":{
			window.location.href =link;
			break;
		}
		case "media":{
			window.location.href =media;
			break;
		}
		case "medianr":{
			window.location.href =medianr;
			break;
		}
		case "mediaqa":{
			window.location.href =mediaqa;
			break;
		}
		case "mediapho":{
			window.location.href =mediapho;
			break;
		}
		case "mediacm":{
			window.location.href =mediacm;
			break;
		}
		case "mediatec":{
			window.location.href =mediatec;
			break;
		}case "mediabrol":{
			window.location.href =mediabrol;
			break;
		}
		case "privacy":{
			window.location.href =privacy;
			break;
		}case "howto":{
			window.location.href =howto;
			break;
		}

	}
	
}

	MyImages=new Array();
    MyImages[0]='images/top1.jpg';
    MyImages[1]='images/Homebanner_2.jpg';

function displayMsg(flag){
	var authtype=document.forms[0].serviceName.value;
	switch(authtype){
		case "ProntoAuthentication":{
			document.getElementById('authtype').innerHTML = "ONE ZONE LOGIN";
			document.getElementById('msg').innerHTML = "";
			if(navigator.appName=="Netscape" && flag==2){
				window.location.reload();break;
			}
			break;
		}
		case "BoingoAuthentication":{
			document.getElementById('authtype').innerHTML = "BOINGO LOGIN";
			document.getElementById('msg').innerHTML = "You can either login here or you can use your <b>Boingo dialer client</b>.";
			if(navigator.appName=="Netscape" && flag==2){
				window.location.reload();break;
			}
			break;
		}
		case "IPassAuthentication":{
			document.getElementById('authtype').innerHTML = "IPASS LOGIN";
			document.getElementById('msg').innerHTML = "You can either login here or you can use your <b>IPass dialer client</b>.";
			if(navigator.appName=="Netscape" && flag==2){
				window.location.reload();break;
			}
			break;
		}
	}
	
}    
function displayMsg1(){
	if(navigator.appName=="Netscape"){
				window.location.reload();
	}
	
}   
function newImage() 
{
        document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)]);		

}
function onloadNewIFrm(){
   //window.parent.alert(portalPage);
   document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)])
   if(portalPage!="registration")
	{
	   document.getElementById("iframeId").src = regURL+"wispId="+wisp_id+"&nasId="+nas_id+"&newReg="+new_Reg;
	}
}
function onloadMyaccountIFrm(){
   
   document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)])
   if(portalPage!="registration")
   {
	 document.getElementById("iframeId").src = regURL+"wispId="+wisp_id+"&nasId="+nas_id;
   }
}
function onloadcheckAccountIFrm(){
   document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)])
   document.getElementById("iframeId").src = regURL+"wispId="+wisp_id+"&nasId="+nas_id+"&sessionId="+session_id;
  }

 var redirect_UserId=srchData.redirectUserId;
var redirect_Password=srchData.redirectPassword;
var auto_Submit=srchData.autoSubmit;
var plan_ExpMsg=srchData.planExpMsg;
var pronto_txn_id=srchData.cm;
var pg_txn_id=srchData.tx;
var pg_txn_st=srchData.st;

 
 function onloadBuyPlanIFrm(){
   document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)])
   document.getElementById("iframeId").src = regURL+"wispId="+wisp_id+"&nasId="+nas_id+"&redirectUserId="+redirect_UserId+"&redirectPassword="+redirect_Password+"&autoSubmit="+auto_Submit+"&planExpMsg="+plan_ExpMsg;
}

function onloadSuccessPayPal(){
   document.getElementById("mainImage").setAttribute("src", MyImages[Math.round(Math.random()*1)])
   document.getElementById("iframeId").src = portalURL+"/registration/IntermediateRespPmntGateway.jsp?cm="+pronto_txn_id+"&tx="+pg_txn_id+"&st="+pg_txn_st+"";


}


/******************************************************************************/

//function that performs all functions, defined in the onsubmit event handler

function check(){
	
	strName = document.customersupport.name.value;
	strPoP=document.customersupport.pointofpurchase.value
	strEmail = document.customersupport.email.value;
	 if (strName == "" || strName == null || strName.charAt(0) == ' ')
    {
    alert("\"Name\" is a mandatory field.\nPlease retry.")
	document.customersupport.name.focus();
    return false;
    }
	if (strPoP == "" || strPoP == null || strPoP.charAt(0) == ' ')
    {
    alert("\"Point of purchase field. \" is a mandatory field.\nPlease retry.")
	document.customersupport.pointofpurchase.focus();
    return false;
    }
	 if (document.customersupport.servpack.selectedIndex == 0)
    {
    alert("\"Select a package\" \nPlease retry.")
	document.customersupport.servpack.focus();
    return false;
    }
	 if (strEmail == "" || strEmail == null || strEmail.charAt(0) == ' ')
    {
    alert("\"Email\" is a mandatory field.\nPlease retry.")
	document.customersupport.email.focus();
    return false;
    }else{
		if(!isValidEmail()){
			document.customersupport.email.focus();
			return false;
		}
	}
   
	return true;
	
}

function openSelf(urlVal){
	var winName = window.open(urlVal,"MYACCOUNT")
	//location.href= urlVal;
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function isValidEmail(strEmail){
  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
  strEmail = document.customersupport.email.value;
   // search email text for regular exp matches
    if (strEmail.search(validRegExp) == -1) 
   {
        alert('A valid e-mail address is required.\nPlease and retry');
                document.customersupport.email.focus();                
                return false;
        }
    return true; 
}

