//Standard Reset doesn't work because data is reloaded

//Reset function for feedback
 function resetfb()
 {
 document.fdback.ezlmVersion.value="2.0.02";
 document.fdback.otherVersion.value="";
 document.fdback.javaVersion.value="1.4.2";
 document.fdback.otherJava.value="";
 document.fdback.progLang.value="Java";
 document.fdback.os.value="Windows";
 document.fdback.osVersion.value="";
 document.fdback.name.value="";
 document.fdback.email.value="";
 document.fdback.company.value="";
 document.fdback.login.value="";
 document.fdback.ratingExp.value=" ";
 document.fdback.exp.value="";
 document.fdback.ratingPricing.value="";
 document.fdback.pricing.value="";
 document.fdback.ratingQuality.value="";
 document.fdback.quality.value="";
 document.fdback.ratingDoc.value="";
 document.fdback.doc.value="";
 document.fdback.strengths.value="";
 document.fdback.keyFeature.value="";
 document.fdback.alternative.value="";
 //document.fdback.concerns.value="";
 //document.fdback.confidence.value="";
 document.fdback.addComments.value="";
 
 }
 
 function clearCheckBoxes()
 {
   var elements = document.getElementsByTagName("INPUT");
   for (i=0;i< elements.length;i++)
   {
	if(elements[i].type == 'checkbox')
	{
		elements[i].checked = false;
	}
   }
 }
 

 function checkCheckBoxes()
 {
   var elements = document.getElementsByTagName("INPUT");
   for (i=0;i< elements.length;i++)
   {
	if(elements[i].type == 'checkbox')
	{
		if(elements[i].checked)
		{
			//alert("checked");
			return true;
		}
	}
   }
   return false;
 }


//Reset function for probsubm
 function resetps()
 {
 document.probsub.ezlmVsn.value="2.0.02";
 document.probsub.otherVersion.value="";
 document.probsub.javaVersion.value="1.4.2";
 document.probsub.otherJava.value="";
 document.probsub.progLang.value="Java";
 document.probsub.os.value="Windows";
 document.probsub.osVersion.value="";
 document.probsub.name.value="";
 document.probsub.email.value="";
 document.probsub.company.value="";
 document.probsub.login.value="";
 document.probsub.probSyn.value="";
 document.probsub.probDesc.value="";
 document.probsub.severity.value="Critical - Show Stopper";
 document.probsub.addInfo.value="";
 document.probsub.probRepro.value="";
 document.probsub.bugFile.value="";
 }	
 
 //Reset function for contact
 function resetct()
{
document.contact.contactTarget[0].checked=true;
document.contact.name.value="";
document.contact.company.value="";
document.contact.email.value="";
document.contact.phone.value="";
//document.contact.topic.value="";
document.contact.topic[0].selected=true;
document.contact.otherSubject.value="";
document.contact.message.value="";
}

//Reset function for webinar
 function resetwebinar()
{

document.webinarIdeas.name.value="";
document.webinarIdeas.company.value="";
document.webinarIdeas.email.value="";
document.webinarIdeas.phone.value="";
document.webinarIdeas.suggestion.value="";
//document.getElementById('ideas').cheched = "false";
//document.webinarIdeas.ideas[].value="";
clearCheckBoxes();

}

 //Reset function for contact in Portal
 function resetctp()
{
document.contact.name.value="";
document.contact.company.value="";
document.contact.email.value="";
document.contact.phone.value="";
document.contact.topic.value="";
document.contact.message.value="";
}

//Reset function for htb
 function resethtb()
{
document.datacollect.name.value="";
document.datacollect.company.value="";
document.datacollect.email.value="";
document.datacollect.phone.value="";
document.datacollect.OSUser.value="";
document.datacollect.OSMachine.value="";
document.datacollect.edition.value="Pro";
document.datacollect.q.value="";
document.datacollect.price.value="";
document.datacollect.ecommerce.value="Yes";
document.datacollect.promo.value="";
document.datacollect.server.value="No";
}

