﻿function validateComplete(formObj)// Ensure that mandatory text fields of form have been filled in. Uses specific messages.
{
//alert("validateComplete is running!")
var check_box1 = eval("document.aspnetForm.pdfCatalog");
var check_box2 = eval("document.aspnetForm.mailCatalog");
var check_box3 = eval("document.aspnetForm.Newsletter");
var userEmail = document.aspnetForm.emailEntry.value;
var symbol1 = userEmail.indexOf("@");
var symbol2 = userEmail.indexOf(".");

if (emptyField(document.aspnetForm.firstname))
alert("Oops! Please enter your first name.");
else if (emptyField(document.aspnetForm.lastname))
alert("Oops! Please enter your last name.");
else if ((document.aspnetForm.businessOrIndividual[0].checked) && (emptyField(document.aspnetForm.company_name)))
alert("Oops! You indicated you are affiliated with a business. Please enter your Company Name.");
else if ((document.aspnetForm.businessOrIndividual[0].checked) && (emptyField(document.aspnetForm.jobtitle)))
alert("Oops! You indicated you are affiliated with a business. Please enter your Job Title.");
else if ((document.aspnetForm.businessOrIndividual[0].checked) && (emptyField(document.aspnetForm.businesstype)))
alert("Oops! You indicated you are affiliated with a business. Please enter your Business Type.");
else if ((document.aspnetForm.businessOrIndividual[0].checked) && (emptyField(document.aspnetForm.numberofemployees)))
alert("Oops! You indicated you are affiliated with a business. Please enter the Number of Employees.");

else if ((check_box2.checked == true) && (emptyField(document.aspnetForm.address)))
alert("Oops! You have opted to receive our print catalog by mail. Please provide your mailing address.");
else if ((check_box2.checked == true) && (emptyField(document.aspnetForm.city)))
alert("Oops! You have opted to receive our print catalog by mail. Please provide your city.");
else if ((check_box2.checked == true) && (emptyField(document.aspnetForm.state)))
alert("Oops! You have opted to receive our print catalog by mail. Please provide your state.");
else if ((check_box2.checked == true) && (emptyField(document.aspnetForm.zip)))
alert("Oops! You have opted to receive our print catalog by mail. Please provide your zip code.");

else if ((check_box1.checked == true) && (emptyField(document.aspnetForm.address)))
alert("Oops! Please provide your mailing address.");
else if ((check_box1.checked == true) && (emptyField(document.aspnetForm.city)))
alert("Oops! Please provide your city.");
else if ((check_box1.checked == true) && (emptyField(document.aspnetForm.state)))
alert("Oops! Please provide your state.");
else if ((check_box1.checked == true) && (emptyField(document.aspnetForm.zip)))
alert("Oops! Please provide your zip code.");


else if ((check_box3.checked == true) && ((symbol1 == -1) || (symbol2 == -1)))
alert("Oops! You have opted to receive our email newsletter with exclusive offers, coupons and discounts. Please provide a valid email address.");

else return true;
return false;
}

//Check to see if field is empty
function emptyField(textObj)
{
if (textObj.value.length == 0) return true;
for (var i=0; i<textObj.value.length; ++i) {
var ch = textObj.value.charAt(i);
if (ch != ' ' && ch != '\t') return false;
}
return true;
}

function switchAsterixBusiness() 
{		
imgWhite = new Image(12, 12);
imgWhite.src = "http://www.timemotion.com/Images/spacers/whiteSpacer.gif";
		
imgRed = new Image(12, 12);
imgRed.src = "http://www.timemotion.com/Images/redAsterix.gif";

//No asterisk
if(document.aspnetForm.businessOrIndividual[1].checked)
{
document ['busNameReqd'].src = imgWhite.src;
document ['jobTitleReqd'].src = imgWhite.src;
document ['busTypeReqd'].src = imgWhite.src;
document ['empNumReqd'].src = imgWhite.src;
}
else 
{
//Red asterisk
document ['busNameReqd'].src = imgRed.src;
document ['jobTitleReqd'].src = imgRed.src;
document ['busTypeReqd'].src = imgRed.src;
document ['empNumReqd'].src = imgRed.src;
}
}

function switchAsterixCat() 
{		
imgWhite = new Image(12, 12);
imgWhite.src = "http://www.timemotion.com/Images/spacers/whiteSpacer.gif";
		
imgRed = new Image(12, 12);
imgRed.src = "http://www.timemotion.com/Images/redAsterix.gif";

//Red asterisk
var check_box1 = eval("document.aspnetForm.pdfCatalog");
var check_box2 = eval("document.aspnetForm.mailCatalog");

if (check_box1.checked == true || check_box2.checked == true)
{
document ['mailAddressReqd'].src = imgRed.src;
document ['cityReqd'].src = imgRed.src;
document ['stateReqd'].src = imgRed.src;
document ['zipReqd'].src = imgRed.src;
document ['countryReqd'].src = imgRed.src;
}
else 
{
//No asterisk
document ['mailAddressReqd'].src = imgWhite.src;
document ['cityReqd'].src = imgWhite.src;
document ['stateReqd'].src = imgWhite.src;
document ['zipReqd'].src = imgWhite.src;
document ['countryReqd'].src = imgWhite.src;
}
}

function switchAsterixEmail() 
{		
imgWhite = new Image(12, 12);
imgWhite.src = "http://www.timemotion.com/Images/spacers/whiteSpacer.gif";
		
imgRed = new Image(12, 12);
imgRed.src = "http://www.timemotion.com/Images/redAsterix.gif";

//No asterisk
var check_box4 = eval("document.aspnetForm.Newsletter");

if (check_box4.checked == false)
{
document ['emailAddressReqd'].src = imgWhite.src;
}
else 
{
//Red asterisk
document ['emailAddressReqd'].src = imgRed.src;
}
}

function JumpURL(selection) {
var tempIndex, selectedURL;
tempIndex = selection.selectedIndex;
selectedURL = selection.options[tempIndex].value;
window.top.location.href = selectedURL;
}

