﻿
//----------------- ZIFF DAVIS - CHANGE GLOBAL VARIABLES ---------------------------
g_ShowKey = 1285;
g_ShowPackageKey = 470;
g_DirectoryPath = "07-23-08";
g_ShowOpen = 1; // 1 = Open  0 = Closed
g_DisplayForgotPassword = 0; // 1 = Display  0 = Hide

//----------------- END ---------------------------

function window_onload(i_Page){
	//-- Show/Hide Show Open Button
	switch(i_Page){
		case 1: //Code for RegistrationPage
			if(g_ShowOpen == 1){
				document.getElementById('ShowOpenTR').style.display = '';
				document.getElementById('ShowOpenLink').href = 'http://vts.inxpo.com/scripts/lightning.dll?LASCmd=AI:4;F:APIUTILS!10&ShowKey='+ g_ShowKey;
			}
		break;
		default: // All Other Pages
			if(g_ShowOpen == 1){
				document.getElementById('ShowOpenTR').style.display = '';
				document.getElementById('ShowOpenLink').href = 'http://vts.inxpo.com/scripts/lightning.dll?LASCmd=AI:4;F:APIUTILS!10&ShowKey='+ g_ShowKey;
			}
		break;
	}
}



function CheckRequiredField(cFieldID, cMessageName) {
var bRetval = true;
var oElem = document.getElementById(cFieldID);
if (oElem && oElem.value.length < 1) 
  {
    window.alert(cMessageName + " may not be blank!");
    oElem.focus();
    bRetval = false;
  }

return bRetval;
}