//Reset function for taf
function resettaf()
{
document.tellfriend.collName.value="";
document.tellfriend.collEmail.value="";
document.tellfriend.message.value="";
document.tellfriend.name.value="";
document.tellfriend.email.value="";
}

//Validate for special terms
function validatespecial()
{

}

//Validate for ezlm decline
function validatedcl()
{
var declinefield=document.declineterms.reason.value;
if(declinefield=="")
{
	alert("You have left the comments field blank.");
	document.declineterms.reason.focus();
	return false;
}
}

//Register
function validatereg()
{
var namefield=document.register.fname.value;
if(namefield=="")
{
	alert("Please enter your first name");
	document.register.fname.focus();
	return false;
}
var namefield=document.register.lname.value;
if(namefield=="")
{
	alert("Please enter your last name");
	document.register.lname.focus();
	return false;
}
var companyfield=document.register.company.value;
if(companyfield=="")
{
	alert("Please enter your Company name");
	document.register.company.focus();
	return false;
}
if(!email(document.register.email.value))
{
	document.register.email.focus();
	return false
}
if(!document.register.altemail.value=="")
{
	if(!email(document.register.altemail.value))
	{
		document.register.altemail.focus();
		return false
	}
}
if(!phone(document.register.phone.value))
{
	document.register.phone.focus();
	return false
}
if(!document.register.altphone.value=="")
{
	if(!phone(document.register.altphone.value))
	{
		document.register.altphone.focus();
	return false
	}
}
var urlfield=document.register.url.value;
var validUrl = /^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i;
var isValid=(validUrl.test(urlfield));
if(isValid==false&&urlfield!=""&&urlfield!="http://")
{
	alert("There is a problem with the format of your website url.");
	document.register.url.focus();
	return false;
}
return true;
}


//How to Buy


function validatehtb()
{
var svcustomerfield=document.datacollect.svcustomer.value;
var unitsfield=document.datacollect.q.value;
var editionfield=document.datacollect.edition.value;
var promofield=document.datacollect.promo.value;
var ecommercefield=document.datacollect.ecommerce.value;
var pricefield=document.datacollect.price.value;
var namefield=document.datacollect.name.value;
var companyfield=document.datacollect.company.value;
var emailfield=document.datacollect.email.value;
var phonefield=document.datacollect.phone.value;
var OSUserfield=document.datacollect.OSUser.value;
var OSMachinefield=document.datacollect.OSMachine.value;
var server=document.datacollect.server.value;
if (svcustomerfield=="contact")
{ 
if(namefield==""||companyfield==""||emailfield==""||phonefield=="")
{
	document.datacollect.svcustomer.value="na";
	alert("Please complete all contact information.");
	return false;
}
if(!email(document.datacollect.email.value))
{
	document.datacollect.svcustomer.value="na";
	document.datacollect.email.focus();
	return false
}
if(!phone(document.datacollect.phone.value))
{
	document.datacollect.svcustomer.value="na";
	document.datacollect.phone.focus();
	return false
}

var msg='howtobuy.php?zzz' + '&' + namefield + '&' + emailfield + '&' +  companyfield + '&' + phonefield;

MM_goToURL('parent',msg);return document.MM_returnValue;
}
else if(namefield==""||companyfield==""||emailfield==""||phonefield==""||OSUserfield==""||OSMachinefield=="")
{
	alert("Please complete all contact information.");
	return false;
}
if(!email(document.datacollect.email.value))
{
	document.datacollect.email.focus();
	return false
}
if(!phone(document.datacollect.phone.value))
{
	document.datacollect.phone.focus();
	return false
}
if(promofield==""&&svcustomerfield=="promotion")
{
	alert("Please enter your Promotion code.");
	return false;
}
if(unitsfield==0)
{
	alert("Please enter the number of License Units as a number between 1 and 10,000");
	document.datacollect.q.focus();
	return false;
}
var p=77;var promotitle=""; promocolon="";
if(editionfield=='Standard'&&ecommercefield=="No")
{
	p=0;
}
else if(editionfield=='Pro'&&ecommercefield=="No")
{
	p=1;
}
else if(editionfield=='Standard'&&ecommercefield=="Yes")
{
	p=2;
}
if(editionfield=='Pro'&&ecommercefield=="Yes")
{
	p=3;
}

if(promofield==""&&svcustomerfield=="promotion")
{
	alert("Please enter your Promotion code.");
	return false;
}
if(!promofield=="")
{
	p=4;
	unitsfield=pricefield;
	promotitle="promo="; promocolon=";"
}
var productArray=new Array('4448AG0001','4448AG0002','44484448AG0003','444844480004','4448AG0005');
var selectedCode=(productArray[p]);
document.datacollect.productcode.value=selectedCode;
var msg='https://www.swreg.org/cgi-bin/b.cgi?s=4448' + '&p=' + selectedCode + '&v=0&d=0&q='
 + unitsfield +  '&t=' +  promotitle + promofield +promocolon + 'quota=' + unitsfield +';userid=' + OSUserfield + '@' + OSMachinefield + ";server=" +server;
document.datacollect.swreg.value=msg;
//MM_goToURL('parent',msg);return document.MM_returnValue;
return;
}

