//////alert ('Inside the PCNow us SignUp-driver.js ');
//SignUpStep1
var freeTrialDays = 30;
var timeZoneEdit = ''; //Used in Update
var CCNumber = '';
var termId = '';
var renewalId = '';
var offerDesc = '';

var applicationName = 'NOW';
var locale = '';
var theme = '';
var serviceType = '';
var channelId = '';
var createAccountFirstName = '';
var createAccountLastName = '';
var createAccountEmailaddress = '';
var createAccountPassword = '';
var createAccountConfirmPassword = '';
var createAccountCompanyName = '';
var createAccountCompanySize = '';
var createAccountLocation = '';
//SignUpStep2
var accountFirstName = '';
var accountLastName = '';
var accountEmailAddress = '';
var accountPassword = '';
var accountConfirmPassword = '';
var accountCompanyName = '';
var accountCompanySize = '';
var accountLocation = '';
var accountBilladdress = '';
var accountCity = '';
var accountState = '';
var accountZipcode = '';
var accountCountry = '';
var accountTelephone = '';
var accountCreditCard = '';
var accountCreditCardNumber = '';
var accountExpirationMonth = '';
var accountExpirationYear = '';
var accountSecurityCode = '';
var optInFlag = '';
//SemiUser
var wbxSemiUser = 'false';
var brmProcessUpdateError = 'false';
var account_semiuser_accountid = '0';
//
var prePayTerm = "Annually";
var price ="708";
var tabaName = "Step1";
var tabbName = "Step2";
var tabcName = "Step3";
var tabdName = "Step4";
// Declare these in variable scope to be used in functions
var step,taba,tabb,tabc,tabd,numSteps,contenta,contentb,contentc,contentd,button;
var arrError = new Array(51);
//SignUp Step1 Error Message
arrError[0] = "<li>Please enter site name.";
arrError[1] = "<li>Enter your email address. ";
arrError[2] = "<li>Please re-enter email address.";
arrError[3] = "<li>Please create your WebEx Meetings Plus password.";
arrError[4] = "<li>Please re-type your password.";
arrError[5] = "<li>Invalid email format - Only numbers, letters, @, and . are allowed. Length 7-64 (example: 123test@webex.com).";
arrError[6] = "<li>Please enter a valid password.";
arrError[7] = "<li>Your emails do not match. Please re-enter email address.";
arrError[8] = "<li>The password confirmation does not match your password. Please re-enter.";
arrError[9] = "<li>Please check the site availability."; //Amitabha:TO Be removed after NPK Confirms
arrError[10] = "<li>Enter your first name.";
arrError[11] = "<li>Enter your last name.";
arrError[12] = "<li>Enter your email address.";
arrError[13] = "<li>Enter a password.";
arrError[14] = "<li>Confirm your password.";
arrError[15] = "<li>Enter your CompanyName."; //Amitabha:Its not Mandatory in NOW TO Be removed
//SignUp Step2 Error Message
arrError[16] = "<li>Enter the billing address for this credit card.";
arrError[17] = "<li>Enter the billing city for this credit card.";
arrError[18] = "<li>Enter the billing state for this credit card.";
arrError[19] = "<li>Enter the billing zip or postal code for this credit card.";
arrError[20] = "<li>Enter your area code and phone number.";
arrError[21] = "<li>Enter the credit card number.";
arrError[22] = "<li>Enter a valid expiration year.";
arrError[23] = "<li>CID (credit card validation number) is required. Please Enter CID. ";
arrError[24] = "<li>Please enter your company name.";//Amitabha:Duplicate Entries:To Be removed
arrError[25] = "<li>Please re-enter your site name without spaces.";//Amitabha:TO Be removed after NPK Confirms
arrError[26] = "<li>Please re-enter your site name without special characters.";//Amitabha:TO Be removed after NPK Confirms
arrError[27] = "<li>Please re-enter a site name that does not begin with a numeral.";//Amitabha:TO Be removed after NPK Confirms
arrError[28] = "<li>Please shorten your site name to 26 characters.";//Amitabha:TO Be removed after NPK Confirms
arrError[29] = "<li>Your site name must be in lower case.";//Amitabha:TO Be removed after NPK Confirms

//arrError[30] = "<li>Please shorten the email address to 60 characters.";
arrError[30] = "";
arrError[31] = "<li>Please enter a valid city.";
arrError[32] = "<li>Please shorten your city name to 40 characters.";
arrError[33] = "<li>Please enter a valid phone number of format XXX-XXX-XXXX.";
arrError[34] = "<li>Enter a valid state name.";
//Password Related Error Messages
arrError[35] = "<li>Only letters, spaces, hyphens, and apostrophes accepted.";
//arrError[36] = "<li>Invalid password format - All characters except <,>,are allowed.No spaces.Length 6-15.";//Amitabha:Password would be of  minimum 6 char long for NOW
//arrError[37] = "<li>Password should contain at least one lower case letter.";
//arrError[38] = "<li>Password should contain at least one number.";
arrError[36] = "";
arrError[37] = "";
arrError[38] = "";
arrError[39] = "<li>Invalid password format - All characters except &,<,>,are allowed.No spaces.Length 6-15.";

arrError[40] = "<li>Please check the Terms and Conditions box.";
arrError[41] = "<li>Please enter a valid credit card number.";
arrError[42] = "<li>Please enter the security code as it appears on the back of your credit card.";
arrError[43] = "<li>Please enter the name as it appears on the credit card.";
arrError[44] = "<li>Enter a valid CID (credit card validation number). Only numbers are allowed.";
arrError[45] = "<li>Please enter a valid phone number.";
arrError[46] = "<li>Please enter a valid string without < > characters.";
arrError[47] = "<li>Please shorten the company name to 40 characters.";
arrError[48] = "<li>Please shorten the phone number to 40 characters.";//Amitabha:TO Be removed after NPK Confirms
arrError[49] = "<li>Please shorten the state/province to 40 characters.";
//arrError[50] = "<li>Password should contain at least one upper case letter.";
arrError[50] = "";
arrError[51] = "Please correct the following errors:</br></br>";
arrError[52] = "";
arrError[53] = "<li>Enter your Company size.";
arrError[54] = "<li>Enter a valid US ZipCode.";
arrError[55] = "<li>Please enter a valid phone number of format XXX-XXX-XXXX.";
arrError[56] = "<li>Invalid Phone number - Only numbers, '(', ')', '-', and '+' are allowed. No Spaces. Length 6 - 32.";
arrError[57] = "<li>The email address you entered is already in use for an account, Please enter another email address"

//Strat:Archana::;special char field validation
arrError[58] = "<li>Enter a valid first name.";
arrError[59] = "<li>Enter a valid last name.";
arrError[60] = "<li>Enter a valid city name.";

arrError[61] = "Please correct the following errors before proceeding,";
arrError[62] = "<li>Enter a valid county name.";
arrError[63] = "<li>Enter a valid zip or postal code."

// variable for omniture stuff
var pgname = "";

