var agent = navigator.userAgent.toLowerCase();
//var app = navigator.appName.toLowerCase();
var ie = agent.indexOf("msie 4")>0 && agent.indexOf("aol")<0 && agent.indexOf("mac")<0 && agent.indexOf("netscape")<0

function ValidateEmail(str)
{
	var ret = false;
	if (typeof(str) != "undefined")
	{
		if (/^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test(str))
		{
	
		ret = str;
		}
	}
	
	return ret;
}

function OpenDetail()
{
	var Sel = document.MainFrm.elements['ProdSelect'];
	var prodString = Sel.options[Sel.selectedIndex].value.split(';')[0];
	var file = "../Products/" + prodString + "/index.htm";
	var win = window.open(file,"1","height=300,width=400,location=no,menubar=no,resizable=no,scrollbars=yes,status=no,toolbar=no");
	win.focus();
	win.moveTo(15,15);
	
}

function openTerms()
{
	var file = "./DavesplaceEULA.htm";
	var win = window.open(file,"1","height=400,width=600,location=no,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
	win.focus();
	win.moveTo(15,15);
	
}

function ValidateFields()
{
	if (document.MainFrm.elements['FirstNamTxt'].value == "")
	{
		alert("Please complete all fields (first name).");
	}
	else if (document.MainFrm.elements['LastNamTxt'].value == "")
	{
		alert("Please complete all fields (last name).");
	}
	else if (!ValidateEmail(document.MainFrm.elements['EmailTxt'].value))
	{
		alert("Please enter a valid email address.");
	}
	else if (!document.MainFrm.elements['TermChk'].checked)
	{
		alert("You must agree to the terms of sale before proceeding!");
	}
	else if (document.MainFrm.elements['Addr1Txt'].value == "")
	{
		alert("Please complete all fields (address)");
	}
	else if (document.MainFrm.elements['CityTxt'].value == "")
	{
		alert("Please complete all fields (City)");
	}
	else if (document.MainFrm.elements['StateTxt'].value == "")
	{
		alert("Please complete all fields (State)");
	}
	else if (document.MainFrm.elements['ZipTxt'].value == "")
	{
		alert("Please complete all fields (Zip)");
	}
	else if (document.MainFrm.elements['PhoneTxt'].value == "")
	{
		alert("Please complete all fields (Phone)");
	}
	else //Looks like they entered something for all the fields, so we can do our thang!
	{
		__doPostBack('PurchasePost','');
	}
}