//If "before you purchase" changes
function changepurchase()
{
var svcustomerfield=document.datacollect.svcustomer.value;
var namefield=document.datacollect.name.value;
var companyfield=document.datacollect.company.value;
var emailfield=document.datacollect.email.value;
var phonefield=document.datacollect.phone.value;
if (svcustomerfield=="contact")
{ 
if(namefield==""||companyfield==""||emailfield==""||phonefield=="")
{
	document.datacollect.svcustomer.value="na";
	alert("Please complete all contact information.");
	
	return false;
}
if(!email(document.datacollect.email.value))
{
	document.datacollect.svcustomer.value="na";
	document.datacollect.email.focus();
	return false
}
if(!phone(document.datacollect.phone.value))
{
	document.datacollect.svcustomer.value="na";
	document.datacollect.phone.focus();
	return false;
}
var msg='howtobuy.php?zzz' + '&' + namefield + '&' + emailfield + '&' +  companyfield + '&' + phonefield;

MM_goToURL('parent',msg);return document.MM_returnValue;

return true;
}
}

//How to Buy - dynamic version
function validatehtbd()
{
var namefield=document.datacollect.name.value;
var companyfield=document.datacollect.company.value;
var emailfield=document.datacollect.email.value;
var phonefield=document.datacollect.phone.value;
var macfield=document.datacollect.mac.value;
var promofield=document.datacollect.promo.value;
var affiliatefield=document.datacollect.affiliate.value;
if(namefield==""||companyfield==""||emailfield==""||phonefield=="")
{
	alert("Please complete all fields before downloading.");
return false;
}
if(!email(document.datacollect.email.value))
{
	document.datacollect.email.focus();
	return false
}
if(!phone(document.datacollect.phone.value))
{
	document.datacollect.phone.focus();
	return false
}
if(!mactest(document.datacollect.mac.value))
{
	document.datacollect.mac.focus();
	return false
}
var unitsfield=document.datacollect.q.value;
var editionfield=document.datacollect.edition.value;
var promofield=document.datacollect.promo.value;
var ecommercefield=document.datacollect.ecommerce.value;
var pricefield=document.datacollect.price.value;
if(unitsfield==0)
{
	alert("Please enter the number of License Units as a number between 1 and 10,000");
	document.datacollect.q.focus();
	return false;
}
var p=77;
if(editionfield=='Standard'&&ecommercefield=="No")
{
	p=0;
}
else if(editionfield=='Pro'&&ecommercefield=="No")
{
	p=1;
}
else if(editionfield=='Standard'&&ecommercefield=="Yes")
{
	p=2;
}
if(editionfield=='Pro'&&ecommercefield=="Yes")
{
	p=3;
}
if(!promofield=="")
{
	p=4;
	unitsfield=pricefield;
}
var productArray=new Array('4448AG0001','4448AG0002','44484448AG0003','444844480004','4448AG0005');
var selectedCode=(productArray[p]);
document.datacollect.productcode.value=selectedCode;
var msg='https://www.swreg.org/cgi-bin/b.cgi?s=4448' + '&p=' + selectedCode + '&v=0&d=0&q='
 + unitsfield;
document.datacollect.swreg.value=msg;
return;
}