var signUpUrl = '';
function signUpInit(xhrUrl)
{
	signUpUrl = xhrUrl;
	dojo.xhrGet({
        url: xhrUrl+"html/SignUp.html",
        handleAs: "text",
        load: function(data){
			dojo.byId('signUpContent').innerHTML = data;
        },
		error: function(response, ioArgs) {
			//////////alert("HTTP status code: ", response);
			//////////alert("HTTP status code: ", ioArgs.xhr.status);
        },
        sync: true
    });
	tabInit();
}
function tabInit()
{
	xhrUrl = signUpUrl;
	dojo.xhrGet({
        url: xhrUrl+"html/SignUp_Step1.html",
        handleAs: "text",
        load: function(data){
         dojo.byId('stepaContent').innerHTML = data;
        },
		error: function(response, ioArgs) {
			//////////alert("HTTP status code: ", ioArgs.xhr.status);
        },
        sync: true
    });

	dojo.xhrGet({
        url: xhrUrl+"html/SignUp_Step2.html",
        handleAs: "text",
        load: function(data){
         dojo.byId('stepbContent').innerHTML = data;
        },
		error: function(response, ioArgs) {
			//////////alert("HTTP status code: ", ioArgs.xhr.status);
        },
        sync: true
    });
    dojo.xhrGet({
        url: xhrUrl+"html/SignUp_Step3.html",
        handleAs: "text",
        load: function(data){
         dojo.byId('stepcContent').innerHTML = data;
        },
		error: function(response, ioArgs) {
			//////////alert("HTTP status code: ", ioArgs.xhr.status);
        },
        sync: true
    });
	dojo.xhrGet({
        url: xhrUrl+"html/SignUp_Step2_Cancel.html",
        handleAs: "text",
        load: function(data){
         dojo.byId('stepdContent').innerHTML = data;
        },
		error: function(response, ioArgs) {
			//////////alert("HTTP status code: ", ioArgs.xhr.status);
        },
        sync: true
    });
//	step = 1;
//Start:SEMIUSER code

if(wbx_semiuser == "true" && (!wbx_semiSiteUrl==null || !wbx_semiSiteUrl == ''))
	{
			////////alert("wbx_semiSiteUrl_true:: inside if block");
			////////alert("wbx_semiSiteUrl_true:: inside if block "+wbx_semiSiteUrl);
			//////////alert('Passsword in Cookie::::'+getCookie("SEMISIGNUPASSWORD"));
			accountPassword =  getCookie("SEMISIGNUPASSWORD");
			accountConfirmPassword = getCookie("SEMISIGNUPASSWORD");
			wbxSemiUser = "true";
			step = 0;
	}
	else
	{
		//////////alert("wbx_semiSiteUrl_true:: inside else block "+wbx_semiSiteUrl);
		step = 1;
		if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
		{
			//////////alert("wbx_semifFirstName"+wbx_semifFirstName);
			//SemiFirstName
			var ui_flex_semifFirstName = wbx_semifFirstName;
			var createAccountFirstName = document.getElementById('createAccountFirstName');
			createAccountFirstName.value = ui_flex_semifFirstName;
			//SemiLastName
			var ui_flex_semiLastName = wbx_semiLastName;
			var createAccountLastName = document.getElementById('createAccountLastName');
			createAccountLastName.value = ui_flex_semiLastName;
			//SemiEmailAddress
			var ui_flex_semiEmailAddress = wbx_semiEmailAddress;
			var createAccountEmailaddress = document.getElementById('createSemiAccountEmailaddress');
			createAccountEmailaddress.value = ui_flex_semiEmailAddress;

			document.getElementById ('commonEmailDisply').style.display = 'none';
			document.getElementById ('semiuserEmailDisply').style.display = 'block';

			account_semiuser_id = wbx_semiindividualId;
			wbxSemiUser = "true";
		}
	}

//End:SEMIUSER code
	numSteps = 4;
	taba = document.getElementById('stepa');
	tabb = document.getElementById('stepb');
	tabc = document.getElementById('stepc');
	tabd = document.getElementById('stepd');
	contenta = document.getElementById('stepaContent');
	contentb = document.getElementById('stepbContent');
	contentc = document.getElementById('stepcContent');
	contentd = document.getElementById('stepdContent');
	button = document.getElementById('nextButton');
////alert("+++++++++++++++PCNow Free Trail+++++++++++++++");
//trackID
//alert("+++++++++wbx_flex_trackID++++++++"+wbx_flex_trackID);
//alert("+++++++++wbx_flex_trackID++++++++"+wbx_flex_trackID);
//alert("+++++++++wbx_flex_rollover_ordertotalUS++++++++"+wbx_flex_rollover_ordertotalUS);
//alert("+++++++++wbx_flex_rollover_ordertotalGB++++++++"+wbx_flex_rollover_ordertotalGB);
//alert("+++++++++wbx_flex_rollover_ordertotalEUR++++++++"+wbx_flex_rollover_ordertotalEUR);
//alert("+++++++++wbx_flex_rollover_mrrUS++++++++"+wbx_flex_rollover_mrrUS);
//alert("+++++++++wbx_flex_rollover_mrrGB++++++++"+wbx_flex_rollover_mrrGB);
//alert("+++++++++wbx_flex_rollover_mrrEUR++++++++"+wbx_flex_rollover_mrrEUR);
//alert("+++++++++wbx_flex_rolloveroffercode_bynode++++++++"+wbx_flex_rolloveroffercode_bynode);
//alert("+++++++++wbx_flex_rolloverpromocode_bynode++++++++"+wbx_flex_rolloverpromocode_bynode);
if ((wbx_flex_trackID != null) && (!wbx_flex_trackID == ''))
{
	var ui_flex_trackID = wbx_flex_trackID;
	var ui_flex_tracklID = document.getElementById('ui_flex_tracklID');
	ui_flex_tracklID.value = ui_flex_trackID;
}
if(wbx_flex_initialTerm == '0'  && wbx_flex_renewalTerm == '0')
{
	//////alert("+++++++++++++++inside PCNow Free Trail+++++++++++++++");
	document.getElementById ('optInBox').style.display = 'none';
	document.getElementById ('signup_step1_lbl_freeTrialWithColon').style.display = 'inline';
	document.getElementById ('signup_step1_content_middle_freeTrial').style.display = 'inline';
	document.getElementById ('signup_step1_content_middle_buynow').style.display = 'none';
	document.getElementById ('signup_step2_lbl_freeTrialWithColon').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_riskFreeTrial').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_freeTrial_continue').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_MeetMeNow14Day').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_freetrial').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_Subscribe').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_Subscribe_Curr').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_AsAFreeTrial').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_TheTransaction').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_NextAndCancel').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_Continue').style.display = 'none';
	document.getElementById ('signup_step2_Cancel_expiryDate').style.display = 'inline';
	document.getElementById ('signup_step2_Cancel_content_middle_freetrial').style.display = 'inline';
	document.getElementById ('signup_step3_title_freeTrial').style.display = 'inline';
	document.getElementById ('signup_step3_content_top_freeTrial').style.display = 'inline';
	document.getElementById ('signup_step3_content_top_subscription').style.display = 'none';

	document.getElementById ('signup_step3_content_middle_highlight').innerHTML = "Congratulations! Your account has been created and is now ready to use.";
	var freetrialDt = addDays(freeTrialDays);
	document.getElementById ('signup_step2_Cancel_expiryDate').innerHTML = freetrialDt;
	document.getElementById ('signup_step2_content_middle_freetrial').innerHTML = wbx_flex_signup2_offerdesc;
	document.getElementById ('signup_step2_Cancel_content_middle_freetrial').innerHTML = wbx_flex_signup2_offerdesc;

	if(wbx_flex_channelid == "default")
	{
		document.getElementById ('signup_account_location_default').style.display = 'inline';
		document.getElementById ('signup_account_location_vz').style.display = 'none';
		document.getElementById('channelId').value = "1230";
	}
	else
	{
		document.getElementById ('signup_account_location_default').style.display = 'none';
		document.getElementById ('signup_account_location_vz').style.display = 'inline';
		document.getElementById('channelId').value = "1240";
	}

	//channelid
	var ui_flex_channelid = wbx_flex_channelid;
	var ui_flex_channelID = document.getElementById('ui_flex_channelID');
	ui_flex_channelID.value = ui_flex_channelid;
	//inititalterm
	var ui_flex_initialTerm = wbx_flex_initialTerm;
	var ui_flex_initialTermID = document.getElementById('ui_flex_initialTermID');
	ui_flex_initialTermID.value = ui_flex_initialTerm;
	//renevalterm
	var ui_flex_renewalTerm = wbx_flex_renewalTerm;
	var ui_flex_renewalTermID = document.getElementById('ui_flex_renewalTermID');
	ui_flex_renewalTermID.value = ui_flex_renewalTerm;
	//promotioncode
	var ui_flex_promotioncode = wbx_flex_promotioncode;
	var ui_flex_promotioncodeID = document.getElementById('ui_flex_promotioncodeID');
	ui_flex_promotioncodeID.value = ui_flex_promotioncode;
	//offercodebynode
	//var ui_flex_offercode_bynode = "MyWebEx PC";
	var ui_flex_offercode_bynode = wbx_flex_offercode_bynode;
	var ui_flex_offercodeID_bynode = document.getElementById('ui_flex_offercodeID_bynode');
	ui_flex_offercodeID_bynode.value = ui_flex_offercode_bynode;
	//promotioncodebynode

	//var wbx_flex_promotioncode_bynodeProcess =  wbx_flex_promotioncode_bynode + ":" + wbx_flex_offercode_bynode;
	var ui_flex_promotioncode_bynode = wbx_flex_promotioncode_bynode;
	var ui_flex_promotioncodeID_bynode = document.getElementById('ui_flex_promotioncodeID_bynode');
	ui_flex_promotioncodeID_bynode.value = ui_flex_promotioncode_bynode;
	//ordertotal
	var ui_flex_ordertotal = wbx_flex_ordertotal;
	var orderTotalID = document.getElementById('orderTotalID');
	orderTotalID.value = ui_flex_ordertotal;
	//mrr
	var ui_flex_mrr = wbx_flex_mrr;
	var mrrID = document.getElementById('mrrID');
	mrrID.value = ui_flex_mrr;
	//freetrial
	var ui_flex_trialType = "freeTrial";
	var trialTypeID = document.getElementById('trialTypeID');
	trialTypeID.value = ui_flex_trialType;
	//ccOptional
	var ui_flex_ccOptional = wbx_flex_ccOptional;
	var ccOptionalID = document.getElementById('ccOptionalID');
	ccOptionalID.value = ui_flex_ccOptional;
	//////////alert("ui_flex_ccOptional:::"+ui_flex_ccOptional);
	//Noofpcs
	var ui_flex_pcs = wbx_no_pcs;
	var ui_flex_pcsID = document.getElementById('ui_flex_pcsID');
	ui_flex_pcsID.value = ui_flex_pcs;
	//////////alert("ui_flex_pcs:::"+ui_flex_pcs);
	//wbx_flex_isfreetrial
	//////////alert("###wbx_flex_isfreetrial###"+wbx_flex_isfreetrial);
	var ui_flex_isfreetrial = wbx_flex_isfreetrial;
	var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID');
	ui_flex_isfreetrialID.value = ui_flex_isfreetrial;

	if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
	{
		document.getElementById ('commonEmailDisply').style.display = 'none';
		document.getElementById ('semiuserEmailDisply').style.display = 'block';
	}
	else
	{
		document.getElementById ('commonEmailDisply').style.display = 'block';
		document.getElementById ('semiuserEmailDisply').style.display = 'none';
	}

}
////////////////alert("wbx_flex_promotioncode_bynode:::"+wbx_flex_promotioncode_bynode);
if(wbx_flex_initialTerm == '1'  && wbx_flex_renewalTerm == '1')
{
	//channelid
	var ui_flex_channelid = wbx_flex_channelid;
	var ui_flex_channelID = document.getElementById('ui_flex_channelID');
	ui_flex_channelID.value = ui_flex_channelid;
	//inititalterm
	var ui_flex_initialTerm = wbx_flex_initialTerm;
	var ui_flex_initialTermID = document.getElementById('ui_flex_initialTermID');
	ui_flex_initialTermID.value = ui_flex_initialTerm;
	//renevalterm
	var ui_flex_renewalTerm = wbx_flex_renewalTerm;
	var ui_flex_renewalTermID = document.getElementById('ui_flex_renewalTermID');
	ui_flex_renewalTermID.value = ui_flex_renewalTerm;
	//promotioncode
	var ui_flex_promotioncode = wbx_flex_promotioncode;
	var ui_flex_promotioncodeID = document.getElementById('ui_flex_promotioncodeID');
	ui_flex_promotioncodeID.value = ui_flex_promotioncode;
	//offercodebynode
	//var ui_flex_offercode_bynode = "MyWebEx PC";
	var ui_flex_offercode_bynode = wbx_flex_offercode_bynode;
	var ui_flex_offercodeID_bynode = document.getElementById('ui_flex_offercodeID_bynode');
	ui_flex_offercodeID_bynode.value = ui_flex_offercode_bynode;
	//promotioncodebynode
	//var ui_flex_promotioncode_bynode = "WXPak:MyWebEx PC";
	var ui_flex_promotioncode_bynode = wbx_flex_promotioncode_bynode;
	var ui_flex_promotioncodeID_bynode = document.getElementById('ui_flex_promotioncodeID_bynode');
	ui_flex_promotioncodeID_bynode.value = ui_flex_promotioncode_bynode;
	//ordertotal
	//var ui_flex_ordertotal = "49";
	var ui_flex_ordertotal = wbx_flex_ordertotal;
	var orderTotalID = document.getElementById('orderTotalID');
	orderTotalID.value = ui_flex_ordertotal;
	//ordertotalUS
	var ui_flex_ordertotalUS = wbx_flex_ordertotalUS;
	var orderTotalIDUS = document.getElementById('orderTotalIDUS');
	orderTotalIDUS.value = ui_flex_ordertotalUS;
	//ordertotalGB
	var ui_flex_ordertotalGB = wbx_flex_ordertotalGB;
	var orderTotalIDGB = document.getElementById('orderTotalIDGB');
	orderTotalIDGB.value = ui_flex_ordertotalGB;
	//ordertotalEUR
	var ui_flex_ordertotalEUR = wbx_flex_ordertotalEUR;
	var orderTotalIDEUR = document.getElementById('orderTotalIDEUR');
	orderTotalIDEUR.value = ui_flex_ordertotalEUR;
	//mrr
	//var ui_flex_mrr = "49";
	var ui_flex_mrr = wbx_flex_mrr;
	var mrrID = document.getElementById('mrrID');
	mrrID.value = ui_flex_mrr;
		//mrrUS
	var ui_flex_mrrUS = wbx_flex_mrrUS;
	var mrrIDUS = document.getElementById('mrrIDUS');
	mrrIDUS.value = ui_flex_mrrUS;
	//mrrGB
	var ui_flex_mrrGB = wbx_flex_mrrGB;
	var mrrIDGB = document.getElementById('mrrIDGB');
	mrrIDGB.value = ui_flex_mrrGB;
	//mrrEUR
	var ui_flex_mrrEUR = wbx_flex_mrrEUR;
	var mrrIDEUR = document.getElementById('mrrIDEUR');
	mrrIDEUR.value = ui_flex_mrrEUR;
	//buynowmonthly
	var ui_flex_trialType = "buynow monthly term";
	var trialTypeID = document.getElementById('trialTypeID');
	trialTypeID.value = ui_flex_trialType;
	//ccOptional
	//Noofpcs
	var ui_flex_pcs = wbx_no_pcs;
	var ui_flex_pcsID = document.getElementById('ui_flex_pcsID');
	ui_flex_pcsID.value = ui_flex_pcs;
	//////////alert("ui_flex_pcs:::"+ui_flex_pcs);
	var ui_flex_ccOptional = wbx_flex_ccOptional;
	var ccOptionalID = document.getElementById('ccOptionalID');
	ccOptionalID.value = ui_flex_ccOptional;
	//wbx_flex_isfreetrial
	//////////alert("###wbx_flex_isfreetrial###"+wbx_flex_isfreetrial);
	var ui_flex_isfreetrial = "false";
	var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID');
	ui_flex_isfreetrialID.value = ui_flex_isfreetrial;
	document.getElementById ('signup_step2_content_middle_Subscribe').innerHTML = wbx_flex_signup2_offerdesc;
	document.getElementById ('signup_step3_content_middle_highlight').innerHTML = "Congratulations! Your subscription has been created and your account is now ready to use.";

	document.getElementById ('optInBox').style.display = 'none';
	document.getElementById ('signup_step1_lbl_freeTrialWithColon').style.display = 'none';
	document.getElementById ('signup_step1_content_middle_freeTrial').style.display = 'none';
	document.getElementById ('signup_step1_content_middle_buynow').style.display = 'inline';
	document.getElementById ('signup_step2_lbl_freeTrialWithColon').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_riskFreeTrial').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_freeTrial_continue').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_MeetMeNow14Day').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_freetrial').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_Subscribe').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_Subscribe_Curr').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_AsAFreeTrial').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_TheTransaction').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_NextAndCancel').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_Continue').style.display = 'inline';
	document.getElementById ('signup_step2_Cancel_expiryDate').style.display = 'none';
	document.getElementById ('signup_step2_Cancel_content_middle_freetrial').style.display = 'none';
	document.getElementById ('signup_step3_title_freeTrial').style.display = 'none';
	document.getElementById ('signup_step3_content_top_freeTrial').style.display = 'none';
	document.getElementById ('signup_step3_content_top_subscription').style.display = 'inline';

	if(wbx_flex_channelid == "default")
	{
		document.getElementById ('signup_account_location_default').style.display = 'inline';
		document.getElementById ('signup_account_location_vz').style.display = 'none';
		document.getElementById('channelId').value = "1230";
	}
	else
	{
		document.getElementById ('signup_account_location_default').style.display = 'none';
		document.getElementById ('signup_account_location_vz').style.display = 'inline';
		document.getElementById('channelId').value = "1240";
	}

	if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
	{
		document.getElementById ('commonEmailDisply').style.display = 'none';
		document.getElementById ('semiuserEmailDisply').style.display = 'block';
	}
	else
	{
		document.getElementById ('commonEmailDisply').style.display = 'block';
		document.getElementById ('semiuserEmailDisply').style.display = 'none';
	}
}
if(wbx_flex_initialTerm == '12'  && wbx_flex_renewalTerm == '12')
{
	//////////alert("inside PCNow annual");
	//channelid
	var ui_flex_channelid = wbx_flex_channelid;
	var ui_flex_channelID = document.getElementById('ui_flex_channelID');
	ui_flex_channelID.value = ui_flex_channelid;
	//inititalterm
	var ui_flex_initialTerm = wbx_flex_initialTerm;
	var ui_flex_initialTermID = document.getElementById('ui_flex_initialTermID');
	ui_flex_initialTermID.value = ui_flex_initialTerm;
	//renevalterm
	var ui_flex_renewalTerm = wbx_flex_renewalTerm;
	var ui_flex_renewalTermID = document.getElementById('ui_flex_renewalTermID');
	ui_flex_renewalTermID.value = ui_flex_renewalTerm;
	//promotioncode
	var ui_flex_promotioncode = wbx_flex_promotioncode;
	var ui_flex_promotioncodeID = document.getElementById('ui_flex_promotioncodeID');
	ui_flex_promotioncodeID.value = ui_flex_promotioncode;
	//offercodebynode
	//var ui_flex_offercode_bynode = "PC Now Annual";
	var ui_flex_offercode_bynode = wbx_flex_offercode_bynode;
	var ui_flex_offercodeID_bynode = document.getElementById('ui_flex_offercodeID_bynode');
	ui_flex_offercodeID_bynode.value = ui_flex_offercode_bynode;
	//promotioncodebynode

	//var ui_flex_promotioncode_bynode = "WXPakAnnual:PC Now Annual";
	var ui_flex_promotioncode_bynode = wbx_flex_promotioncode_bynode;
	var ui_flex_promotioncodeID_bynode = document.getElementById('ui_flex_promotioncodeID_bynode');
	ui_flex_promotioncodeID_bynode.value = ui_flex_promotioncode_bynode;
	//ordertotal
	//var ui_flex_ordertotal = "39";
	var ui_flex_ordertotal = wbx_flex_ordertotal;
	var orderTotalID = document.getElementById('orderTotalID');
	orderTotalID.value = ui_flex_ordertotal;
	//ordertotalUS
	var ui_flex_ordertotalUS = wbx_flex_ordertotalUS;
	var orderTotalIDUS = document.getElementById('orderTotalIDUS');
	orderTotalIDUS.value = ui_flex_ordertotalUS;
	//ordertotalGB
	var ui_flex_ordertotalGB = wbx_flex_ordertotalGB;
	var orderTotalIDGB = document.getElementById('orderTotalIDGB');
	orderTotalIDGB.value = ui_flex_ordertotalGB;
	//ordertotalEUR
	var ui_flex_ordertotalEUR = wbx_flex_ordertotalEUR;
	var orderTotalIDEUR = document.getElementById('orderTotalIDEUR');
	orderTotalIDEUR.value = ui_flex_ordertotalEUR;
	//mrr
	//var ui_flex_mrr = "0";
	var ui_flex_mrr = wbx_flex_mrr;
	var mrrID = document.getElementById('mrrID');
	mrrID.value = ui_flex_mrr;
	//mrrUS
	var ui_flex_mrrUS = wbx_flex_mrrUS;
	var mrrIDUS = document.getElementById('mrrIDUS');
	mrrIDUS.value = ui_flex_mrrUS;
	//mrrGB
	var ui_flex_mrrGB = wbx_flex_mrrGB;
	var mrrID = document.getElementById('mrrIDGB');
	mrrID.value = ui_flex_mrrGB;
	//mrrEUR
	var ui_flex_mrrEUR = wbx_flex_mrrEUR;
	var mrrIDEUR = document.getElementById('mrrIDEUR');
	mrrIDEUR.value = ui_flex_mrrEUR;
	//buynowannual
	var ui_flex_trialType = "buynow annual term";
	var trialTypeID = document.getElementById('trialTypeID');
	trialTypeID.value = ui_flex_trialType;
	//ccOptional
	var ui_flex_ccOptional = wbx_flex_ccOptional;
	var ccOptionalID = document.getElementById('ccOptionalID');
	ccOptionalID.value = ui_flex_ccOptional;
	//Noofpcs
	var ui_flex_pcs = wbx_no_pcs;
	var ui_flex_pcsID = document.getElementById('ui_flex_pcsID');
	ui_flex_pcsID.value = ui_flex_pcs;
	//////////alert("ui_flex_pcs:::"+ui_flex_pcs);
	//wbx_flex_isfreetrial
	//////////alert("###wbx_flex_isfreetrial###"+wbx_flex_isfreetrial);
	var ui_flex_isfreetrial = "false";
	var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID');
	ui_flex_isfreetrialID.value = ui_flex_isfreetrial;

	document.getElementById ('signup_step2_content_middle_Subscribe').innerHTML = wbx_flex_signup2_offerdesc;
	document.getElementById ('signup_step3_content_middle_highlight').innerHTML = "Congratulations! Your subscription has been created and your account is now ready to use.";

	document.getElementById ('optInBox').style.display = 'none';
	document.getElementById ('signup_step1_lbl_freeTrialWithColon').style.display = 'none';
	document.getElementById ('signup_step1_content_middle_freeTrial').style.display = 'none';
	document.getElementById ('signup_step1_content_middle_buynow').style.display = 'inline';
	document.getElementById ('signup_step2_lbl_freeTrialWithColon').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_riskFreeTrial').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_freeTrial_continue').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_MeetMeNow14Day').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_freetrial').style.display = 'none';
	document.getElementById ('signup_step2_content_middle_Subscribe').style.display = 'inline';
	document.getElementById ('signup_step2_content_middle_Subscribe_Curr').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_AsAFreeTrial').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_TheTransaction').style.display = 'inline';
	document.getElementById ('signup_step2_content_bottom_NextAndCancel').style.display = 'none';
	document.getElementById ('signup_step2_content_bottom_Continue').style.display = 'inline';
	document.getElementById ('signup_step2_Cancel_expiryDate').style.display = 'none';
	document.getElementById ('signup_step2_Cancel_content_middle_freetrial').style.display = 'none';
	document.getElementById ('signup_step3_title_freeTrial').style.display = 'none';
	document.getElementById ('signup_step3_content_top_freeTrial').style.display = 'none';
	document.getElementById ('signup_step3_content_top_subscription').style.display = 'inline';

	if(wbx_flex_channelid == "default")
	{
		document.getElementById ('signup_account_location_default').style.display = 'inline';
		document.getElementById ('signup_account_location_vz').style.display = 'none';
		document.getElementById('channelId').value = "1230";
	}
	else
	{
		document.getElementById ('signup_account_location_default').style.display = 'none';
		document.getElementById ('signup_account_location_vz').style.display = 'inline';
		document.getElementById('channelId').value = "1240";
	}

	if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
	{
		document.getElementById ('commonEmailDisply').style.display = 'none';
		document.getElementById ('semiuserEmailDisply').style.display = 'block';
	}
	else
	{
		document.getElementById ('commonEmailDisply').style.display = 'block';
		document.getElementById ('semiuserEmailDisply').style.display = 'none';
	}
}
    document.getElementById ('EnabledNextLinkStep1').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep1').style.display = 'none';
    document.getElementById ('EnabledNextLinkStep2').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep2').style.display = 'none';
	document.getElementById ('EnabledNextLinkStep2Cancel').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep2Cancel').style.display = 'none';

	populateExpiresYearDropDownValue();
	tabSwitch(step);
}

// Function to populate CreditCard expires-year dropdown values.
function populateExpiresYearDropDownValue() {
	// Fetching the drop-down element.
	var aeyCombo = document.getElementById("accountExpirationYear");
	// Fetching the current year.
	var d = new Date();
    var curr_year = d.getFullYear();
    // Adding the current-year and the next ten years to the drop-down.
	for (var i = 0; i <= 10 ; i++){
		var tmpYr1 = curr_year + i;
		var option = document.createElement("option");
		option.text = tmpYr1;
		option.value = tmpYr1;
		try {
			aeyCombo.add(option, null); //Standard
		}catch(error) {
			aeyCombo.add(option); // IE only
		}
	}
}

