function getVariable(varName){
	var arg=location.search.substring(1).split('&');
	var variable="";
	var i;
	for(i=0;i<arg.length;i++){
		if(arg[i].split('=')[0]==varName){
			if(arg[i].split('=').length>1){
				variable=arg[i].split('=')[1]
			}
			return variable
		}
	}
	return ""
}

function init(){
	var type = getVariable("type");
	var s = document.forms["Customer"].cmbPlatform;
	if(type == "java"){
		s.selectedIndex = 1;
	}
	else{
		s.selectedIndex = 0;
	}
	changeSelect(s);
}

window.onload = init;

function checkTrialRequiredFields()
{
	SetProductId();
	var f = document.forms["Customer"];
	var str = "";
	if(isSpacerLine(f.txtFirstName.value))str+="Enter first name.";
	if(isSpacerLine(f.txtLastName.value))str+="\nEnter last name.";
	if(isSpacerLine(f.txtOrganization.value))str+="\nEnter organization.";
	if(isSpacerLine(f.cmbPlatform.value))str+="\nEnter Product."
	if(isSpacerLine(f.txtPhone.value))str+="\nEnter Work phone."
	if(isSpacerLine(f.cmbOperSys.value))str+="\nEnter Operating System."
	if(isSpacerLine(f.cmbUseForm.value))str+="\nEnter CodeLogic Use Form."
	if(isSpacerLine(f.txtEmail.value)){
		str+="\nEnter e-mail."
	}
	else if(isEmail(f.txtEmail.value)){
		str+="\nE-mail is incorrect."
		}
		else {
			var D = domain.split(",");
			var deny = false;
			for(var i=0;i<D.length;i++){
				var tmpStr = f.txtEmail.value.toLowerCase();
				if (tmpStr.indexOf(D[i].toLowerCase())!=-1)deny = true;
		}
		if(deny)str+="\nAll registrations for demos and software licenses must be made to a subscribed email service. Anonymous email services such as Hotmail, Yahoo, etc. are not permitted.";
	}
	if(str!="")alert(str);
	return (str=="");
	//return false
}

var ProductsArray = new Array();
ProductsArray["C#_Windows_StandaloneApp"] = 1;
ProductsArray["C#_Windows_VisualStudioPlugin"] = 2;

ProductsArray["Java_Windows_JBuilder"] = 3;
ProductsArray["Java_Windows_JDeveloper"] = 4;
ProductsArray["Java_Windows_IntelliJ (Pre-Version 5)"] = 5;
ProductsArray["Java_Windows_Eclipse"] = 6;
ProductsArray["Java_Windows_StandaloneApp"] = 7;

ProductsArray["Java_Linux_JBuilder"] = 8;
ProductsArray["Java_Linux_JDeveloper"] = 9;
ProductsArray["Java_Linux_IntelliJ (Pre-Version 5)"] = 10;
ProductsArray["Java_Linux_Eclipse"] = 11;
ProductsArray["Java_Linux_StandaloneApp"] = 12;

ProductsArray["Java_LinuxInstaller_JBuilder"] = 13;
ProductsArray["Java_LinuxInstaller_JDeveloper"] = 14;
ProductsArray["Java_LinuxInstaller_IntelliJ (Pre-Version 5)"] = 15;
ProductsArray["Java_LinuxInstaller_Eclipse"] = 16;
ProductsArray["Java_LinuxInstaller_StandaloneApp"] = 17;

ProductsArray["Java_Solaris_JBuilder"] = 18;
ProductsArray["Java_Solaris_JDeveloper"] = 19;
ProductsArray["Java_Solaris_IntelliJ (Pre-Version 5)"] = 20;
ProductsArray["Java_Solaris_Eclipse"] = 21;
ProductsArray["Java_Solaris_StandaloneApp"] = 22;
/*
ProductsArray["Java_MacOSX_JBuilder"] = 23;
ProductsArray["Java_MacOSX_JDeveloper"] = 24;
ProductsArray["Java_MacOSX_IntelliJ (Pre-Version 5)"] = 25;
ProductsArray["Java_MacOSX_Eclipse"] = 26;
ProductsArray["Java_MacOSX_StandaloneApp"] = 27;
*/
function SetProductId()
{
	try{
		var platform = document.forms["Customer"].cmbPlatform;
		var opsys = document.forms["Customer"].cmbOperSys;
		var useform = document.forms["Customer"].cmbUseForm;
		var product = document.forms["Customer"].txtProduct;
		
		paramStr = platform.options[platform.selectedIndex].value + "_" + opsys.options[opsys.selectedIndex].value + "_" + useform.options[useform.selectedIndex].value;
		
		product.value = ProductsArray[paramStr];
	}
	catch(e)
	{
		product.value = 7;
	}
}

function changeSelect(select){
	var s = document.forms["Customer"].cmbUseForm;
	var p = document.forms["Customer"].cmbOperSys;
	s.options.length = 0;
	p.options.length = 0;
	if(select.options[select.selectedIndex].value=="Java"){
		
		s.options[s.options.length] = new Option("JBuilder plugin", "JBuilder");
		s.options[s.options.length] = new Option("JDeveloper plugin", "JDeveloper");
		s.options[s.options.length] = new Option("IntelliJ IDEA plugin (Pre-Version 5)", "IntelliJ (Pre-Version 5)");
		s.options[s.options.length] = new Option("Eclipse plugin", "Eclipse");
		s.options[s.options.length] = new Option("Standalone Application", "StandaloneApp",true,true);
		
		p.options[p.options.length] = new Option("Windows 98, ME, 2000, XP", "Windows",true,true)
		p.options[p.options.length] = new Option("Linux", "Linux")
		p.options[p.options.length] = new Option("Linux (Generic Installer for older versions)", "LinuxInstaller")
		p.options[p.options.length] = new Option("Solaris", "Solaris")
	//	p.options[p.options.length] = new Option("MacOSX", "MacOSX")
		
	}
	else{
		s.options[s.options.length] = new Option("VisualStudio plugin", "VisualStudioPlugin");
		s.options[s.options.length] = new Option("Standalone Application", "StandaloneApp",true,true);
		
		p.options[p.options.length] = new Option("Windows 98, ME, 2000, XP", "Windows",true,true)
	}
}