//Calculate total price of order
function price()
{
//If viewer changes any field except promo field, assume it is not a promotion
document.datacollect.promo.value="";
var unitsfield=document.datacollect.q.value;
var editionfield=document.datacollect.edition.value;
var ecommercefield=document.datacollect.ecommerce.value;
if(unitsfield=="")
{
	document.datacollect.price.value=""
	return;
}
if(isNaN(unitsfield)||unitsfield<=0||(parseInt(unitsfield)!=unitsfield))
{
	document.datacollect.price.value="";
	alert("Please enter the number of License Units as a number between 1 and 10,000");
	document.datacollect.q.focus();
	return false;
}
if(unitsfield>10000)
{
	alert("Please contact us directly for special discount pricing");
	document.datacollect.q.focus();
	return false;
}
var tier
var numberComb=4;
var selectComb;
if(editionfield=='Standard'&&ecommercefield=="No")
{
	selectComb=0;
}
else if(editionfield=='Pro'&&ecommercefield=="No")
{
	selectComb=1;
}
else if(editionfield=='Standard'&&ecommercefield=="Yes")
{
	selectComb=2;
}
else if(editionfield=='Pro'&&ecommercefield=="Yes")
{
	selectComb=3;
}
var tierArray=new Array(0,10,50,100,500,1000,2500,10000);
var priceTotalArray=new Array(15.00, 16.50, 18.00, 18.75, 10.00, 11.00, 12.00, 12.50, 9.00, 9.90, 10.80, 11.25, 6.00, 6.60, 7.20, 7.50, 5.00, 5.50, 6.00, 6.25, 4.00, 4.40, 4.80, 5.00, 2.00, 2.20, 2.40, 2.50);
var index;
for(index=0;index<7;index++)
{
	if(unitsfield>tierArray[index]&&unitsfield<=tierArray[index+1])
	{
		tier=(index*numberComb+selectComb);
		var totalCost=Math.round(priceTotalArray[tier]*document.datacollect.q.value*100);
		totalCost= new String(totalCost/100);
		var point=totalCost.lastIndexOf(".");
		var zeros=(totalCost.length-point-1)
		if(zeros==1)
		{
			totalCost=totalCost+"0";
		}
	document.datacollect.price.value=totalCost;
	break;
	}
}
return true;
}

//Feedback
function validatefb()
{
var osVersionfield=document.fdback.osVersion.value;
if(osVersionfield=="")
{
	alert("Please input the Version/Service pack of the Operating System you are using.");
	document.fdback.osVersion.focus();
	return false;
}
var namefield=document.fdback.name.value;
if(namefield=="")
{
	alert("Please input your name.");
	document.fdback.name.focus();
	return false;
}
var loginfield=document.fdback.login.value;
if(loginfield=="")
{
	alert("Please input your User login.");
	document.fdback.login.focus();
	return false;
}
if(!email(document.fdback.email.value))
{
	document.fdback.email.focus();
	return false
}
var companyfield=document.fdback.company.value;
if(companyfield=="")
{
	alert("Please input the name of your Company.");
	document.fdback.company.focus();
	return false;
}
var ezlmfield=document.fdback.ezlmVersion.value;

var ezlmVsnfield=document.fdback.otherVersion.value;
if(ezlmfield=="Other"&&ezlmVsnfield=="")
{
	alert ("Please input the version of EasyLicenser you are using.");
	document.fdback.otherVersion.focus();
	return false;
}
var javafield=document.fdback.javaVersion.value;
var javaVsnfield=document.fdback.otherJava.value;
if(javafield=="other"&&javaVsnfield=="")
{
	alert ("Please input the version of Java SDK you are using.");
	document.fdback.otherJava.focus();
	return false;
}
}