function ValidateFields() {


var bRetval = CheckRequiredField("EMailAddress", "Email Address");
if (bRetval)
  {
    var oElem = document.getElementById("EMailAddress");
    var emailReg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
    var emailReg2 = /^.+\@(\[?)[a-zA-Z0-9\-_\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/; // valid
    if (!(!emailReg1.test(oElem.value) && emailReg2.test(oElem.value))) 
      {
        window.alert("The field Email Address must be a valid Email address!\x0D\x0APlease Re-Enter.");
        oElem.focus();
        return false;
      }

    if (bRetval)
      bRetval = CheckRequiredField("Password", "Password");

    if (bRetval)
      bRetval = CheckRequiredField("FirstName", "First Name");
	  
    if (bRetval)
      bRetval = CheckRequiredField("LastName", "Last Name");

    if (bRetval)
      bRetval = CheckRequiredField("CompanyName", "Company Name");
	  
    if (bRetval)
      bRetval = CheckRequiredField("Phone", "Phone");

    if (bRetval)
      bRetval = CheckRequiredField("Department", "Department");

    if (bRetval)
      bRetval = CheckRequiredField("Country", "Country");
	  
    if (bRetval)
      bRetval = CheckRequiredField("CompanySize", "Company Size");
	  
    if (bRetval)
      bRetval = CheckRequiredField("JobFunction", "Job Function");
	  
    if (bRetval)
      bRetval = CheckRequiredField("PostalCode", "Postal Code/Zip"); 
    
	if (bRetval)
      bRetval = CheckRequiredField("AnnualRevenue", "Annual Revenue"); 
	  
	if (bRetval)
      bRetval = CheckRequiredField("Industry", "Industry"); 

	if (bRetval)
      bRetval = CheckRequiredField("EvaluationProcess", "Where are you in the evaluation process?"); 
	  
	if (bRetval)
      bRetval = CheckRequiredField("EvalSolutions", "If you are evaluating WebEx solutions, are you considering it for"); 
	  

	var radio_choice2 = false;
	// Loop from zero to the one minus the number of radio button selections
	for (counter = 0; counter < document.form1.SS1012.length; counter++){
	// If a radio button has been selected it will return true
	// (If not it will return false)
		if (document.form1.SS1012[counter].checked){
			radio_choice2 = true; 
		}	
	}
	if (radio_choice2 == false) {
		alert("Please enter how many people are in your organization?")
		bRetval = false;
	}


    if (bRetval)
		if (document.form1.UsageValidate.value == 0000000000){
			alert("How might you use WebEx may not be blank");
			bRetval = false;
		}

	}
	  
	if (bRetval == true){
		SubmitFormAction();

	}
return bRetval;
}


function PrevRegister(){
var bRetval = CheckRequiredField("PrevLoginID", "Email Address");
if (bRetval)
  {
    var oElem = document.getElementById("PrevLoginID");
    var emailReg1 = /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/; // not valid
    var emailReg2 = /^.+\@(\[?)[a-zA-Z0-9\-_\.]+\.([a-zA-Z]{2,6}|[0-9]{1,3})(\]?)$/; // valid
    if (!(!emailReg1.test(oElem.value) && emailReg2.test(oElem.value))) 
      {
        window.alert("The field Email Address must be a valid Email address!\x0D\x0APlease Re-Enter.");
        oElem.focus();
        return false;
      }
}
      bRetval = CheckRequiredField("PrevPassword", "Password");
	if (bRetval == true){
		var pLogin = document.form1.PrevLoginID.value;
		var pPass = document.form1.PrevPassword.value;

		document.PrevRegForm.LoginID.value = pLogin;
		document.PrevRegForm.ShowKey.value = g_ShowKey;
		document.PrevRegForm.ShowPackageKey.value = g_ShowPackageKey;
		document.PrevRegForm.ErrorPage.value = 'http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+ g_DirectoryPath +'/Website/RegistrationErrorPage.htm';
		document.PrevRegForm.Password.value = pPass;
		document.PrevRegForm.ThankYouPage.value = 'http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+ g_DirectoryPath +'/Website/PreRegistrationThankYou.htm?LoginID='+pLogin+'&Password='+pPass+'&ShowKey=1004';
		document.PrevRegForm.submit();
	}
}


function ThankYouPageOnLoad() { 
var surl = window.document.URL.toString(); 
if (surl.indexOf("?") > 0) { 
	var arrParams = surl.split("?"); 
	var arrurlParams = arrParams[1].split("&"); 
	var arrParamNames = new Array(arrurlParams.length); 
	var arrParamValues = new Array(arrurlParams.length); 
	var i = 0; 
	for (i=0;i<arrurlParams.length;i++) { 
		var sParam = arrurlParams[i].split("="); 
		arrParamNames[i] = sParam[0]; 
			if (sParam[1]!= "") 
				arrParamValues[i] = unescape(sParam[1]); 
			else 
				arrParamValues[i] = "No Value"; 
			} 
	for (i=0;i<arrurlParams.length;i++) { 

		var EmailAddress = arrParamValues[2];
		//var iShowKey = arrParamValues[2];
		//var AffiliateData = arrParamValues[1];
		//alert('http://vts.inxpo.com/scripts/Lightning.dll?LASCmd=AI:4;F:UP!10000&RecipientKey='+RecipientKey+'&ShowKey=91&VLoginID='+LoginID+'&VPassword='+Password+'&SaveRedirectURL=http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/02-07/Website/InviteFriend.htm')
	} 
	document.getElementById('HiddenFrame').innerHTML='<iframe width="100%" height="100%" src="http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+g_DirectoryPath+'/Website/InviteFriend.htm?EmailAddress='+EmailAddress+'" frameborder=0></iframe>';
} 
	else { 
	document.getElementById('HiddenFrame').innerHTML='<iframe width="100%" height="100%" src="http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+g_DirectoryPath+'/Website/InviteFriend.htm" frameborder=0></iframe>';

	} 
	
//Extract Pass
			if(g_ShowOpen == 1){
				
				document.getElementById('ShowOpenTR').style.display = '';
				document.getElementById('ShowOpenLink').href = 'http://vts.inxpo.com/scripts/lightning.dll?LASCmd=AI:4;F:APIUTILS!10&ShowKey='+ g_ShowKey;
			}
window_onresize();
}

function InviteFriendOnLoad() { 
var surl = window.document.URL.toString(); 
if (surl.indexOf("?") > 0) { 
	var arrParams = surl.split("?"); 
	var arrurlParams = arrParams[1].split("&"); 
	var arrParamNames = new Array(arrurlParams.length); 
	var arrParamValues = new Array(arrurlParams.length); 
	var i = 0; 
	for (i=0;i<arrurlParams.length;i++) { 
		var sParam = arrurlParams[i].split("="); 
		arrParamNames[i] = sParam[0]; 
			if (sParam[1]!= "") 
				arrParamValues[i] = unescape(sParam[1]); 
			else 
				arrParamValues[i] = "No Value"; 
			} 
	for (i=0;i<arrurlParams.length;i++) { 

		var EmailAddress = arrParamValues[0];
		//var iShowKey = arrParamValues[2];
		//var AffiliateData = arrParamValues[1];
		//alert('http://vts.inxpo.com/scripts/Lightning.dll?LASCmd=AI:4;F:UP!10000&RecipientKey='+RecipientKey+'&ShowKey=91&VLoginID='+LoginID+'&VPassword='+Password+'&SaveRedirectURL=http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/02-07/Website/InviteFriend.htm')
	} 
		document.SubmitForm.FromEMailAddress.value = EmailAddress;
	} 
} 



function window_onresize() {
var oLPC = document.getElementById('HiddenFrame');
oLPC.style.height = document.body.scrollHeight - document.getElementById('HiddenFrameRow').offsetTop - 0;
}



function CheckContentForm() {
var formComplete = true;
	with (document.SubmitForm){
		if (FromEMailAddress.value == "") {
			alert("You must enter your email address");
			formComplete = false;
		}
		if (ToEMailAddressList.value == "") {
			alert("You must a friend's email address");
			formComplete = false;
		}
		
	var fieldValue = FromEMailAddress.value;
	if(fieldValue != ""){  
	var atSymbol = 0
	
		//loop through field value string
		for(var a = 0; a < fieldValue.length; a++){ 
			//look for @ symbol and for each @ found, increment atSymbol variable by 1
			if(fieldValue.charAt(a) == "@"){ 
			atSymbol++
			}
			
		}
		
		// if more than 1 @ symbol exists
		if(atSymbol > 1){ 
		// then cancel and don't submit form
		alert("Please Enter A Valid Email Address") 
		formComplete = false;
					return false;  
		}
		
		// if 1 @ symbol was found, and it is not the 1st character in string
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){ 
		
		//look for period at 2nd character after @ symbol 
		var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) 
		
		// "."  immediately following 1st "." ? 
		var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 
				  
			//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
			// then cancel and don't submit form
			alert("Please Enter A Valid Email Address") 
			formComplete = false;
							return false;  
			}
		  		  
		}
		// no @ symbol exists or it is in position 0 (the first character of the field)
		else{  
		// then cancel and don't submit form
		alert("Please Enter A Valid Email Address")
			formComplete = false;
						return false;  
		}
	}
	// if field is empty
	else{  
	// then cancel and don't submit form
	alert("Please Enter A Valid Email Address")
			formComplete = false;
			return false;  
	}		
	}
	if (formComplete == true){ 	
		var oButton = document.getElementById("SubmitButton");
		oButton.value = "Please Wait......";	

	}
}
function GoToPage(){
	document.location='http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+g_DirectoryPath+'/Website/home.htm';
}