function nextStep(num)
{
	document.getElementById ('EnabledNextLinkStep1').style.display = 'none';
	document.getElementById ('DisabledNextLinkStep1').style.display = 'block';
	document.getElementById ('EnabledNextLinkStep2').style.display = 'none';
	document.getElementById ('DisabledNextLinkStep2').style.display = 'block';
	document.getElementById ('EnabledNextLinkStep2Cancel').style.display = 'none';
	document.getElementById ('DisabledNextLinkStep2Cancel').style.display = 'block';

	var error = false;
    if (step == 1)
    {
		//alert("++++++++++++++++inside PCNow Step1+++++++++++++++++");
		//Add trial days
		var freetrialDt = addDays(freeTrialDays);
		document.getElementById ("expiryDate").innerHTML = freetrialDt;
		//alert("++++++++++++++++inside PCNow Step2222222222222+++++++++++++++++");
		error = validateStep1(error);
		//////alert("++++++++++++++++error++++++++++++++++++"+error);
		if (!error)
        {
				/* ::::::::::::::::::::::  START: :::::::::::::::::::::   */
				//alert("++++++++++++++++inside PCNow Step1 inside error +++++++++++++++++");
				var signUpForm = document.getElementById('signUpForm');
				createAccountFirstName = document.getElementById('createAccountFirstName').value;
				createAccountLastName = document.getElementById('createAccountLastName').value;
				createAccountEmailaddress = document.getElementById('createAccountEmailaddress').value;
				createAccountEmailaddress = createAccountEmailaddress.toLowerCase();
				//alert("++++++++++++++++inside PCNow Step1 inside +++++++++++++++++"+createAccountEmailaddress);
				createAccountPassword = document.getElementById('createAccountPassword').value;
				createAccountConfirmPassword = document.getElementById('createAccountConfirmPassword').value;
				createAccountLocationBox = document.getElementById('createAccountLocation');
				createAccountLocationBoxIndex = createAccountLocationBox.selectedIndex;
				createAccountLocation = createAccountLocationBox.options[createAccountLocationBoxIndex].value;

				// Change to select the same country in second page
				if(createAccountLocation == 'USD') {
					document.getElementById("accountCountry").value = 'US';
				} else {
					document.getElementById("accountCountry").value = 'GB';
				}

				// Start: Setting up timezone specific to currency for BUG #1436 Fix
				if(createAccountLocation == 'USD') {
					document.getElementById("timeZone").value = '12';
				} else if(createAccountLocation == 'GBP') {
					document.getElementById("timeZone").value = '20';
				}else if(createAccountLocation == 'EUR') {
					document.getElementById("timeZone").value = '21';
				}
				// End: Setting up timezone specific to currency for BUG #1436 Fix


				document.getElementById ('signup_step2_content_middle_Subscribe_Curr').innerHTML = getCurrCharFromDesc(createAccountLocation);
				document.getElementById ('signup_step2_content_middle_freeTrial_continue').innerHTML = getMonthlyRateString(createAccountLocation);
				//START:LOAD The SignUpApp-Include.jsp
					//Start:Forming the Calling URL
					var proto = "http:";
					if(window.top.location.protocol == "https:"){
						proto = "https:";
					}
					var domainString ='';
					if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
					{
						domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

					}else
					{
						domainString = proto + '//'+document.domain;
						var xhrURL = domainString+'/SignUpApp/js/SignUpApp-Include.jsp';
						////alert("xhrURL"+xhrURL);
						//END:Forming the Calling URL

							dojo.xhrGet ({

								// Location of the HTML content we want to grab
								url: xhrURL,

								// Called when the page loaded successfully
								load: function (data) {

								},
								sync: true,
								// Called if there was an error (such as a 404 response)
								error: function (data) {
									console.error('Error: ', data);
								}
							});

					}
					//END:LOAD The SignUpApp-Include.jsp
					//START:Calling The JSON-RPC
					var proto = "http:";
					if(window.top.location.protocol == "https:"){
						proto = "https:";
					}

					var domainString ='';
					if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
					{
						domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

					}else
					{
						domainString = proto + '//'+document.domain;
						jsonurl = domainString + '/SignUpApp/JSON-RPC';
						////alert("jsonurl"+jsonurl);
						//End:Forming the Calling URL
						jsonrpc = null;
						//Initializing JSONRpcClient
						try
						{
							jsonrpc = new JSONRpcClient(jsonurl);
						}
						catch(e)
						{
						  window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
						  error = true;
						}
					}
					//END:Calling The JSON-RPC
					var siteInvalidError = document.getElementById('siteInvalidError');
					siteInvalidError.style.display   = "none";
					var createAccountInput = {"createAccountEmailaddress": createAccountEmailaddress};
					var createAccountInputJSON = JSON.stringify(createAccountInput);
					////alert("++++++++++createAccountInputJSON++++++++++++"+createAccountInputJSON);
			if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
			{
				////////alert("++++++++++++++No Need for EmailAddress Check++++++++++++++++++++++");
			}
			else
			{
					 if (jsonrpc != null)
					 {
						 if (jsonrpc.signUp != null)
						 {
							var createAccountResultJSON =  null;
							try
							{
								createAccountResultJSON = jsonrpc.signUp.createAccount(createAccountInputJSON);
								////alert("++++++++++++++++inside PCNow Step1 inside +++++++++++++++++"+createAccountResultJSON);
								if (createAccountResultJSON!=null)
								{
									document.getElementById('siteInvalidError').innerHTML = '';
									if (createAccountResultJSON == "true")
									{
										siteInvalidError.style.display   = "none";
									}
									if (createAccountResultJSON == "false")
									{
										error = true;
										siteInvalidError.style.display   = "block";
										//document.getElementById('siteInvalidError').innerHTML = 'The email address you chose is taken. Please try again with another email address.';
										document.getElementById('siteInvalidError').innerHTML = "The email address you chose is taken. <a href='/MyWebExWeb/MyWebexPortal.portal?_nfpb=true&_pageLabel=MyWebexPortal_page_portalLogin&LOGOHEADER=true'>Click Here</a> to Login or Please try again with another email address.";
									}

									if (createAccountResultJSON == "error")
									{
										 error = true;
										 window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
									}
								}

							}
							catch (e)
							{}
						 } else
						 {
							 window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
							 error = true;
						 }
					 } else
					 {
						window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
						error = true;
					 }
			}
		}
    } else if (step == 2)
    {
		var freetrialDt = addDays(freeTrialDays);
		document.getElementById ("expiryDate").innerHTML = freetrialDt;
		error = validateStep2(error);
        if (!error)
        {
			var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID').value;
			if(wbx_semiuser == "true" && (!wbx_semiSiteUrl==null || !wbx_semiSiteUrl == ''))
			{
				//alert("######inside SemiUser fucntion#######");
			//Start:Archana:keep the step 1 value
				//accountFirstName = wbx_semifFirstName;
				//accountLastName = wbx_semiLastName;
				createAccountBillingFirstName = wbx_semifFirstName;
				createAccountBillingLastName = wbx_semiLastName;
			//End
				accountFirstName = document.getElementById('accountFirstName').value;
				accountLastName = document.getElementById('accountLastName').value;

				accountEmailAddress = wbx_semiEmailAddress;
				accountLocation = wbx_semiCurrency;
				account_semiuser_accountid = wbx_semiindividualId;
				////////alert("#################account_semiuseraccount_id##################"+account_semiuser_accountid);

				if (document.getElementById ("signup_step2_state")){
				  if ((accountLocation != null) && (accountLocation == "USD") )
				  {
					   document.getElementById ("signup_step2_state").innerHTML = "State:";
				  }else {
					   document.getElementById ("signup_step2_state").innerHTML = "County:";
				  }
				}


				accountPassword =  getCookie('SEMISIGNUPASSWORD');
				accountConfirmPassword = getCookie('SEMISIGNUPASSWORD');
				if ((accountLocation != null) && (accountLocation == "USD"))
				{
					if(ui_flex_isfreetrialID == "false")
					{
						////////alert("######inside Semi USD fucntion#######"+accountLocation);
						var orderTotal = document.getElementById('orderTotalIDUS').value;
						var mrr = document.getElementById('mrrIDUS').value;
						////////alert("######orderTotal#####"+orderTotal);
						////////alert("######mrr#####"+mrr);
					}
					else
					{
						////////alert("######inside Semi USD FreeTrail fucntion#######");
						var orderTotal = document.getElementById('orderTotalID').value;
						var mrr = document.getElementById('mrrID').value;
					}
				}
				if ((accountLocation != null) && (accountLocation == "GBP"))
				{
					if(ui_flex_isfreetrialID == "false")
					{
						////////alert("######inside Semi GBP fucntion#######"+accountLocation);
						var orderTotal = document.getElementById('orderTotalIDGB').value;
						var mrr = document.getElementById('mrrIDGB').value;
						////////alert("######orderTotal#####"+orderTotal);
						////////alert("######mrr#####"+mrr);
					}
					else
					{
						////////alert("######inside Semi GBP FreeTrail fucntion#######");
						var orderTotal = document.getElementById('orderTotalID').value;
						var mrr = document.getElementById('mrrID').value;
					}
				}
				if ((accountLocation != null) && (accountLocation == "EUR"))
				{
					if(ui_flex_isfreetrialID == "false")
					{
						////////alert("######inside Semi EUR fucntion#######"+accountLocation);
						var orderTotal = document.getElementById('orderTotalIDEUR').value;
						var mrr = document.getElementById('mrrIDEUR').value;
						////////alert("######orderTotal#####"+orderTotal);
						////////alert("######mrr#####"+mrr);
					}
					else
					{
						////////alert("######inside Semi EUR FreeTrail fucntion#######");
						var orderTotal = document.getElementById('orderTotalID').value;
						var mrr = document.getElementById('mrrID').value;
					}
				}
			}
			else
			{
					if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
					{
						account_semiuser_accountid = wbx_semiindividualId;
						////////alert("#################account_semiuseraccount_id##################"+account_semiuser_accountid);
						accountEmailAddress = document.getElementById('createSemiAccountEmailaddress').value;
						//alert("#################wbx_semiuser true  accountEmailAddress##################"+accountEmailAddress);
					}else{
						accountEmailAddress = document.getElementById('accountEmailAddress').value;
						//alert("#################wbx_semiuser false  accountEmailAddress##################"+accountEmailAddress);
					}
					accountFirstName = document.getElementById('accountFirstName').value;
					accountLastName = document.getElementById('accountLastName').value;
					//accountEmailAddress = document.getElementById('accountEmailAddress').value;
					accountEmailAddress = accountEmailAddress.toLowerCase();
					accountPassword = document.getElementById('accountPassword').value;
					accountConfirmPassword = document.getElementById('accountConfirmPassword').value;
					accountLocation = document.getElementById('accountLocation').value;
				//Start:Archana:for Billing Contact pass Step1 value
					var createAccountBillingFirstName = document.getElementById('createAccountBillingFirstName').value;
					var createAccountBillingLastName = document.getElementById('createAccountBillingLastName').value;
				//End

				if (document.getElementById ("signup_step2_state")){
				  if ((accountLocation != null) && (accountLocation == "USD") )
				  {
					   document.getElementById ("signup_step2_state").innerHTML = "State:";
				  }else {
					   document.getElementById ("signup_step2_state").innerHTML = "County:";
				  }
				}


						if ((accountLocation != null) && (accountLocation == "USD"))
						{
							if(ui_flex_isfreetrialID == "false")
							{
								////////alert("######inside USD fucntion#######"+accountLocation);
								var orderTotal = document.getElementById('orderTotalIDUS').value;
								var mrr = document.getElementById('mrrIDUS').value;
								////////alert("######orderTotal#####"+orderTotal);
								////////alert("######mrr#####"+mrr);
							}
							else
							{
								////////alert("######inside USD FreeTrail fucntion#######");
								var orderTotal = document.getElementById('orderTotalID').value;
								var mrr = document.getElementById('mrrID').value;
							}
						}
						if ((accountLocation != null) && (accountLocation == "GBP"))
						{
							if(ui_flex_isfreetrialID == "false")
							{
								////////alert("######inside GBP fucntion#######"+accountLocation);
								var orderTotal = document.getElementById('orderTotalIDGB').value;
								var mrr = document.getElementById('mrrIDGB').value;
								////////alert("######orderTotal#####"+orderTotal);
								////////alert("######mrr#####"+mrr);
							}
							else
							{
								////////alert("######inside GBP FreeTrail fucntion#######");
								var orderTotal = document.getElementById('orderTotalID').value;
								var mrr = document.getElementById('mrrID').value;
							}
						}
						if ((accountLocation != null) && (accountLocation == "EUR"))
						{
							if(ui_flex_isfreetrialID == "false")
							{
								////////alert("######inside EUR fucntion#######"+accountLocation);
								var orderTotal = document.getElementById('orderTotalIDEUR').value;
								var mrr = document.getElementById('mrrIDEUR').value;
								////////alert("######orderTotal#####"+orderTotal);
								////////alert("######mrr#####"+mrr);
							}
							else
							{
								////////alert("######inside EUR FreeTrail fucntion#######");
								var orderTotal = document.getElementById('orderTotalID').value;
								var mrr = document.getElementById('mrrID').value;
							}
						}
			}
			DeleteCookie( 'SEMISIGNUPASSWORD' );
			accountBilladdress = document.getElementById('accountBilladdress').value;
			accountCity = document.getElementById('accountCity').value;
			accountState = document.getElementById('accountState').value;
			accountState = accountState.toUpperCase();
			accountZipcode = document.getElementById('accountZipcode').value;
			accountCountryBox = document.getElementById('accountCountry');
			accountCountryBoxIndex = accountCountryBox.selectedIndex;
			accountCountry = accountCountryBox.options[accountCountryBoxIndex].value;
			accountTelephone = document.getElementById('accountTelephone').value;
			accountCreditCardBox = document.getElementById('accountCreditCard');
			accountCreditCardBoxIndex = accountCreditCardBox.selectedIndex;
			accountCreditCard = accountCreditCardBox.options[accountCreditCardBoxIndex].value;
			accountCreditCardNumber = document.getElementById('accountCreditCardNumber').value;
			accountExpirationMonthBox = document.getElementById('accountExpirationMonth');
			accountExpirationMonthBoxIndex = accountExpirationMonthBox.selectedIndex;
			accountExpirationMonth = accountExpirationMonthBox.options[accountExpirationMonthBoxIndex].value;
			accountExpirationYearBox = document.getElementById('accountExpirationYear');
			accountExpirationYearBoxIndex = accountExpirationYearBox.selectedIndex;
			accountExpirationYear = accountExpirationYearBox.options[accountExpirationYearBoxIndex].value;
			accountSecurityCode = document.getElementById('accountSecurityCode').value;
			//hiddenBox Values
			/********************************************************************************/
			var ui_flex_channelID = document.getElementById('ui_flex_channelID').value;
			var ui_flex_initialTermID = document.getElementById('ui_flex_initialTermID').value;
			var ui_flex_renewalTermID = document.getElementById('ui_flex_renewalTermID').value;
			var ui_flex_offercodeID = document.getElementById('ui_flex_offercodeID').value;
			var ui_flex_promotioncodeID = document.getElementById('ui_flex_promotioncodeID').value;
			var ui_flex_offercodeID_bynode = document.getElementById('ui_flex_offercodeID_bynode').value;
			var ui_flex_promotioncodeID_bynode = document.getElementById('ui_flex_promotioncodeID_bynode').value;
			var resellerId = document.getElementById('resellerId').value;
			var channelId = document.getElementById('channelId').value;
			var partyID = document.getElementById('partyID').value;
			var partyName = document.getElementById('partyName').value;
			var partyUrl = document.getElementById('partyUrl').value;
			var employeeNumber = document.getElementById('employeeNumber').value;
			var annualRevenue = document.getElementById('annualRevenue').value;
			var timeZone = document.getElementById('timeZone').value;
			timeZoneEdit = timeZone;
			var trialType = document.getElementById('trialTypeID').value;
			var nowServiceType = document.getElementById('NowServiceType').value;
			var trialDay = document.getElementById('trialDay').value;
		    var ui_flex_pcsID = document.getElementById('ui_flex_pcsID').value;
			var ui_flex_tracklID = document.getElementById('ui_flex_tracklID').value;
			ui_wbx_semiuser = wbxSemiUser;
			////////alert("################ui_wbx_semiuser###############"+ui_wbx_semiuser);
			/********************************************************************************/
			//START:LOAD The SignUpApp-Include.jsp
				//Start:Forming the Calling URL
				var proto = "http:";
				if(window.top.location.protocol == "https:"){
					proto = "https:";
				}
				var domainString ='';
				if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
				{
					domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

				}else
				{
					domainString = proto + '//'+document.domain;
					var xhrURL = domainString+'/SignUpApp/js/SignUpApp-Include.jsp';
				//END:Forming the Calling URL
					dojo.xhrGet ({

						// Location of the HTML content we want to grab
						url: xhrURL,

						// Called when the page loaded successfully
						load: function (data) {

						},
						sync: true,
						// Called if there was an error (such as a 404 response)
						error: function (data) {
							console.error('Error: ', data);
						}
					});

										var xpyURL = domainString+'/PaymentApp/js/CCMgmtApp-Include.jsp';
				//END:Forming the Calling URL
					dojo.xhrGet ({

						// Location of the HTML content we want to grab
						url: xpyURL,

						// Called when the page loaded successfully
						load: function (data) {

						},
						sync: true,
						// Called if there was an error (such as a 404 response)
						error: function (data) {
							console.error('Error: ', data);
						}
					});


				}
				//END:LOAD The SignUpApp-Include.jsp
				//START:Calling The JSON-RPC
				//Start:Forming the Calling URL
				var proto = "http:";
				if(window.top.location.protocol == "https:"){
					proto = "https:";
				}

				var domainString ='';
				if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
				{
					domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

				}else
				{
					domainString = proto + '//'+document.domain;
					jsonurl = domainString + '/SignUpApp/JSON-RPC';
					jsonpaymenturl = domainString + '/PaymentApp/JSON-RPC';
					//End:Forming the Calling URL
					jsonrpc = null;
					jsonpaymentrpc = null;
					//Initializing JSONRpcClient
					try
					{
						//alert('AAAAAAAAAAAA---->'+jsonpaymenturl);
						jsonrpc = new JSONRpcClient(jsonurl);

						jsonpaymentrpc = new JSONRpcClient(jsonpaymenturl);

						//alert('BBBBBBBBBBBB---->'+jsonpaymentrpc.ccMgmt);
					}
					catch(e)
					{
					  //In case of Error Show Error Page
					  window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
					  error = true;
					}
				}



				//END:Calling The JSON-RPC
//***************************************** STYART:AGAINCALLING JSON *******************************************************************
				var inputAccountObject ={
					 "createAccountBillingFirstName": createAccountBillingFirstName,
		             "createAccountBillingLastName": createAccountBillingLastName,
					 "accountFirstName": accountFirstName,
					 "accountLastName":accountLastName,
					 "accountEmailAddress":accountEmailAddress,
					 "accountPassword": accountPassword,
					 "accountConfirmPassword":accountConfirmPassword,
					 "accountCompanySize":accountCompanySize,
					 "accountLocation": accountLocation,
					 "accountBilladdress":accountBilladdress,
					 "accountCity":accountCity,
					 "accountState": accountState,
					 "accountZipcode": accountZipcode,
					 "accountCountry":accountCountry,
					 "accountTelephone":accountTelephone,
					 "accountCreditCard": accountCreditCard,
					 "accountCreditCardNumber":accountCreditCardNumber,
					 "accountExpirationMonth":accountExpirationMonth,
					 "accountExpirationYear": accountExpirationYear,
					 "accountSecurityCode":accountSecurityCode,
					 "ui_flex_initialTermID":ui_flex_initialTermID,
					 "ui_flex_renewalTermID":ui_flex_renewalTermID,
					 "resellerId":resellerId,
					 "channelId":channelId,
					 "orderTotal":orderTotal,
					 "partyID":partyID,
					 "partyName":partyName,
					 "partyUrl":partyUrl,
					 "mrr":mrr,
					 "employeeNumber":employeeNumber,
					 "annualRevenue":annualRevenue,
					 "timeZone":timeZone,
					 "trialType":trialType,
					 "ui_flex_channelID":ui_flex_channelID,
					 "ui_flex_offercodeID_bynode":ui_flex_offercodeID_bynode,
					 "ui_flex_promotioncodeID_bynode":ui_flex_promotioncodeID_bynode,
					 "nowServiceType":nowServiceType,
					 "trialDay":trialDay,
					 "ui_flex_pcsID":ui_flex_pcsID,
					 "ui_flex_isfreetrialID":ui_flex_isfreetrialID,
					 "sessionToken":wbx_jsessionid,
					 "ui_wbx_semiuser":ui_wbx_semiuser,
					"account_semiuser_accountid":account_semiuser_accountid,
					"ui_flex_tracklID":ui_flex_tracklID,
					"wbx_flex_offerdesc":wbx_flex_offerdesc
				};

	CCNumber = accountCreditCardNumber;
	termId = ui_flex_initialTermID;
	renewalId = ui_flex_renewalTermID;
	offerDesc = wbx_flex_offerdesc;

							//////////alert("sessionToken  "+wbx_jsessionid);
			    var inputAccountObjectJSON = JSON.stringify(inputAccountObject);
document.getElementById('signUpCommonErrors').innerHTML = "";
document.getElementById('signUpProcessOrderCommonErrors').innerHTML = "";
document.getElementById('signUpProcessOrderOptInCommonErrors').innerHTML = "";
document.getElementById('signUpUpdateCreditErrors').innerHTML = "";
if (jsonrpc != null)
 {
	 if (jsonrpc.signUp != null)
	 {
			var validateCCResultErrors = "";
			try{
				validateCCResultErrors = jsonrpc.signUp.validateCC(inputAccountObjectJSON);
				validateCCResultErrors = validateCCResultErrors.list;
				var signUpCommonErrors = document.getElementById('signUpCommonErrors');
				for(var i=0; i<validateCCResultErrors.length; i++)
				{
					if (validateCCResultErrors[i] != null)
					{
						var existingValue = document.getElementById('signUpCommonErrors').innerHTML;
						if(validateCCResultErrors[i] == "TIMEOUT_VALIDATECC")
						{
							window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
							error = true;
						}
						//if errors have USR in it, then don't do AFTER BUY else do AFTER BUY call and redirect to error page
						var pos=validateCCResultErrors[i].indexOf("USR");
						if (pos>=0)
						{
							if (errorCodes.get(validateCCResultErrors[i]) != null)
							{
								document.getElementById('signUpCommonErrors').innerHTML = existingValue + "<br><li> " + errorCodes.get(validateCCResultErrors[i]);
								error = true;
							}
							else
							{
								window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
								error = true;
							}
						}
						else
						{
							window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
							error = true;
						}
					}
				} //end of validateCCResultErrors.length for loop
				if(validateCCResultErrors.length>0)
				{
					//ValidateCC has noErros...
				}
				else
				{
				////////////////////////////////////////////////////////////////
				///Updatating CC if it is a SEMI USER
				// Start by Ramesh 03/09/09
				//alert('wbx_semiuser:::::'+wbx_semiuser);
				if(wbx_semiuser == "true"){
					//alert('Trying to Update wbx_semiuser');
				    var editCCResult = {
						 "applicationName":"NOW",
						 "fname": accountFirstName,
						 "bAddr":accountBilladdress,
						 "city":accountCity,
						 "state":accountState,
						 "zCode":accountZipcode,
						 "country":accountCountry,
						 "cType":accountCreditCard,
						 "cNo": accountCreditCardNumber,
						 "expMon": accountExpirationMonth,
						 "expYr": accountExpirationYear,
						 "cid": accountSecurityCode,
						// "ccPoId" :	ccPoId,
						 "acctPoId"	: account_semiuser_accountid,
						 "sessionUserId" : accountEmailAddress,
						 "sessionToken": wbx_jsessionid,
						 "applicationContext": "creditCard",
					     "userElementId": userElementId // this will be set in the artemisCreditCard.jsp
					};
					var editCCResultJSON = JSON.stringify(editCCResult);

					//alert("Debug Message: Before calling CCEdit...This alert would be removed after testing.");
					if (jsonpaymentrpc != null){
							//alert('jsonpaymentrpc not null');
							if (jsonpaymentrpc.ccMgmt != null){
							//alert('jsonpaymentrpc.ccMgmt not null');
							var outputJSON = '';
							try{
									//alert('callig tomcat');
									outputEditJSON = jsonpaymentrpc.ccMgmt.getCCEditDetails(editCCResultJSON);
									if (outputEditJSON != null){
										//alert('Edit CC output =' + outputEditJSON);
										var jonEditData = JSON.parse(outputEditJSON);
										//alert("++++++++++jonEditData+++++++++++"+jonEditData);
										//alert("++++++++++jonEditData.errorsList+++++++++++"+jonEditData.errorsList);
										if(jonEditData.errorsList != null && jonEditData.errorsList.length > 0) {
										 if(jonEditData.brmUpdateErr == "true") {
												brmProcessUpdateError = "true";
												document.getElementById('signUpUpdateCreditErrors').innerHTML = "Credit card information is invalid. Please check and correct.";
												error = true;
											}
									}
									else
									{
											brmProcessUpdateError = "false";
									}


									//alert('outputEditJSON       '+outputEditJSON);
									// alert("output from Edit ccmgmt" + outputEditJSON);
								}

							}catch(e){
								brmProcessUpdateError = "true";
								document.getElementById("status").innerHTML = e;
								//alert('error updating Credit card..returning');
								return;

								// alert('error calling tomcat');
								// alert('exception ='  + e);
							}
					}
				}
				}
				//End by Ramesh 03/09/09
				////////////////////////////////////////////////////////////////
				if (brmProcessUpdateError == "false")
				{
				/////////////////////////////////////////////////////////////////////////////////////////////////
					if (jsonrpc != null)
					 {
						 if (jsonrpc.signUp != null)
						 {
							try{
									var buyOnlineResult = "";
									buyOnlineResult = jsonrpc.signUp.processOrderSignUp(inputAccountObjectJSON);
									var orderId = buyOnlineResult.orderId;
									var wid = buyOnlineResult.wid;
									var nowSiteUrl = buyOnlineResult.nowSiteUrl;
									if (orderId != null)
									{
										SetCookie("MDWBXId",wid,1);
										SetCookie("MDSiteURL",nowSiteUrl,1);
										SetCookie("MDPWD", encodeBase64(accountPassword), 1);
										SetCookie ('wbx_jsessionid', wbx_jsessionid, 1);
										SetCookie ('MDEMAILID',encodeBase64(accountEmailAddress), 1);
										SetCookie ('MDFRISTNAME', accountFirstName, 1);
										SetCookie ('MDLASTNAME', accountLastName, 1);
									}
									var accountId = buyOnlineResult.accountId;
									var subscriptionCode = buyOnlineResult.subscriptionCode;
									var orderConfirmationNumber = buyOnlineResult.orderConfirmationNumber;
									var processordererrors = buyOnlineResult.errors;
									processordererrors = processordererrors.list;
									var signUpProcessOrderCommonErrors = document.getElementById('signUpProcessOrderCommonErrors');
									for(var i=0; i<processordererrors.length; i++)
									{
										if (processordererrors[i] != null)
										{
											var existingValue = document.getElementById('signUpProcessOrderCommonErrors').innerHTML;
											if(processordererrors[i] == "PROCESS_ORDER_TIMEOUT")
											{
												window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
												error = true;
											}
											//if errors have USR in it, then don't do AFTER BUY else do AFTER BUY call and redirect to error page
											var pos=processordererrors[i].indexOf("USR");
											if (pos>=0)
											{
												//alert("inside processorder processordererrors"+processordererrors);
												if (errorCodes.get(processordererrors[i]) != null)
												{
													//alert("inside process order errorcodes"+errorCodes.get(processordererrors[i]));
													document.getElementById('signUpProcessOrderCommonErrors').innerHTML = existingValue + "<br><li> " + errorCodes.get(processordererrors[i]);
													error = true;
												}
												else
												{
													window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
													error = true;
												}
											}
											else
											{
												window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
												error = true;
											}
										}
									} //end of ProcessOrderErrors.length for loop
									if(optInFlag == "optIn")
									{
										if(processordererrors.length<=0)
										{
												///////////////////
												if ((accountLocation != null) && (accountLocation == "USD"))
												{
														//alert("######inside USD fucntion#######"+accountLocation);
														var orderTotal = wbx_flex_rollover_ordertotalUS;
														var mrr = wbx_flex_rollover_mrrUS;
														//alert("+++++++++orderTotal++++++++"+orderTotal);
														//alert("+++++++++mrr++++++++"+mrr);

												}
												if ((accountLocation != null) && (accountLocation == "GBP"))
												{
														var orderTotal = wbx_flex_rollover_ordertotalGB;
														var mrr = wbx_flex_rollover_mrrGB;
												}
												if ((accountLocation != null) && (accountLocation == "EUR"))
												{
														var orderTotal = wbx_flex_rollover_ordertotalEUR;
														var mrr = wbx_flex_rollover_mrrEUR;
												}


												///////////////////
												var ui_flex_offercodeID_bynode = wbx_flex_rolloveroffercode_bynode;
												var ui_flex_promotioncodeID_bynode = wbx_flex_rolloverpromocode_bynode;
												var trialDay = "0";
												var accountId = buyOnlineResult.accountId;
												var subscriptionCode = buyOnlineResult.subscriptionCode;
												var inputAccountObject ={
													    "createAccountBillingFirstName": createAccountBillingFirstName,
														"createAccountBillingLastName": createAccountBillingLastName,
														 "accountFirstName": accountFirstName,
														 "accountLastName":accountLastName,
														 "accountEmailAddress":accountEmailAddress,
														 "accountPassword": accountPassword,
														 "accountConfirmPassword":accountConfirmPassword,
														 "accountLocation": accountLocation,
														 "accountBilladdress":accountBilladdress,
														 "accountCity":accountCity,
														 "accountState": accountState,
														 "accountZipcode": accountZipcode,
														 "accountCountry":accountCountry,
														 "accountTelephone":accountTelephone,
														 "accountCreditCard": accountCreditCard,
														 "accountCreditCardNumber":accountCreditCardNumber,
														 "accountExpirationMonth":accountExpirationMonth,
														 "accountExpirationYear": accountExpirationYear,
														 "accountSecurityCode":accountSecurityCode,
														 "ui_flex_initialTermID":ui_flex_initialTermID,
														 "ui_flex_renewalTermID":ui_flex_renewalTermID,
														 "accountId":accountId,
														 "subscriptionCode":subscriptionCode,
														 "resellerId":resellerId,
														 "channelId":channelId,
														 "orderTotal":orderTotal,
														 "partyID":partyID,
														 "partyName":partyName,
														 "partyUrl":partyUrl,
														 "mrr":mrr,
														 "employeeNumber":employeeNumber,
														 "annualRevenue":annualRevenue,
														 "timeZone":timeZone,
														 "trialType":trialType,
														 "ui_flex_channelID":ui_flex_channelID,
														 "ui_flex_offercodeID_bynode":ui_flex_offercodeID_bynode,
														 "ui_flex_promotioncodeID_bynode":ui_flex_promotioncodeID_bynode,
														 "nowServiceType":nowServiceType,
														 "trialDay":trialDay,
														 "ui_flex_pcsID":ui_flex_pcsID
													};
												  var inputAccountObjectJSON = JSON.stringify(inputAccountObject);
												  buyOnlineResult = jsonrpc.signUp.processOrderSignUpOptIn(inputAccountObjectJSON);
 												  var orderId = buyOnlineResult.orderId;
												var processOrderOptIndErrors = buyOnlineResult.errors;
												processOptInErrors = processOrderOptIndErrors.list;
												var signUpProcessOrderOptInCommonErrors = document.getElementById('signUpProcessOrderOptInCommonErrors');
												for(var i=0; i<processOptInErrors.length; i++)
												{
													if (processOptInErrors[i] != null)
													{
														var existingValue = document.getElementById('signUpProcessOrderOptInCommonErrors').innerHTML;
														if(processOptInErrors[i] == "PROCESS_ORDER_TIMEOUT")
														{
															window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
															error = true;
														}
														//if errors have USR in it, then don't do AFTER BUY else do AFTER BUY call and redirect to error page
														var pos=processOptInErrors[i].indexOf("APP");
														if (pos>=0)
														{
															if (errorCodes.get(processOptInErrors[i]) != null)
															{
																//////////alert("inside process order exception end5"+errorCodes.get(processOptInErrors[i]));
																document.getElementById('signUpProcessOrderOptInCommonErrors').innerHTML = existingValue + "<br><li> " + errorCodes.get(processOptInErrors[i]);
																error = true;
															}
															else
															{
																window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
																error = true;
															}
														}
														else
														{
															window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
															error = true;
														}
													}
												} //end of ProcessOrderOptInErrors.length for loop
										}
									}
								}catch(e){
									////////////////alert ('exception ='  + e);
								}
						 }
					 }
				//////////////////////////////////////////////////////////
				}
				//////////////////////////////////////////////////////////
				}
			}catch(e){
				////////////////////alert ('exception ='  + e);
			}
	 }
 }
        }
    }
		else if (step == 4)
	{
        if (!error)
        {
				var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID').value;
				if(wbx_semiuser == "true" && (!wbx_semiSiteUrl==null || !wbx_semiSiteUrl == ''))
				{
					////////alert("######inside SemiUserWithOutCC fucntion#######");
				//Start:Archana(keep step 1 value for billing contact)
					createAccountBillingFirstName = wbx_semifFirstName;
					createAccountBillingLastName = wbx_semiLastName;
				//End:
					accountFirstName = wbx_semifFirstName;
					accountLastName = wbx_semiLastName;
					accountEmailAddress = wbx_semiEmailAddress;
					accountLocation = wbx_semiCurrency;
					account_semiuser_accountid = wbx_semiindividualId;
					////////alert("#################account_semiuseraccount_id SemiUserWithOutCC##################"+account_semiuser_accountid);
					accountPassword =  getCookie('SEMISIGNUPASSWORD');
					accountConfirmPassword = getCookie('SEMISIGNUPASSWORD');

					if (document.getElementById ("signup_step2_state")){
					  if ((accountLocation != null) && (accountLocation == "USD") )
					  {
					   document.getElementById ("signup_step2_state").innerHTML = "State:";
					  }else {
					   document.getElementById ("signup_step2_state").innerHTML = "County:";
					  }
					}

					if ((accountLocation != null) && (accountLocation == "USD"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside SemiSemiUserWithOutCC USD fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDUS').value;
							var mrr = document.getElementById('mrrIDUS').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside SemiSemiUserWithOutCC USD FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
					if ((accountLocation != null) && (accountLocation == "GBP"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside SemiSemiUserWithOutCC GBP fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDGB').value;
							var mrr = document.getElementById('mrrIDGB').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside SemiSemiUserWithOutCC GBP FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
					if ((accountLocation != null) && (accountLocation == "EUR"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside SemiSemiUserWithOutCC EUR fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDEUR').value;
							var mrr = document.getElementById('mrrIDEUR').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside SemiSemiUserWithOutCC EUR FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
				}
				else
				{
					if(wbx_semiuser == "true" && (wbx_semiSiteUrl==null ||  wbx_semiSiteUrl== ''))
					{
						account_semiuser_accountid = wbx_semiindividualId;
						//alert("#################account_semiuseraccount_id##################"+account_semiuser_accountid);
					}
				accountFirstName = document.getElementById('accountFirstName').value;
				accountLastName = document.getElementById('accountLastName').value;
				accountEmailAddress = document.getElementById('accountEmailAddress').value;
				accountEmailAddress = accountEmailAddress.toLowerCase();
				accountPassword = document.getElementById('accountPassword').value;
				accountConfirmPassword = document.getElementById('accountConfirmPassword').value;
				accountLocation = document.getElementById('accountLocation').value;
				//Start:Archana:Billing Contact Step1 value
					var createAccountBillingFirstName = document.getElementById('createAccountBillingFirstName').value;
					var createAccountBillingLastName = document.getElementById('createAccountBillingLastName').value;
				 //End

				if (document.getElementById ("signup_step2_state")){
				  if ((accountLocation != null) && (accountLocation == "USD") )
				  {
					   document.getElementById ("signup_step2_state").innerHTML = "State:";
				  }else {
					   document.getElementById ("signup_step2_state").innerHTML = "County:";
				  }
				}

					if ((accountLocation != null) && (accountLocation == "USD"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside USD fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDUS').value;
							var mrr = document.getElementById('mrrIDUS').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside USD FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
					if ((accountLocation != null) && (accountLocation == "GBP"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside GBP fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDGB').value;
							var mrr = document.getElementById('mrrIDGB').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside GBP FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
					if ((accountLocation != null) && (accountLocation == "EUR"))
					{
						if(ui_flex_isfreetrialID == "false")
						{
							////////alert("######inside EUR fucntion#######"+accountLocation);
							var orderTotal = document.getElementById('orderTotalIDEUR').value;
							var mrr = document.getElementById('mrrIDEUR').value;
							////////alert("######orderTotal#####"+orderTotal);
							////////alert("######mrr#####"+mrr);
						}
						else
						{
							////////alert("######inside EUR FreeTrail fucntion#######");
							var orderTotal = document.getElementById('orderTotalID').value;
							var mrr = document.getElementById('mrrID').value;
						}
					}
				}
				DeleteCookie( 'SEMISIGNUPASSWORD' );
				/********************************************************************************/
				var ui_flex_channelID = document.getElementById('ui_flex_channelID').value;
				var ui_flex_isfreetrialID = document.getElementById('ui_flex_isfreetrialID').value;
				var ui_flex_initialTermID = document.getElementById('ui_flex_initialTermID').value;
				var ui_flex_renewalTermID = document.getElementById('ui_flex_renewalTermID').value;
				var ui_flex_offercodeID = document.getElementById('ui_flex_offercodeID').value;
				var ui_flex_promotioncodeID = document.getElementById('ui_flex_promotioncodeID').value;
				var ui_flex_offercodeID_bynode = document.getElementById('ui_flex_offercodeID_bynode').value;
				var ui_flex_promotioncodeID_bynode = document.getElementById('ui_flex_promotioncodeID_bynode').value;

				var resellerId = document.getElementById('resellerId').value;
				var channelId = document.getElementById('channelId').value;
				//var orderTotal = document.getElementById('orderTotalID').value;
				var partyID = document.getElementById('partyID').value;
				var partyName = document.getElementById('partyName').value;
				var partyUrl = document.getElementById('partyUrl').value;
				//var mrr = document.getElementById('mrrID').value;
				var employeeNumber = document.getElementById('employeeNumber').value;
				var annualRevenue = document.getElementById('annualRevenue').value;
				var timeZone = document.getElementById('timeZone').value;
				timeZoneEdit = timeZone;
				var trialType = document.getElementById('trialTypeID').value;
				var nowServiceType = document.getElementById('NowServiceType').value;
				var trialDay = document.getElementById('trialDay').value;
				var ccHideID = document.getElementById('ccHideID').value;
				var ui_flex_pcsID = document.getElementById('ui_flex_pcsID').value;
				var ui_flex_tracklID = document.getElementById('ui_flex_tracklID').value;
				ui_wbx_semiuser = wbxSemiUser;
				////////alert("################ui_wbx_semiuserwithoutCC###############"+ui_wbx_semiuser);
				/********************************************************************************/
				//START:LOAD The InvoiceApp-Include.jsp
				//Start:Forming the Calling URL
				var proto = "http:";
				if(window.top.location.protocol == "https:"){
					proto = "https:";
				}
				var domainString ='';
				if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
				{
					domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

				}else
				{
					domainString = proto + '//'+document.domain;
					var xhrURL = domainString+'/SignUpApp/js/SignUpApp-Include.jsp';
					//END:Forming the Calling URL
						dojo.xhrGet ({
							// Location of the HTML content we want to grab
							url: xhrURL,
							// Called when the page loaded successfully
							load: function (data) {
							},
							sync: true,
							// Called if there was an error (such as a 404 response)
							error: function (data) {
								console.error('Error: ', data);
							}
						});
					}
				//END:LOAD The SignUpApp-Include.jsp
				//START:Calling The JSON-RPC
				//Start:Forming the Calling URL
				var proto = "http:";
				if(window.top.location.protocol == "https:"){
					proto = "https:";
				}
				var domainString ='';
				if(document.domain.indexOf('sjwbpr574') != -1 || document.domain.indexOf('sjwbpr575') != -1 || document.domain.indexOf('wcm') != -1)
				{
					domainString = 'http://'+document.domain+':7005/wp/object-download-by-path-prefix/ComponentApp';

				}else
				{
					domainString = proto + '//'+document.domain;
					jsonurl = domainString + '/SignUpApp/JSON-RPC';
				//End:Forming the Calling URL

					jsonrpc = null;
					//Initializing JSONRpcClient
					try
					{
						jsonrpc = new JSONRpcClient(jsonurl);
					}
					catch(e)
					{
					  //In case of Error Show Error Page
					  window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
					  error = true;
					}
				}
				//END:Calling The JSON-RPC
				var inputAccountObject ={
					 "createAccountBillingFirstName": createAccountBillingFirstName,
					 "createAccountBillingLastName": createAccountBillingLastName,
					 "accountFirstName": accountFirstName,
					 "accountLastName":accountLastName,
					 "accountEmailAddress":accountEmailAddress,
					 "accountPassword": accountPassword,
					 "accountConfirmPassword":accountConfirmPassword,
					 "accountCompanySize":accountCompanySize,
					 "accountLocation": accountLocation,
					 "ui_flex_initialTermID":ui_flex_initialTermID,
					 "ui_flex_renewalTermID":ui_flex_renewalTermID,
					 "resellerId":resellerId,
					 "channelId":channelId,
					 "orderTotal":orderTotal,
					 "partyID":partyID,
					 "partyName":partyName,
					 "partyUrl":partyUrl,
					 "mrr":mrr,
					 "employeeNumber":employeeNumber,
					 "annualRevenue":annualRevenue,
					 "timeZone":timeZone,
					 "trialType":trialType,
					 "ui_flex_channelID":ui_flex_channelID,
					 "ui_flex_offercodeID_bynode":ui_flex_offercodeID_bynode,
					 "ui_flex_promotioncodeID_bynode":ui_flex_promotioncodeID_bynode,
					 "nowServiceType":nowServiceType,
					 "trialDay":trialDay,
					 "ccHideID":ccHideID,
					 "ui_flex_pcsID":ui_flex_pcsID,
					 "ui_flex_isfreetrialID":ui_flex_isfreetrialID,
					 "sessionToken":wbx_jsessionid,
					 "ui_wbx_semiuser":ui_wbx_semiuser,
					 "account_semiuser_accountid":account_semiuser_accountid,
					 "ui_flex_tracklID":ui_flex_tracklID
				};

				CCNumber = "";
				termId = ui_flex_initialTermID;
				renewalId = ui_flex_renewalTermID;
				offerDesc = "";

				var inputAccountObjectJSON = JSON.stringify(inputAccountObject);
				//START:CALLING GETINVOICE JSON
				document.getElementById('signUpCreditCommonErrors').innerHTML = "";
				var validateCCResultErrors = "";
				if (jsonrpc != null)
				 {
					 if (jsonrpc.signUp != null)
					 {
						try{
								var buyOnlineResult = "";
								buyOnlineResult = jsonrpc.signUp.processOrderWithoutCCSignUp(inputAccountObjectJSON);
								var orderId = buyOnlineResult.orderId;
								if (orderId != null)
								{
									step == 2;
								}
								if (orderId == null)
								{
									step == 2;
								}
								var wid = buyOnlineResult.wid;
								var nowSiteUrl = buyOnlineResult.nowSiteUrl;
								if (orderId != null)
								{
									SetCookie("MDWBXId",wid,1);
									SetCookie("MDSiteURL",nowSiteUrl,1);
									SetCookie("MDPWD", encodeBase64(accountPassword), 1);
									SetCookie ('wbx_jsessionid', wbx_jsessionid, 1);
									SetCookie ('MDEMAILID', encodeBase64(accountEmailAddress), 1);
									SetCookie ('MDFRISTNAME', accountFirstName, 1);
									SetCookie ('MDLASTNAME', accountLastName, 1);
								}
								var accountId = buyOnlineResult.accountId;
								var subscriptionCode = buyOnlineResult.subscriptionCode;
								var orderConfirmationNumber = buyOnlineResult.orderConfirmationNumber;
								var processordererrors = buyOnlineResult.errors;
								processordererrors = processordererrors.list;
								var signUpCreditCommonErrors = document.getElementById('signUpCreditCommonErrors');
								for(var i=0; i<processordererrors.length; i++)
								{
									if (processordererrors[i] != null)
									{
										var existingValue = document.getElementById('signUpCreditCommonErrors').innerHTML;
										if(processordererrors[i] == "TIMEOUT_PROCESS_ORDER")
										{
											window.location = 'BuyMeetingPlusError.html';
										}
										//if errors have USR in it, then don't do AFTER BUY else do AFTER BUY call and redirect to error page
										var pos=processordererrors[i].indexOf("USR");
										if (pos>=0)
										{
											//alert("inside processorder processordererrors"+processordererrors);
											if (errorCodes.get(processordererrors[i]) != null)
											{
												//alert("inside process order errorcodes"+errorCodes.get(processordererrors[i]));
												document.getElementById('signUpCreditCommonErrors').innerHTML = existingValue + "<br><li> " + errorCodes.get(processordererrors[i]);
												error = true;
											}
											else
											{
												window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
												error = true;
											}
										}
										else
										{
											window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
											error = true;
										}
									}
								} //end of ProcessOrderErrors.length for loop
						}catch(e){
							//////////////////alert ('exception ='  + e);
						}
				}
			}
        }
	}
    if (error == false)
    {
        step++;
        tabSwitch(step);
    }
	if (step > numSteps)
	{

	} //end of if (step > numSteps)

    document.getElementById ('EnabledNextLinkStep1').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep1').style.display = 'none';
    document.getElementById ('EnabledNextLinkStep2').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep2').style.display = 'none';
	document.getElementById ('EnabledNextLinkStep2Cancel').style.display = 'block';
	document.getElementById ('DisabledNextLinkStep2Cancel').style.display = 'none';

	return false;
}

function cancelStep()
{
	step = 4;
	tabSwitch(step);
}

function backTo(returnStep)
{
	if (returnStep >= step)
	{
		// Trying to advance a step, or step is the same
		return false;
	}
	tabSwitch(returnStep);
}

function tabSwitch(newStep)
{
	if (newStep == 0)
	{
		if(wbx_semiuser == "true" && (!wbx_semiSiteUrl==null || !wbx_semiSiteUrl == ''))
		{
			document.getElementById('accountFirstName').value = wbx_semifFirstName;
			document.getElementById('accountLastName').value = wbx_semiLastName;
			document.getElementById ('signup_step2_content_middle_Subscribe_Curr').innerHTML = getCurrCharFromDesc(wbx_semiCurrency);

			if (document.getElementById ("signup_step2_state")){
			 // if ((createAccountLocation != null) && (createAccountLocation == "USD") ) //createAccountLocation value is no more getting the Currency information
			if ((wbx_semiCurrency != null) && (wbx_semiCurrency == "USD") )
			  {
			   document.getElementById ("signup_step2_state").innerHTML = "State:";
			  }else {
			   document.getElementById ("signup_step2_state").innerHTML = "County:";
			  }
			}

		}
		if(wbx_flex_skippcc == "true" && (!wbx_flex_skippcc==null || !wbx_flex_skippcc == ''))
		{
				contenta.style.display = 'none';
				contentb.style.display = 'none';
				contentc.style.display = 'none';
				contentd.style.display = 'block';
				step = 4;
				// to call omniture stuff
				//pgname="optionalStep2";
				//pageView(pgname);
		}
		else
		{
			contenta.style.display = 'none';
			contentb.style.display = 'block';
			contentc.style.display = 'none';
			contentd.style.display = 'none';
			step = 2;
			pgname="step2";
			pageView(pgname);
		}
	}
	if (newStep == 1)
	{
		contenta.style.display = 'block';
		contentb.style.display = 'none';
		contentc.style.display = 'none';
		contentd.style.display = 'none';
        document.getElementById("createAccountFirstName").focus();

		step = 1;
	}
	else if (newStep == 2)
	{
		if(wbx_flex_skippcc == "true" && (!wbx_flex_skippcc==null || !wbx_flex_skippcc == ''))
		{
			//Start:Archana:keep the step1 value for billing contact
			document.getElementById('createAccountBillingFirstName').value = createAccountFirstName;
			document.getElementById('createAccountBillingLastName').value = createAccountLastName;
			//End:
			document.getElementById('accountFirstName').value = createAccountFirstName;
			document.getElementById('accountLastName').value = createAccountLastName;
			document.getElementById('accountEmailAddress').value = createAccountEmailaddress;
			document.getElementById('accountPassword').value = createAccountPassword;
			document.getElementById('accountConfirmPassword').value = createAccountConfirmPassword;
			document.getElementById('accountCompanyName').value = createAccountCompanyName;
			document.getElementById('accountCompanySize').value = createAccountCompanySize;
			document.getElementById('accountLocation').value = createAccountLocation;
			contenta.style.display = 'none';
			contentb.style.display = 'none';
			contentc.style.display = 'none';
			contentd.style.display = 'block';
			step = 4;
			// to call omniture stuff
			pgname="optionalStep2";
			pageView(pgname);
		}
		else
		{
			if(optInFlag == "optIn")
			{
				document.getElementById ('cancelInBox').style.display = 'none';
			}
			if(optInFlag == "optOut")
			{
				document.getElementById ('cancelInBox').style.display = 'block';
			}
			//Start:Archana:keep the step1 value for billing contact
			document.getElementById('createAccountBillingFirstName').value = createAccountFirstName;
			document.getElementById('createAccountBillingLastName').value = createAccountLastName;
			//End:
			document.getElementById('accountFirstName').value = createAccountFirstName;
			document.getElementById('accountLastName').value = createAccountLastName;
			document.getElementById('accountEmailAddress').value = createAccountEmailaddress;
			document.getElementById('accountPassword').value = createAccountPassword;
			document.getElementById('accountConfirmPassword').value = createAccountConfirmPassword;
			document.getElementById('accountCompanyName').value = createAccountCompanyName;
			document.getElementById('accountCompanySize').value = createAccountCompanySize;
			document.getElementById('accountLocation').value = createAccountLocation;
			contenta.style.display = 'none';
			contentb.style.display = 'block';
			contentc.style.display = 'none';
			contentd.style.display = 'none';
			//add below line to putthe cursor in proper place
			document.getElementById("accountBilladdress").focus();
			if (document.getElementById ("signup_step2_state")){
			  if ((createAccountLocation != null) && (createAccountLocation == "USD") )
			  {
			   document.getElementById ("signup_step2_state").innerHTML = "State:";
			  }else {
			   document.getElementById ("signup_step2_state").innerHTML = "County:";
			  }
			}
			step = 2;
			//pageView(tabbName); NOT REQUIRED FOR NOW PROJECT

			// to call omniture stuff
			pgname="step2";
			pageView(pgname);
		}
	}
	else if (newStep == 3)
	{
		//Strat:Archana:display the step1 value instead of step2
		if(wbx_semiuser == "true" && (!wbx_semiSiteUrl==null || !wbx_semiSiteUrl == ''))
		{

			document.getElementById('accountConfirmationFirstName').innerHTML = wbx_semifFirstName;
			document.getElementById('accountConfirmationLastName').innerHTML = wbx_semiLastName;
        }

		else
		{
		//document.getElementById('accountConfirmationFirstName').innerHTML = accountFirstName;
		//document.getElementById('accountConfirmationLastName').innerHTML = accountLastName;
		document.getElementById('accountConfirmationFirstName').innerHTML = createAccountFirstName;
		document.getElementById('accountConfirmationLastName').innerHTML = createAccountLastName;
		}
		//End:
		document.getElementById('accountConfirmationEmailAddress').innerHTML = accountEmailAddress;
		contenta.style.display = 'none';
		contentb.style.display = 'none';
		contentc.style.display = 'block';
		contentd.style.display = 'none';
		step = 3;
		//pageView(tabcName); NOT REQUIRED FOR NOW PROJECT
		// to call omniture stuff
		pgname="step3";
		pageView(pgname);
	}
	else if (newStep == 4)
	{
		contenta.style.display = 'none';
		contentb.style.display = 'none';
		contentc.style.display = 'none';
		contentd.style.display = 'block';
		step = 4;
//		pageView(tabdName); NOT REQUIRED FOR NOW PROJECT

		// to call omniture stuff
		pgname="optionalStep2";
		pageView(pgname);
	}
	else if (newStep == 5)
	{
		//////////alert("inside tabswitch step5");
		document.getElementById('accountConfirmationFirstName').innerHTML = accountFirstName;
		document.getElementById('accountConfirmationLastName').innerHTML = accountLastName;
		document.getElementById('accountConfirmationEmailAddress').innerHTML = accountEmailAddress;
		contenta.style.display = 'none';
		contentb.style.display = 'none';
		contentc.style.display = 'block';
		contentd.style.display = 'none';
		step = 5;
//		pageView(tabdName); NOT REQUIRED FOR NOW PROJECT

		// to call omniture stuff
		pgname="step3";
		pageView(pgname);
	}
	else
	{
		return false;
//		pageView("InvalidStep"); NOT REQUIRED FOR NOW PROJECT
	}
	window.top.scrollTo(0,0);
}
function validateStep3(error)
{
		return error;
}
function validateStep1(error)
{
		//alert("+++++++++++++++++++++++isnide PCNow validateStep1++++++++++++++++++");
		var error = false;
		var agreeCheckBox = document.getElementById('agree');
		if(!agreeCheckBox.checked)
		{
			alert("You must agree to the Terms of Service by checking the box.");
			return true;
		}
		var createAccountFirstNameError = document.getElementById('createAccountFirstNameError');
		var createAccountLastNameError = document.getElementById('createAccountLastNameError');
		var createAccountEmailaddressError = document.getElementById('createAccountEmailaddressError');
		var createAccountPasswordError = document.getElementById('createAccountPasswordError');
		var createAccountConfirmPasswordError = document.getElementById('createAccountConfirmPasswordError');
		var createAccountFirstNameField = document.getElementById('createAccountFirstName').value;
		var createAccountLastNameField = document.getElementById('createAccountLastName').value;
		//var createAccountEmailaddressField = document.getElementById('createAccountEmailaddress').value;
		var createAccountEmailaddressField = '';
		if(wbx_semiuser == "true")
		{
			createAccountEmailaddressField = document.getElementById('createSemiAccountEmailaddress').value;
		}else{
			createAccountEmailaddressField = document.getElementById('createAccountEmailaddress').value;
		}

		//alert("+++++++++++++++++++++++isnide PCNow validateStep1++++++++++++++++++"+createAccountEmailaddressField);
		var createAccountPasswordField = document.getElementById('createAccountPassword').value;
		var createAccountConfirmPasswordField = document.getElementById('createAccountConfirmPassword').value;
		createAccountFirstNameField = trimStrings(createAccountFirstNameField,"createAccountFirstName");
		createAccountLastNameField = trimStrings(createAccountLastNameField,"createAccountLastName");
		createAccountEmailaddressField = trimStrings(createAccountEmailaddressField,"createAccountEmailaddress");
		error |= emptyFieldCheck(createAccountFirstNameField,arrError[10],createAccountFirstNameError);
		error |= emptyFieldCheck(createAccountLastNameField,arrError[11],createAccountLastNameError);
		error |= emptyFieldCheck(createAccountEmailaddressField,arrError[12],createAccountEmailaddressError);
		error |= emptyFieldCheck(createAccountPasswordField,arrError[13],createAccountPasswordError);
		error |= emptyFieldCheck(createAccountConfirmPasswordField,arrError[14],createAccountConfirmPasswordError);
		//error |= emptyFieldCheck(createAccountCompanySizeField,arrError[53],createAccountCompanySizeError);

		//Start:Archana - validate the name fields
		error |= validateName(createAccountFirstNameField,arrError[58],createAccountFirstNameError);
		error |= validateName(createAccountLastNameField,arrError[59],createAccountLastNameError);
		//End:

		//Check validation for email,reemail…

		error |= validateEmail(createAccountEmailaddressField,arrError[5],arrError[30],createAccountEmailaddressError);
		//error |= validatePassword(createAccountPasswordField,arrError[37],arrError[50],arrError[38],arrError[39],arrError[36],createAccountPasswordError);
		error |= validatePassword(createAccountPasswordField,arrError[39],createAccountPasswordError);
		if(validatePassword(createAccountPasswordField,arrError[39],createAccountPasswordError) == false)
		{
			error |= checkSimilar(createAccountPasswordField,createAccountConfirmPasswordField,arrError[8],createAccountConfirmPasswordError);
		}
		if (!error)
		{

		}
		else
		{
			var correctFollowingError = document.getElementById('correctFollowingError');
			var createAccountPleaseCorrectField = document.getElementById('createAccountPleaseCorrect').value;
			error |= emptyPleaseCorrectFieldCheck(createAccountPleaseCorrectField,arrError[51],correctFollowingError);
			var correctFollowingEmptyError = document.getElementById('correctFollowingEmptyError');
			var createAccountPleaseCorrectEmptyField = document.getElementById('createAccountPleaseCorrectEmpty').value;
			error |= emptyPleaseCorrectFieldCheck(createAccountPleaseCorrectEmptyField,arrError[52],correctFollowingEmptyError);
			if(agreeCheckBox.checked)
			{
				agreeCheckBox.checked = false;
			}
		}
        return error;
}

function validateStep2(error)
{
		var error = false;
		var accountFirstNameError = document.getElementById('accountFirstNameError');
		var accountLastNameError = document.getElementById('accountLastNameError');
		var accountBilladdressError = document.getElementById('accountBilladdressError');
		var accountCityError = document.getElementById('accountCityError');
		var accountStateError = document.getElementById('accountStateError');
		var accountZipcodeError = document.getElementById('accountZipcodeError');
		var accountTelephoneError = document.getElementById('accountTelephoneError');
		var accountCreditCardNumberError = document.getElementById('accountCreditCardNumberError');
		var accountSecurityCodeError = document.getElementById('accountSecurityCodeError');
		var accountFirstNameField = document.getElementById('accountFirstName').value;
		var accountLastNameField = document.getElementById('accountLastName').value;
		var accountBilladdressField = document.getElementById('accountBilladdress').value;
		var accountCityField = document.getElementById('accountCity').value;
		var accountStateField = document.getElementById('accountState').value;
		var accountZipcodeField = document.getElementById('accountZipcode').value;
		var accountTelephoneField = document.getElementById('accountTelephone').value;
		var accountCreditCardNumberField = document.getElementById('accountCreditCardNumber').value;
		var accountSecurityCodeField = document.getElementById('accountSecurityCode').value;
		error |= emptyFieldCheck(accountFirstNameField,arrError[10],accountFirstNameError);
		error |= emptyFieldCheck(accountLastNameField,arrError[11],accountLastNameError);
		error |= emptyFieldCheck(accountBilladdressField,arrError[16],accountBilladdressError);
		error |= emptyFieldCheck(accountCityField,arrError[17],accountCityError);
		error |= emptyFieldCheck(accountStateField,arrError[18],accountStateError);
		error |= emptyFieldCheck(accountZipcodeField,arrError[19],accountZipcodeError);
		error |= emptyFieldCheck(accountTelephoneField,arrError[20],accountTelephoneError);
		error |= emptyFieldCheck(accountCreditCardNumberField,arrError[21],accountCreditCardNumberError);
		error |= emptyFieldCheck(accountSecurityCodeField,arrError[23],accountSecurityCodeError);

	//START:Archana
		//trim the space for step2 field validation
		accountFirstNameField = trimStrings(accountFirstNameField,"accountFirstName");
		accountLastNameField = trimStrings(accountLastNameField,"accountLastName");
		accountBilladdressField = trimStrings(accountBilladdressField,"accountBilladdress");
		accountCityField = trimStrings(accountCityField,"accountCity");
		accountStateField = trimStrings(accountStateField,"accountState");
		accountZipcodeField = trimStrings(accountZipcodeField,"accountZipcode");
		accountTelephoneField = trimStrings(accountTelephoneField,"accountTelephone");


		error |= validateName(accountFirstNameField,arrError[58],accountFirstNameError);
		error |= validateName(accountLastNameField,arrError[59],accountLastNameError);
		error |= validateCity(accountCityField,arrError[60],accountCityError);
		//field validation follwed by production rule:Only numbers, '(', ')', '-', and '+' are allowed. No Spaces. Length 6 - 32.
		error |= validatePhoneNo(accountTelephoneField,arrError[56],accountTelephoneError);
	//End:

		if((document.getElementById('accountCountry').value =="US") || (document.getElementById('accountCountry').value =="CA"))
		{
			error |= validateUsCanadaZip(accountZipcodeField,arrError[54],accountZipcodeError);
		}
		else{
			error |= validateZip(accountZipcodeField,arrError[63],accountZipcodeError);
		}

		if((document.getElementById('accountCountry').value =="US") || (document.getElementById('accountCountry').value =="CA"))
		{
			error |= validateUsCanadaState(accountStateField,arrError[34],accountStateError);
		}
		else
			error |= validateState(accountStateField,arrError[62],accountStateError);
	//START:Archana:comented out
		/*
		if((document.getElementById('accountCountry').value =="US") || (document.getElementById('accountCountry').value =="CA"))
		{
			error |= validatePhoneUSCanada(accountTelephoneField,arrError[55],accountTelephoneError);
		}
		else
		{
			error |= validatesOCPhone(accountTelephoneField,arrError[56],accountTelephoneError);
		}
        */
		error |= validateSecurityCode(accountSecurityCodeField,arrError[44],accountSecurityCodeError);


	//Strat:To display the error message if any field error is there
		if (!error)
			{

			}
			else
			{
				var correctFollowingError = document.getElementById('correctFollowingErrorStep2');
				var createAccountPleaseCorrectField = document.getElementById('createAccountPleaseCorrectStep2').value;
				error |= emptyPleaseCorrectFieldCheck(createAccountPleaseCorrectField,arrError[51],correctFollowingError);

				var correctFollowingEmptyError = document.getElementById('correctFollowingEmptyErrorStep2');
				var createAccountPleaseCorrectEmptyField = document.getElementById('createAccountPleaseCorrectEmptyStep2').value;
				error |= emptyPleaseCorrectFieldCheck(createAccountPleaseCorrectEmptyField,arrError[52],correctFollowingEmptyError);
			}
	//End

        return error;
}
//End:ValidateCC
function validateStep4(error)
{
        return error;
}

function timeZone()
{
		var proto = "http:";
		if(window.top.location.protocol == "https:"){
			proto = "https:";
		}
		var domainString ='';
		if(document.domain.indexOf('sjpote220') != -1 || document.domain.indexOf('dctmdev') != -1 || document.domain.indexOf('wcm') != -1)
		{
			domainString = proto + '//'+document.domain+':7005/wp/object-download-by-path-prefix/BuyOnlinePlatform';
		}else
		{
			domainString = proto + '//'+document.domain;
			var howDoIResultArray = "";
			try
			 {
				jsonrpc.howDoI.getHowDoI(
				function (msg)
				{
					howDoIResultArray = msg;
					howDoIResultArray = howDoIResultArray.list;
					for(var i=0; i<howDoIResultArray.length; i++)
					{
						if (howDoIResultArray[i] != null)
						{
						}
					}
				}
				);
				//////////////////alert(howDoIResultArray);
		   }
		   catch (e)
		   {}
	}
}
function emptyFieldCheck(fieldValue,arrvalue,fieldErrorDiv)
{
	var error = false;
	var pattern = /^\s*$/;
	if(fieldValue =="" || (pattern.test(fieldValue)==true))
	{
		error = true;
		fieldErrorDiv.innerHTML = arrvalue;
		fieldErrorDiv.style.display = "block";
	}
	else
	{
		fieldErrorDiv.style.display = "none";
	}
	return error;
}
function emptyPleaseCorrectFieldCheck(fieldValue,arrvalue,fieldErrorDiv)
{
	var error = false;
	if(fieldValue =="")
	{
		error = true;
		fieldErrorDiv.innerHTML = arrvalue;
		fieldErrorDiv.style.display = "block";
	}
	return error;
}
function checkSimilar(value1,value2,arrValue,fieldErrorDiv)
{
var error = false;
	 if(value1 != "" && value2 != "")
        {
            if(value1 == value2)
            {
                  fieldErrorDiv.style.display   = "none";
            }
            else
            {
                error = true;
				fieldErrorDiv.innerHTML = arrValue;
                fieldErrorDiv.style.display   = "block";
            }
        }
		return error;
}
//Start:archana
	function validateName(fieldValue,arrvalue,fieldErrorDiv)
	{

	var error = false;
//	var pattern = "&()[]\\\';/{}\"<>";
	var pattern = "&()[]\\';/{}\"<>";

	for (var i = 0; i < fieldValue.length; i++) {
	if (pattern.indexOf(fieldValue.charAt(i)) != -1) {

	  error = true;
	  //alert ("Your string has special characters. \nThese are not allowed.");
	  fieldErrorDiv.innerHTML = arrvalue;
	  fieldErrorDiv.style.display = "block";
	}
	}

	return error;
	}

//validate city field
	function validateCity(fieldValue,arrvalue,fieldErrorDiv)
		{
		//alert(" validFieldCheck ");
		var error = false;
//		var pattern = "<>'()/\"{}[]&";
		var pattern = "&()[]\\';/{}\"<>";

		for (var i = 0; i < fieldValue.length; i++) {
		if (pattern.indexOf(fieldValue.charAt(i)) != -1) {

		  error = true;
		  //alert ("Your string has special characters. \nThese are not allowed.");
		  fieldErrorDiv.innerHTML = arrvalue;
		  fieldErrorDiv.style.display = "block";
		}
		}

		return error;
		}
//validate zip for non US
		function validateZip(fieldValue,arrvalue,fieldErrorDiv)
		{
		//alert(" validFieldCheck ");
		var error = false;
//		var pattern = "!@#$%^&*()+=[]\\\';,./{}|\":<>?~_";
		var pattern = "!@#$%^&*()+=[]\\';,./{}|\":<>?~_";

		for (var i = 0; i < fieldValue.length; i++) {
		if (pattern.indexOf(fieldValue.charAt(i)) != -1) {

		  error = true;
		  //alert ("Your string has special characters. \nThese are not allowed.");
		  fieldErrorDiv.innerHTML = arrvalue;
		  fieldErrorDiv.style.display = "block";
		}
		}

		return error;
		}
//validate state for non US
		function validateState(fieldValue,arrvalue,fieldErrorDiv)
		{
			//alert(" validFieldCheck ");
			var error = false;
//			var pattern = "!@#$%^&*()+=[]\\\';,./{}|\":<>?~_";
			var pattern = "!@#$%^&*()+=[]\\';,./{}|\":<>?~_";
			var alphaExp = /^[a-zA-Z ]+$/;

			if (fieldValue.match(alphaExp))
			{
				//alert("true");
				error = false;
			}else{
				//alert("false");
				error = true;
				fieldErrorDiv.innerHTML = arrvalue;
				fieldErrorDiv.style.display = "block";
			}


			for (var i = 0; i < fieldValue.length; i++) {
			if (pattern.indexOf(fieldValue.charAt(i)) != -1 ) {
			 // alert("state");
			  error = true;
			  //alert ("Your string has special characters. \nThese are not allowed.");
			  fieldErrorDiv.innerHTML = arrvalue;
			  fieldErrorDiv.style.display = "block";
			}
		  }

			return error;
		}

//End:Archana
function validateEmail(value,arrValue,arrValueMax,fieldErrorDiv)
{
	var error = false;
//	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
//	var emailPattern = /^([a-zA-Z0-9]+((\.[a-zA-Z0-9]+)?)*)@(([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/;
//var emailPattern = /^([a-zA-Z0-9]+((?:.[a-zA-Z0-9_-]+)?)*)@(([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/;
var emailPattern = "^[a-zA-Z0-9]+[a-zA-Z0-9._-]*@([a-zA-Z0-9-]+\\.)+([a-zA-Z]{2,4}){1}$";
	var charMax = 64;
	var charMin = 7;
	if(value!="")
	{
		if(value.length>charMax || value.length<charMin)
		{
				error = true;
				fieldErrorDiv.innerHTML = arrValue;
     		    fieldErrorDiv.style.display   = "block";
		}
		else
		{
			if(value.match(emailPattern))
			{
				 fieldErrorDiv.style.display   = "none";
			}
			else
			{
				 error = true;
				 fieldErrorDiv.innerHTML = arrValue;
     		     fieldErrorDiv.style.display   = "block";
			}
		}
	}
	return error;
}
function checkLength(fieldValue,arrvalue,fieldErrorDiv)
{
	var error = false;
	var pattern = /^\s*$/;

	maxLength = 40;
	if(fieldValue!="" && (pattern.test(fieldValue)==false))
	{
	if(fieldValue.length>maxLength)
	{
		error = true;
		fieldErrorDiv.innerHTML = arrvalue;
		fieldErrorDiv.style.display = "block";
	}
	}
	return error;
}
function validateUsCanadaZip(value,arrValue,fieldErrorDiv)
{
	var error = false;
	if(value!="")
	{
		value = value.toUpperCase();
		var zipPattern = /((^\d{5}([- |]\d{4})?$)|(^[A-Z]\d[A-Z][- |]\d[A-Z]\d$))/;
		if(value.match(zipPattern))
		{
			 fieldErrorDiv.style.display   = "none";
		}
		else
		{
			 error = true;
			 fieldErrorDiv.innerHTML = arrValue;
	         fieldErrorDiv.style.display   = "block";
		}
	}
	return error;

}
function validatePassword(value,arrValidChar,fieldErrorDiv)
{
   var error = false;
   var str = "";
	if(value.length!="")
	{
 	  var validLength = false;
      if(value.length>=6)
		validLength = true;

      var hasSpecialChar = false;
      if(value.match(/[&<>\+\"\\ ]/)) {
		  hasSpecialChar=true;
	     //alert("true");
	  }

       var validExpression = validLength && (!hasSpecialChar);
	  if(validExpression)
      {
			fieldErrorDiv.style.display   = "none";
            return error;
      }
      else
      {
   		if(!validLength)
		{
			str+=arrValidChar + "<br />";

		}
		if(hasSpecialChar)
		{
			str+=arrValidChar + "<br />";

		}
		error=true;
		fieldErrorDiv.innerHTML = str;
	    fieldErrorDiv.style.display   = "block";
	  }
	}
  return error;
}
function validatesOCPhone(value,arrMax,fieldErrorDiv)
{
   var error = false;
   var str = "";
	if(value.length!="")
	{
	  var validLength = false;
      if(value.length>=6)
		validLength = true;

      var validExpression = validLength;
	  if(validExpression)
      {
			fieldErrorDiv.style.display   = "none";
            return error;
      }
      else
      {
		if(!validLength)
		{
			str+=arrMax + "<br />";

		}
		error=true;
		fieldErrorDiv.innerHTML = str;
	    fieldErrorDiv.style.display   = "block";
	  }
	}
  return error;
}
function validateUsCanadaState(fieldValue,arrValue,fieldErrorDiv)
{
   var error = false;
//			var pattern = "!@#$%^&*()+=[]\\\';,./{}|\":<>?~_";
			var pattern = "!@#$%^&*()+=[]\\ ';,./{}|\":<>?~_";
			var alphaExp = /^[a-zA-Z]+$/;
			if (fieldValue.match(alphaExp))
			{
				//alert("no error");
			  error = false;
			}else{

			    error = true;
				fieldErrorDiv.innerHTML = arrValue;
				fieldErrorDiv.style.display = "block";
			}


			for (var i = 0; i < fieldValue.length; i++) {
			if (pattern.indexOf(fieldValue.charAt(i)) != -1 ||  fieldValue.length>2 || fieldValue.length<2) {

			  error = true;
			  //alert ("Your string has special characters. \nThese are not allowed.");
			  fieldErrorDiv.innerHTML = arrValue;
			  fieldErrorDiv.style.display = "block";
			}
		  }

			return error;

/*   var error = false;
   var str = "";
	if(value.length!="")
	{
	  var validLength = false;
      if(value.length<=2)
		validLength = true;

      var validExpression = validLength;
	  if(validExpression)
      {
			fieldErrorDiv.style.display   = "none";
            return error;
      }
      else
      {
		if(!validLength)
		{
			str+=arrMax + "<br />";

		}
		error=true;
		fieldErrorDiv.innerHTML = str;
	    fieldErrorDiv.style.display   = "block";
	  }
	}
  return error; */
}
function updateContactStates(selectedStateGroup){
var countrieslist=document.getElementById("contactCountry");
var statesList=document.getElementById("contactStateProvinceDD");
var states=new Array()
states[0]=["Alabama|AL", "Alaska|AK", "Arizona|AZ", "Arkansas|AR", "California|CA", "Colorado|CO",  "Connecticut|CT", "Delaware|DE", "District of Columbia|DC", "Florida|FL", "Georgia|GA", "Hawaii|HI", "Idaho|ID", "Illinois|IL", "Indiana|IN", "Iowa|IA", "Kansas|KS", "Kentucky|KY", "Louisiana|LA", "Maine|ME", "Maryland|MD", "Massachusetts|MA", "Michigan|MI", "Minnesota|MN", "Mississippi|MS", "Missouri|MO", "Montana|MT", "Nebraska|NE", "Nevada|NV", "New Hampshire|NH", "New Jersey|NJ", "New Mexico|NM", "New York|NY", "North Carolina|NC", "North Dakota|ND", "Ohio|OH", "Oklahoma|OK", "Oregon|OR", "Pennsylvania|PA",  "Rhode Island|RI", "South Carolina|SC", "South Dakota|SD", "Tennessee|TN", "Texas|TX", "Utah|UT", "Vermont|VT", "Virginia|VA", "Washington|WA", "West Virginia|WV", "Wisconsin|WI", "Wyoming|WY"];
states[1]=["Alberta|AB", "British Columbia|BC", "Manitoba|MB", "New Brunswick|NB", "Newfoundland and Labrador|NL", "Northwest Territories|NT", "Nova Scotia|NS", "Nunavut|NU", "Ontario|ON", "Prince Edward Island|PE", "Quebec|QC", "Saskatchewan|SK", "Yukon|YT"]
statesList.options.length=0
if ((selectedStateGroup>=0) && (selectedStateGroup<2)){
document.getElementById("contactStateProvinceDD").style.display = "block";
document.getElementById("contactStateProvinceTF").style.display = "none";
document.getElementById('contactStateProvinceError').style.display = "none";
for (i=0; i<states[selectedStateGroup].length; i++)
statesList.options[statesList.options.length]=new Option(states[selectedStateGroup][i].split("|")[0], states[selectedStateGroup][i].split("|")[1])
copyStateFromDD();
}
else
{
document.getElementById("contactStateProvinceDD").style.display = "none";
document.getElementById("contactStateProvinceTF").style.display = "block";
copyStateFromTF();
}
}
function validateURL(value,arrValueSpace,arrValueLength,arrValueStart,arrValueChar,fieldErrorDiv)
{
	var error = false;
	var iChars = "!@#$%^&*()+=-[]\';,./{}|\":<>?_";
	var pattern = /\s/;
	var hasNum = /\d/;
	var str="";
	var spaceStr="";
	var lengthStr="";
	var startStr="";
	var charStr="";
	var caseStr ="";
	if(value != "")
	{
		if(value.length>26)
		{

			lengthStr = arrValueLength +"<br />";
		}
		else
		{

			if(hasNum.test(value.charAt(0)))
				{
					startStr = arrValueStart +"<br />";
				}

			if(pattern.test(value))
				{
					spaceStr = arrValueSpace +"<br />";
				}

			for(i=0; i<value.length; i++)
			{
				if(iChars.indexOf(value.charAt(i)) != -1)
  				{
					charStr = arrValueChar;
  				}

			}

		}
		if(spaceStr!="" || lengthStr!="" || startStr!="" || charStr!="")
		{
			str = spaceStr + lengthStr + startStr + charStr;
		}
		if(str!="")
		{
			error = true;
			fieldErrorDiv.innerHTML = str;
			fieldErrorDiv.style.display = "block";
		}
		else
		{
			fieldErrorDiv.style.display = "none";
		}
	}

	return error;
}
function validateCityState(value,arrValue,fieldErrorDiv)
{
	var error = false;
	if(value.length!="")
	{

		var validLength = false;
		if(value.length<=40) validLength=true;

		var beginEndSpace = false;
		if(value[0]==" "||value[(value.length)-1]==" ") beginEndSpace = true;

		var hasNonValidChars = false;
		if(value.match(/[^a-zA-Z\s]/)) hasNonValidChars=true;

		var  validExpression= validLength && (!hasNonValidChars)&&(!beginEndSpace);

		if(validExpression)
		{
			fieldErrorDiv.style.display = "none";
			return error;
		}
		else
		{
			error=true;
			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display = "block";
		}
	}
	return error;
}
function validatePhoneUSCanada(value,arrValue,fieldErrorDiv)
{
	var error = false;
	if(value.length!="")
	{
		var pattern =/^\d{3}-\d{3}-\d{4}$/;
		if(pattern.test(value))
		{
			fieldErrorDiv.style.display   = "none";
		}
		else
		{
			error = true;
			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display   = "block";
		}
	}
	return error;
}

//START:Archana
//phoneNoValidation:Only numbers, '(', ')', '-', and '+' are allowed. No Spaces. Length 6 - 32.

function validatePhoneNo(value,arrValue,fieldErrorDiv)
{
	//alert("phone validation");
	var error = false;
        // non-digit characters which are allowed in phone numbers
        //are = "()-. ";
        var phoneNumberDelimiters = "()-";
        // characters which are allowed in international phone numbers
        // (a leading + is OK)
        var validWorldPhoneChars = phoneNumberDelimiters + "+";
        // Minimum no of digits in an international phone no.
        //int minDigitsInIPhoneNumber = 10;
        var minDigitsInIPhoneNumber = 6;
        var maxDigitsInIPhoneNumber = 32;
if(value.length!="")
				{
		digitChars=stripDigitChars(value,validWorldPhoneChars);

		if(isInteger(digitChars) && digitChars.length >= minDigitsInIPhoneNumber && digitChars.length <= maxDigitsInIPhoneNumber)
	       {
			fieldErrorDiv.style.display   = "none";
		   }
		   else{
			error = true;
			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display   = "block";
		   }
	}
	return error;
}

//check for allowed special character
function stripDigitChars(s, bag)
{

	var i;
	var returnString = "";
	// Search through string's characters one by one.
	// If character is not in bag, append to returnString.
	for (i = 0; i < s.length; i++)
	{
		// Check that current character isn't whitespace.
		var c = s.charAt(i);
		if (bag.indexOf(c) == -1) returnString += c;
	}
	return returnString;
}
//is integer
function isInteger(s)
{
	//alert("phone validation::stripDigitChars::isInteger");
	var i;
    for (i = 0; i < s.length; i++)
    {
        // Check that current character is number.
        var c = s.charAt(i);
        if (((c < "0") || (c > "9"))) return false;
    }
    // All characters are numbers.
    return true;
}

////End:phone validation)


function validateSecurityCode(value,arrValue,fieldErrorDiv)
{
	var error = false;
	var creditCardType = document.getElementById("accountCreditCard").value;
	if(value.length!="")
	{
		var validLength = false;
		if(creditCardType == "VISA")
		{
			if(value.length == 3)
				validLength=true;
		}
		if(creditCardType == "MASTERCARD")
		{
			if(value.length == 3)
				validLength=true;
		}
		if(creditCardType == "AMEX")
		{
			if(value.length == 4)
				validLength=true;
		}
//Start: Added for BUG #1747
		if(creditCardType == "JCB")
		{
			if(value.length == 3)
				validLength=true;
		}
//End: Added for BUG #1747
		var  validExpression= validLength;
		if(validExpression)
		{
			fieldErrorDiv.style.display = "none";
			return error;
		}
		else
		{
			error=true;
			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display = "block";
		}
	}
	return error;
}
function validateCreditCard(value,arrValue,fieldErrorDiv)
{
	var error = false;
	var creditCardType = document.getElementById("creditCard").value;
	if(value.length!="")
	{
		var validLength = false;
		if(creditCardType == "Visa")
		{
			if(value.length == 16 || value.length == 13) validLength=true;
		}
		if(creditCardType == "MasterCard")
		{
			if(value.length == 16) validLength=true;
		}
		if(creditCardType == "Amex")
		{
			if(value.length == 15) validLength=true;
		}
//Start: Added for BUG #1747
		if(creditCardType == "JCB")
		{
			if(value.length == 15 || value.length == 16) validLength=true;
		}
//End: Added for BUG #1747
		var beginEndSpace = false;
		if(value[0]==" "||value[(value.length)-1]==" ") beginEndSpace = true;

		var hasNonValidChars = false;
		if(value.match(/[^\d]/)) hasNonValidChars=true;

		var  validExpression= validLength && (!hasNonValidChars)&&(!beginEndSpace);

		if(validExpression)
		{
			fieldErrorDiv.style.display = "none";
			return error;
		}
		else
		{
			error=true;
			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display = "block";
		}
	}
	return error;
}
function updateStates(selectedStateGroup){
var countrieslist=document.getElementById("billingCountry");
var statesList=document.getElementById("billingStateProvince");
var states=new Array()
states[0]=["Alabama|AL", "Alaska|AK", "Arizona|AZ", "Arkansas|AR", "California|CA", "Colorado|CO",  "Connecticut|CT", "Delaware|DE", "District of Columbia|DC", "Florida|FL", "Georgia|GA", "Hawaii|HI", "Idaho|ID", "Illinois|IL", "Indiana|IN", "Iowa|IA", "Kansas|KS", "Kentucky|KY", "Louisiana|LA", "Maine|ME", "Maryland|MD", "Massachusetts|MA", "Michigan|MI", "Minnesota|MN", "Mississippi|MS", "Missouri|MO", "Montana|MT", "Nebraska|NE", "Nevada|NV", "New Hampshire|NH", "New Jersey|NJ", "New Mexico|NM", "New York|NY", "North Carolina|NC", "North Dakota|ND", "Ohio|OH", "Oklahoma|OK", "Oregon|OR", "Pennsylvania|PA",  "Rhode Island|RI", "South Carolina|SC", "South Dakota|SD", "Tennessee|TN", "Texas|TX", "Utah|UT", "Vermont|VT", "Virginia|VA", "Washington|WA", "West Virginia|WV", "Wisconsin|WI", "Wyoming|WY"];
states[1]=["Alberta|AB", "British Columbia|BC", "Manitoba|MB", "New Brunswick|NB", "Newfoundland and Labrador|NL", "Northwest Territories|NT", "Nova Scotia|NS", "Nunavut|NU", "Ontario|ON", "Prince Edward Island|PE", "Quebec|QC", "Saskatchewan|SK", "Yukon|YT"];
statesList.options.length=0
if (selectedStateGroup>=0){
for (i=0; i<states[selectedStateGroup].length; i++)
statesList.options[statesList.options.length]=new Option(states[selectedStateGroup][i].split("|")[0], states[selectedStateGroup][i].split("|")[1])
}
writeHiddenValue();
}
function val_CiscoEmail( email){
	varEmail = email.value;
	var regex = /@cisco\./i;
	if (regex.test(varEmail))
	{
	////////////////////alert("As a Cisco employee, you already have a facility in place to use WebEx.  Please contact your IT administrator for details. Thank you. ");
	setTimeout(function() {email.focus();}, 0)
	}
}
function validateHtmlTags(value,arrValue,fieldErrorDiv)
{
var error = false;
	if(value.length!="")
	{

    var hasTagChar = false;
    if(value.match(/[<>]/)) hasTagChar=true;

	if(hasTagChar)
		{

			error=true;

			fieldErrorDiv.innerHTML = arrValue;
			fieldErrorDiv.style.display = "block";
		}
	}
	return error;
}
function wrapText(value,fieldName,maxLength)
{
	pattern = /[\s]/;
	str="";
	if(value!="" && value.length>maxLength)
	{
	var splitResult = value.split(" ");
	for(i=0;i<splitResult.length;i++)
	{

		if(splitResult[i].length>maxLength)
           	{
                curWrapStr = "";
		for(j=0;j<splitResult[i].length;j++)
		{

			if(j>0  && j%maxLength==0)
			{

				curWrapStr+="<br />";
			}
			curWrapStr+=splitResult[i].charAt(j);
		}
                str += curWrapStr;
		}
		else
		{
			str+=splitResult[i];
		}
            if(i<(splitResult.length-1)) str+= " ";
	}
	document.getElementById(fieldName).innerHTML = str;
	}
	else
	{
	document.getElementById(fieldName).innerHTML = value;
	}
}
function trimStrings(fieldValue,fieldName)
{
	fieldValue = fieldValue.replace(/^\s+|\s+$/g,"");
	document.getElementById(fieldName).value = fieldValue;
	return fieldValue;
}
function sleep(milliseconds)
{
var now = new Date();
var exitTime = now.getTime() + milliseconds;
while (true)
{
now = new Date();
if (now.getTime() > exitTime)
return;
}
}
function getCookie( 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));
}
function DeleteCookie (name)
{
	var exp = new Date();
	exp.setTime (exp.getTime() - 1);
	var cval = getCookie (name);
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
function getManualDownLoad(){
	 var userName = getCookie( "MDWBXId" );
	 var meetingUrl = getCookie( "MDSiteURL" );
	 var emailAddress = getCookie( "MDEMAILID" );

	 if ((userName == '' || meetingUrl == ''))
	 {
		window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
	 }
	 else
	 {
		 //window.location = "http://mwplocal.corp.webex.com/MyWebExWeb/initPcLogin.jsp;jsessionid="+wbx_jsessionid;//?userName="+userName+"&meetingSiteUrl="+meetingUrl;
		// window.location = "/MyWebExWeb/initPcLogin.jsp;jsessionid="+wbx_jsessionid;//?userName="+userName+"&meetingSiteUrl="+meetingUrl;
		 window.location = "/MyWebExWeb/initPcLogin.jsp;jsessionid="+wbx_jsessionid+"?jsessionid="+wbx_jsessionid;
	 }
}

function SetCookie(cookieName,cookieValue,nDays) {
	 var today = new Date();
	 var expire = new Date();
	 if (nDays==null || nDays==0) nDays=1;
	 expire.setTime(today.getTime() + 3600000*24*nDays);
	 //document.cookie = cookieName+"="+escape(cookieValue)
     //            + ";expires="+expire.toGMTString();

	var secure='';
	if(window.top.location.protocol == "https:"){
		secure = ";secure";
	}
	document.cookie = cookieName+"="+escape(cookieValue)
                 + ";expires="+expire.toGMTString()
                 +secure;

}

function addDays(days){
	var m_names = new Array("January", "February", "March",
		"April", "May", "June", "July", "August", "September",
		"October", "November", "December");
	var d = new Date();
    d.setDate(d.getDate()+days);
	var dtOutput = m_names[d.getMonth()] +" "+d.getDate()+","+d.getFullYear();
	return dtOutput;
}




//ADDED FOR EDIT INFORMATION STARTS


function HideContent(d) {
	document.getElementById(d).style.display = "none";
}

function ShowContent(d) {
	document.getElementById(d).style.display = "block";
}

function cancelChanges(){

	document.getElementById('firstName').value = accountFirstName;
	document.getElementById('lastName').value = accountLastName;
	document.getElementById('email').value = accountEmailAddress;
	//document.getElementById("statusBlock").innerHTML="";

	//restoreButton();
	var signupMsg = document.getElementById("signupmessage");
	signupMsg.style.display = "block";
	var contBtn = document.getElementById("continue");
	contBtn.style.display = "block";

	HideContent('update_info');
	ShowContent ('display_info');
}



function showEdit(){
	ShowContent('update_info');
	HideContent ('display_info');

//Strat:Archana:display the step1 value instead of step2
	document.getElementById('firstName').value = document.getElementById('accountConfirmationFirstName').innerHTML;
	document.getElementById('lastName').value = document.getElementById('accountConfirmationLastName').innerHTML;
//End:
	document.getElementById('email').value = accountEmailAddress;

	var contBtn = document.getElementById("continue");
	var signupMsg = document.getElementById("signupmessage");
	document.getElementById("error").style.display = "none";
	contBtn.style.display = "none";
	signupMsg.style.display = "none";

}

function restoreButton(){
	var contBtn = document.getElementById("continue");
	var signupMsg = document.getElementById("signupmessage");
	contBtn.style.display = "block";
	signupMsg.style.display = "block";
}

function IsEmpty(aTextField) {
   if ((aTextField.length==0) || (aTextField == ""))
   {
      return true;
   }
   else
   {
	  return false;
   }
}

function isValidEmail(strEmail){
//  validRegExp = /^[^@]+@[^@]+.[a-z]{2,}$/i;
 // validRegExp = /^([a-zA-Z0-9]+((\.[a-zA-Z0-9]+)?)*)@(([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/;
//var emailPattern = /^([a-zA-Z0-9]+((?:.[a-zA-Z0-9_-]+)?)*)@(([a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,3}))|(([01]?\d\d?|2[0-4]\d|25[0-5])\.){3}([01]?\d\d?|25[0-5]|2[0-4]\d))$/;
var emailPattern = "^[a-zA-Z0-9]+[a-zA-Z0-9._-]*@([a-zA-Z0-9-]+\\.)+([a-zA-Z]{2,4}){1}$";

   // search email text for regular exp matches
    if (strEmail.match(emailPattern))
   {
      return true;
   }

    return false;
}

function validateNamePersonalInfo(aTextField)
{
	 if (!aTextField) return false;
//	 var iChars = "<>'()/\"\{}[]& ;";
	 var iChars = "&()[]\\';/{}\"<>";
	 for (var i = 0; i < aTextField.length; i++)
	{
		if (iChars.indexOf(aTextField.charAt(i)) != -1)
			return false;
	}
	return true;
}

function submitPersonalInfo()
	{
		var fName = document.getElementById("firstName").value;
		var lName = document.getElementById("lastName").value;
		var email = document.getElementById("email").value;
		// added to trim the fields in 3rd step
		fName = trimStrings(fName,"firstName");
		lName = trimStrings(lName,"lastName");
		email = trimStrings(email,"email");


		var errors = new Array(10);
		var errorCount = 0;
		var ErrorMsgs="";

		if(IsEmpty(fName))
		{
			 errors[errorCount] = arrError[10];
			 errorCount = errorCount + 1;
			 ErrorMsgs += arrError[10]+"<br>";
		}
		else
		{
			if(!validateNamePersonalInfo(fName))
			{
				errors[errorCount] = arrError[1];
				errorCount = errorCount + 1;
				ErrorMsgs += arrError[58] + '<br>';
			}
		}

		if(IsEmpty(lName))
		{
			 errors[errorCount] = arrError[11];
			 errorCount = errorCount + 1;
			 ErrorMsgs += arrError[11]+"<br>";

		}
		else
		{
			if(!validateNamePersonalInfo(lName))
			{
				errors[errorCount] = arrError[1];
				errorCount = errorCount + 1;
				ErrorMsgs += arrError[59] + '<br>';
			}
		}

		if(IsEmpty(email))
		{
			 errors[errorCount] = arrError[1];
			 errorCount = errorCount + 1;
			 ErrorMsgs += arrError[1]+"<br>";

		}
		else
		{
			if(!isValidEmail(email))
			{
				errors[errorCount] = arrError[5];
				errorCount = errorCount + 1;
				ErrorMsgs += arrError[5]+"<br>";

			}
		}


		var tZone = timeZoneEdit;
		var pwd = accountPassword;
		var oldEmail = accountEmailAddress ;

		//Start:Forming the Calling URL
		var proto = "http:";
		if(window.top.location.protocol == "https:"){
			proto = "https:";
		}

		var domainString ='';
		domainString = proto + '//'+document.domain;
		var xhrURL = domainString+'/UserProfileApp/js/UserProfileApp-Include.jsp';

		//END:Forming the Calling URL
			dojo.xhrGet ({

				// Location of the HTML content we want to grab
				url: xhrURL,

				// Called when the page loaded successfully
				load: function (data) {

				},
				sync: true,
				// Called if there was an error (such as a 404 response)
				error: function (data) {
					console.error('Error: ', data);
				}
			});

		//START:Calling The JSON-RPC

		var proto = "http:";
		if(window.top.location.protocol == "https:"){
			proto = "https:";
		}

		domainString = proto + '//'+document.domain;
		jsonurl = domainString + '/UserProfileApp/JSON-RPC';

		jsonrpc = null;

		//Initializing JSONRpcClient
		try
		{
			jsonrpc = new JSONRpcClient(jsonurl);
		}
		catch(e)
		{
		  //In case of Error Show Error Page
		  window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
		  error = true;
		}

	//END:Calling The JSON-RPC

//***************************************** STYART:AGAINCALLING JSON *******************************************************************



/* ::::::::::::::::::::::  START: SET THE CALLER CONTEXT OBJECT  :::::::::::::::::::::   */
//////////alert("START: SET THE CALLER CONTEXT OBJECT");
//Archana:add one jsession parameter in ProfileCallerContext
	var profileCallerContext ={
				"applicationName":"NOW",
				"applicationModel":"WEBEX",
				"sessionToken":wbx_jsessionid
				};

	var userObject ={
			    "firstName":fName,
				"lastName":lName,
				"email":email,
				"timeZone":tZone,
				"password":pwd,
				"currency":accountLocation,
				"CCNumber":CCNumber,
				"termId":termId,
				"renewalId":renewalId,
				"offerDesc":offerDesc
	};

	var email ={
			"emailId":oldEmail,
			"password":pwd
	};

  var userProfileCallerContextJSON = JSON.stringify(profileCallerContext);
  var userJSON = JSON.stringify(userObject);
  var emailJSON = JSON.stringify(email);

/* ::::::::::::::::::::::  END: SET THE CALLER CONTEXT OBJECT  :::::::::::::::::::::::::    */

	if (jsonrpc != null)
	{
		if (jsonrpc.userProfile != null)
		{
			var outputJSON = '';
			try
			{
				if(errorCount == 0 && ErrorMsgs != " ")
				{
					outputJSON = jsonrpc.userProfile.updateCustomerFromSignUp(userProfileCallerContextJSON, userJSON , emailJSON);
				}
				else
				{
					document.getElementById("error").style.display = "block";
					document.getElementById('error').innerHTML = "<br><span class='signup_error' style='align:right;'><b>" + arrError[61] + "<ul>" + ErrorMsgs + "</ul></b></span>";
					return false;
				}
			}
			catch(e)
			{
				//////////alert("return false"+e);
				//return false;
			}


			if (outputJSON != null)
			{
				var jsonData = JSON.parse(outputJSON);
				//////////alert(">>>>>>>>>>>  jsonData after UPDATE  >>>>>>>>>>>>"+jsonData);

				if(jsonData.emailExists != null && jsonData.emailExists == 'true')
				{
					document.getElementById("error").style.display = "block";
					document.getElementById("error").innerHTML ="<br><span class='signup_error' style='align:right;line-height:0px;'><b>"+arrError[61]+"<ul>"+arrError[57]+"</ul></b></span>";
				}
				else
				{
					document.getElementById("accountConfirmationFirstName").innerHTML = jsonData.firstName;
					document.getElementById("accountConfirmationLastName").innerHTML = jsonData.lastName;
					document.getElementById("accountConfirmationEmailAddress").innerHTML = jsonData.email;

					accountEmailAddress = jsonData.email;
					accountFirstName = jsonData.firstName;
					accountLastName = jsonData.lastName;

					document.getElementById("firstName").value = accountFirstName;
					document.getElementById("lastName").value = accountLastName;
					document.getElementById("email").value = accountEmailAddress;
					SetCookie ('MDEMAILID', encodeBase64(accountEmailAddress), 1);
					SetCookie ('MDFRISTNAME', accountFirstName, 1);
					SetCookie ('MDLASTNAME', accountLastName, 1);

					document.getElementById('display_info').style.display = "block";
					document.getElementById('update_info').style.display = "none";
					var contBtn = document.getElementById("continue");
					contBtn.style.display = "block";
					var signupMsg = document.getElementById("signupmessage");
					signupMsg.style.display = "block";
				}
			}

		}
		else
		{
			//////////alert ('jsonrpc.userProfile is null');
		    window.location = "/MyWebExWeb/uiErrorPage.jsp;jsessionid="+wbx_jsessionid;
			error = true;
		}
	}
	else
	{
		//////////alert ('jsonrpc is null');
	}//END:CALLING GETINVOICE JSON
}

function getCurrCharFromDesc(currDesc){
  var currChar = "";
  var orderTotal = "";
  var currAmount = "";
  if(currDesc != null)
  {
	  if(currDesc == "USD")
	  {
		  currChar = "$";
		  orderTotal = document.getElementById('orderTotalIDUS').value;
	  }
	  else if(currDesc == "GBP")
	  {
		  currChar = "&#163;";
		  orderTotal = document.getElementById('orderTotalIDGB').value;
	  }
	  else if(currDesc == "EUR")
	  {
		  currChar = "&#8364;";
		  orderTotal = document.getElementById('orderTotalIDEUR').value;
	  }
	  if(orderTotal != null)
	  {
		  currAmount = currChar+orderTotal;
	  }
	  else
	  {
		  currAmount = currChar;
	  }
  }
  return currAmount;
}

function getMonthlyRateString(currDesc){
  var currChar = "";
  var monthlyRate = "";
  var monthlyAmount = "";
  var monthlyRateString = "If PCNow is providing value, do nothing, and your membership will continue at a flat monthly rate of ";
  if(currDesc != null)
  {
	  if(currDesc == "USD")
	  {
		  currChar = "$";
		  monthlyRate = wbx_flex_rollover_ordertotalUS;
	  }
	  else if(currDesc == "GBP")
	  {
		  currChar = "&#163;";
		  monthlyRate = wbx_flex_rollover_ordertotalGB;
	  }
	  else if(currDesc == "EUR")
	  {
		  currChar = "&#8364;";
		  monthlyRate = wbx_flex_rollover_ordertotalEUR;
	  }

	  monthlyAmount = currChar+monthlyRate;
  }
  return monthlyRateString + monthlyAmount + ".";
}

function toggleStateLabel(){
       if (document.getElementById('accountCountry').value =="US")
		  {
			   document.getElementById ("signup_step2_state").innerHTML = "State:";
		  }else {
			   document.getElementById ("signup_step2_state").innerHTML = "County:";
		  }
}