//Contact Us
function validatect()
{

var namefield=document.contact.name.value;
var topicfield=document.contact.topic.value;
var phonefield=document.contact.phone.value;
var companyfield=document.contact.company.value;
var emailfield=document.contact.email.value;
var messagefield=document.contact.message.value;
var subOther=document.contact.otherSubject.value;
if(phonefield==""||topicfield==""||namefield==""||companyfield==""||emailfield==""||messagefield=="")
{
	alert("Please complete all fields.");
	return false;
}
if(!email(document.contact.email.value))
{
	document.contact.email.focus();
	return false;
}
if(!phone(document.contact.phone.value))
{
	document.contact.phone.focus();
	return false;
}
if(topicfield=="Other"&&subOther=="")
{
	alert ("Please enter your Subject.");
	document.contact.otherSubject.focus();
	return false;
}
}

//webinar Idea
function validatewebi()
{

var namefield=document.webinarIdeas.name.value;
var phonefield=document.webinarIdeas.phone.value;
var companyfield=document.webinarIdeas.company.value;
var emailfield=document.webinarIdeas.email.value;
var suggestield=document.webinarIdeas.suggestion.value;

if((phonefield == "" || namefield == "" || companyfield =="" || emailfield=="") && (suggestield=="" || checkCheckBoxes()))
{
	alert("Please complete all fields.");
	return false;
}

if((suggestield=="" && !checkCheckBoxes()))
{
	alert("Please complete all fields .");
	return false;
}

if(!email(document.webinarIdeas.email.value))
{
	document.webinarIdeas.email.focus();
	return false;
}
if(!phone(document.webinarIdeas.phone.value))
{
	document.webinarIdeas.phone.focus();
	return false;
}

}

// Make promo
function validatemkp()
{
var unamefield=document.mkpromo.username.value;
var namefield=document.mkpromo.name.value;
var passwordfield=document.mkpromo.password.value;
var phonefield=document.mkpromo.phone.value;
var companyfield=document.mkpromo.company.value;
var emailfield=document.mkpromo.email.value;
var lufield=document.mkpromo.licenseunits.value;
var amtfield=document.mkpromo.amount.value;
if(unamefield==""||passwordfield==""||phonefield==""||amtfield==""||namefield==""||companyfield==""||emailfield==""||lufield=="")
{
	alert("Please complete all fields.");
	return false;
}
if(!email(document.mkpromo.email.value))
{
	document.mkpromo.email.focus();
	return false
}
if(!phone(document.mkpromo.phone.value))
{
	document.mkpromo.phone.focus();
	return false
}
if(isNaN(lufield)||lufield<=0||parseInt(lufield)!=lufield) {
	alert("Please enter a valid positive integer for license units.");
	document.mkpromo.licenseunits.focus();
	return false
}
if(isNaN(amtfield)||amtfield<=0||parseInt(amtfield)!=amtfield) {
	alert("Please enter a valid positive integer for transaction amount.");
	document.mkpromo.amount.focus();
	return false
}
}

//Tell a Friend
function validatetaf()
{
if(!email(document.tellfriend.collEmail.value))
{
	document.tellfriend.collEmail.focus();
	return false
}
if(!email(document.tellfriend.email.value))
{
	document.tellfriend.email.focus();
	return false
}
}

//Problem Submission
function validateps()
{
var ezlmfield=document.probsub.ezlmVsn.value;
var ezlmVsnfield=document.probsub.otherVersion.value;
if(ezlmfield=="Other"&&ezlmVsnfield=="")
{
	alert ("Please input the version of EasyLicenser you are using.");
	document.probsub.otherVersion.focus();
	return false;
}
var javafield=document.probsub.javaVersion.value;
var javaVsnfield=document.probsub.otherJava.value;
if(javafield=="other"&&javaVsnfield=="")
{
	alert ("Please input the version of Java SDK you are using.");
	document.probsub.otherJava.focus();
	return false;
}
var osVersionfield=document.probsub.osVersion.value;
if(osVersionfield=="")
{
	alert("Please input the Version/Service pack of the Operating System you are using.");
	document.probsub.osVersion.focus();
	return false;
}
var namefield=document.probsub.name.value;
if(namefield=="")
{
	alert("Please input your name.");
	document.probsub.name.focus();
	return false;
}

if(!email(document.probsub.email.value))
{
	document.probsub.email.focus();
	return false
}

var companyfield=document.probsub.company.value;
if(companyfield=="")
{
	alert("Please input the name of your Company.");
	document.probsub.company.focus();
	return false;
}
var loginfield=document.probsub.login.value;
if(loginfield=="")
{
	alert("Please input your login name.");
	document.probsub.login.focus();
	return false;
}
}