function CheckContactForm() {
var formComplete = true;
	with (document.SubmitForm){
		if (Name.value == "") {
			alert("You must enter Name");
			formComplete = false;
		}
		if (Question.value == "") {
			alert("You must enter Message Subject");
			formComplete = false;
		}
		
	var fieldValue = FromAddress.value;
	if(fieldValue != ""){  
	var atSymbol = 0
	
		//loop through field value string
		for(var a = 0; a < fieldValue.length; a++){ 
			//look for @ symbol and for each @ found, increment atSymbol variable by 1
			if(fieldValue.charAt(a) == "@"){ 
			atSymbol++
			}
			
		}
		
		// if more than 1 @ symbol exists
		if(atSymbol > 1){ 
		// then cancel and don't submit form
		alert("Please Enter A Valid Email Address") 
		formComplete = false;
					return false;  
		}
		
		// if 1 @ symbol was found, and it is not the 1st character in string
		if(atSymbol == 1 && fieldValue.charAt(0) != "@"){ 
		
		//look for period at 2nd character after @ symbol 
		var period = fieldValue.indexOf(".",fieldValue.indexOf("@")+2) 
		
		// "."  immediately following 1st "." ? 
		var twoPeriods = (fieldValue.charAt((period+1)) == ".") ? true : false 
				  
			//if period was not found OR 2 periods together OR field contains less than 5 characters OR period is in last position
			if(period == -1 || twoPeriods || fieldValue.length < period + 2 || fieldValue.charAt(fieldValue.length-1)=="."){
			// then cancel and don't submit form
			alert("Please Enter A Valid Email Address") 
			formComplete = false;
							return false;  
			}
		  		  
		}
		// no @ symbol exists or it is in position 0 (the first character of the field)
		else{  
		// then cancel and don't submit form
		alert("Please Enter A Valid Email Address")
			formComplete = false;
						return false;  
		}
	}
	// if field is empty
	else{  
	// then cancel and don't submit form
	alert("Please Enter A Valid Email Address")
			formComplete = false;
			return false;  
	}		
	}
	if (formComplete == true){ 	
		document.SubmitForm.MessageSubject.value = "Website Question for VTS - "+g_DirectoryPath;
		document.SubmitForm.Show.value = g_DirectoryPath;
		document.SubmitForm.RedirectURL.value = 'http://presentations.inxpo.com/Shows/ZiffDavisEnterprise/VTS/'+g_DirectoryPath+'/Website/contact_sent.htm';
		document.SubmitForm.submit();
	}
}