//Download
function validatedl()
{
var namefield=document.fmdownload.name.value;
var companyfield=document.fmdownload.company.value;
var emailfield=document.fmdownload.email.value;
var otherfield=document.fmdownload.otherHeard.value;
var hearfield=document.fmdownload.howheard.value;

if(emailfield==""||companyfield==""||namefield=="")
{
	alert("Please complete all fields before downloading.");
	return false;
}
if(!email(document.fmdownload.email.value))
{
	document.fmdownload.email.focus();
	return false
}
if(hearfield=="trade"&&otherfield=="")
{
	alert("Please enter the name of the trade magazine in which you read about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="javanews"&&otherfield=="")
{
	alert("Please tell us in which Java Newsgroup you heard about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="othernews"&&otherfield=="")
{
	alert("Please tell us in which Newsgroup you heard about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="download"&&otherfield=="")
{
	alert("Please tell us in which Download site you heard about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="othercampaign"&&otherfield=="")
{
	alert("Please tell us in which email campaign you heard about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="other"&&otherfield=="")
{
	alert("Please tell us where you heard about our products");
	document.fmdownload.otherHeard.focus();
	return false;
}
if(hearfield=="web"&&otherfield=="")
{
	alert("Please enter the name of the search engine you used to find us");
	document.fmdownload.otherHeard.focus();
	return false;
}
return document.MM_returnValue
}


//Questionnaire
function validatequ()
{
var namefield=document.questionnaire.name.value;
if(namefield=="")
{
	alert("Please enter your name");
	document.questionnaire.name.focus();
	return false;
}
var companyfield=document.questionnaire.company.value;
if(companyfield=="")
{
	alert("Please enter your Company name");
	document.questionnaire.company.focus();
	return false;
}
if(!email(document.questionnaire.email.value))
{
	document.questionnaire.email.focus();
	return false
}
if(!phone(document.questionnaire.phone.value))
{
	document.questionnaire.phone.focus();
	return false
}
if(!document.questionnaire.altPhone.value=="")
{
	if(!phone(document.questionnaire.altPhone.value))
	{
		document.questionnaire.altPhone.focus();
	return false
	}
}
var urlfield=document.questionnaire.url.value;
var validUrl = /^(http|https|ftp):\/\/(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i;
var isValid=(validUrl.test(urlfield));
if(isValid==false&&urlfield!=""&&urlfield!="http://")
{
	alert("There is a problem with the format of your website url.");
	document.questionnaire.url.focus();
	return false;
}
var hearfield=document.questionnaire.hearabout.value;

var otherHearfield=document.questionnaire.otherHear.value;
if(hearfield=="trade"&&otherHearfield=="")
{
	alert("Please enter the name of the trade magazine in which you read about our products");
	document.questionnaire.hearabout.focus();
	return false;
}
if(hearfield=="other"&&otherHearfield=="")
{
	alert("Please tell us where you heard about our products");
	document.questionnaire.hearabout.focus();
	return false;
}
var hearfield=document.questionnaire.hearabout.value;
var otherHearfield=document.questionnaire.otherHear.value;
if(hearfield=="web"&&otherHearfield=="")
{
	alert("Please enter the name of the search engine you used to find us");
	document.questionnaire.hearabout.focus();
	return false;
}
var langfield=document.questionnaire.otherLang.checked;
var otherLangfield=document.questionnaire.inOtherLang.value;
if(langfield==true&&otherLangfield=="")
{
	alert("Please enter the name of the language/environment you use");
	document.questionnaire.inOtherLang.focus();
	return false;
}
var appsfield=document.questionnaire.otherApps.checked;
var otherAppsfield=document.questionnaire.inOtherApps.value;
if(appsfield==true&&otherAppsfield=="")
{
	alert("Please enter the type of application you are developing");
	document.questionnaire.inOtherApps.focus();
	return false;
}
var osfield=document.questionnaire.otherOS.checked;
var otherOSfield=document.questionnaire.inOtherOS.value;
if(osfield==true&&otherOSfield=="")
{
	alert("Please enter the name of the platform that you use");
	document.questionnaire.inOtherOS.focus();
	return false;
}
return true;
}

//email cannot be blank
function email(emailfield)
{
if(emailfield=="")
{
	alert("Please input email address.");
	return false;
}
var validEmail=/^\w(\.?[-\w])*@\w(\.?[-\w])*\.[a-z]{2,4}$/i;
var isValid=(validEmail.test(emailfield));
if(isValid==false)
{
	alert("There is a problem with the format of the email address.");
	return false;
}
return true;
}

//email can be blank
function emailif(emailfield)
{
var validEmail=/^\w(\.?[-\w])*@\w(\.?[-\w])*\.[a-z]{2,4}$/i;
var isValid=(validEmail.test(emailfield));
if(isValid==true||emailfield=="")
{
return true;
}
else
{
	alert("There is a problem with the format of the email address.");
	return false;
}
}

function phone(phonefield)
{
if(phonefield=="")
{
	alert("Please input your phone number.");
	return false;
}
var validPhone=/^(\+)?(\d{1,3} ?)?(\(\d{1,5}\)|\d{1,5})( ?|[-])\d{3}( ?|[-])\d{0,7}( ?(x|xtn|ext|extn|extension)?\.? ?\d{1,5})?$/i;
regex = /-/gi;
phonefield = phonefield.replace(regex," ");
//alert("Phone Value>>>>" + phonefield);
var isValid=(validPhone.test(phonefield));
if(isValid==false)
{
	alert("There is a problem with the format of your phone number.");
	return false;
}

return true;
}




//Promo Code
function promocode()
{
var promofield=document.datacollect.promo.value
if(promofield=="")
{
	return;
}

if(!validPromo(promofield))
{	
    alert("Invalid promo code");
	document.datacollect.promo.focus();
	return false;
}
var word=promofield.split(".");
if(word[0].charAt(0)=="S")
{
	document.datacollect.edition.value="Standard"
}
else
{
document.datacollect.edition.value="Pro"}
if(word[0].charAt(1)=="E")
{
	document.datacollect.ecommerce.value="Yes"
}
else
{
	document.datacollect.ecommerce.value="No"
}
word[0]=word[0].slice(2,10);
document.datacollect.q.value=word[0];
document.datacollect.price.value=word[1];
return true;
}

//Promo Syntax
function validPromo(promofield)
{
var validPromo=/^(S|P)(E|N)(\d+)\.(\d+)\.(\d+)\.(\d+)$/;
var isValid=(validPromo.test(promofield));
if(isValid==true)
{	
	var word=promofield.split(".");
	var periodCount=0
	var myString=new String(promofield);
	var checksum=0;var count=0;
	for(count=0; count<myString.length; count++)
	{
		if(myString.charCodeAt(count)!=46)
		{
			checksum=checksum + myString.charCodeAt(count);
		}
		else
		{
			periodCount=periodCount+1
			if(periodCount==3)
			{
				if(checksum!=word[3])
				{
					break;
				}
				return true;
			}
		}
	}	
}
{
	alert("There is a problem with the format of the promotion code.");
	document.datacollect.promo.focus();
	return false;
}
return true;
}

function mactest(mac)
{
var validMAC=/^(([0-9ABCDEF]{2}:){5}[0-9ABCDEF]{2})|(([0-9ABCDEF]{2}-){5}[0-9ABCDEF]{2})$/i;
var isValid=(validMAC.test(mac));
if(isValid==false)
{
	alert("There is a problem with the format of your MAC address.");
	return false;
}
return true;
}

//Dreamweaver functions
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_callJS(jsStr) { //v2.0
  return eval(jsStr)
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

// JavaScript Document

// end absolutely positioned scrollable area object scripts 


