function email_redir(referer){

if(referer == 'order')
	document.location='http://www.totalcontrolsolutions.com/inquiry_order.php';
else if(referer == 'product')
	document.location='http://www.totalcontrolsolutions.com/inquiry_product.php';
else if(referer == 'support')
	document.location='http://www.totalcontrolsolutions.com/inquiry_support.php';
else if(referer == 'product_order_info')
	document.location='http://www.totalcontrolsolutions.com/inquiry_product_order_info.php';
else
	document.location='http://www.totalcontrolsolutions.com/inquiry_contact.php';


}

function validatefaqcat(fc_title)
{

	if(document.getElementById(fc_title).value == ""){
		alert('Please enter a title for this FAQ category.');
		document.getElementById(fc_title).focus();
		return false;
	}
}

function validateDist(dist_name, dist_phone, dist_address, dist_city, dist_state, dist_zip, dist_country, dist_email, dist_tcs_rep_email1, dist_tcs_rep_email2)
{

	if(document.getElementById(dist_name).value == ""){
		alert('Please enter a distributor name and try again.');
		document.getElementById(dist_name).focus();
		return false;
	}
	if(document.getElementById(dist_phone).value == ""){
		alert('Please enter a distributor phone number and try again.');
		document.getElementById(dist_phone).focus();
		return false;
	}
	if(document.getElementById(dist_address).value == ""){
		alert('Please enter a distributor address and try again.');
		document.getElementById(dist_address).focus();
		return false;
	}
	if(document.getElementById(dist_city).value == ""){
		alert('Please enter a distributor city and try again.');
		document.getElementById(dist_city).focus();
		return false;
	}
	if(document.getElementById(dist_state).value == ""){
		alert('Please enter a distributor state and try again.');
		document.getElementById(dist_state).focus();
		return false;
	}
	if(document.getElementById(dist_zip).value == ""){
		alert('Please enter a distributor zip code and try again.');
		document.getElementById(dist_name).focus();
		return false;
	}
	if(document.getElementById(dist_country).value == ""){
		alert('Please enter a distributor country and try again.');
		document.getElementById(dist_country).focus();
		return false;
	}

	if (document.getElementById(dist_email).value.length > 0)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById(dist_email).value))
		{
			//valid email
		}
		else
		{
				alert('The Email Address You Entered Is Invalid. Please Try Again!');
				document.getElementById(dist_email).focus();
				return false;
		}
	}else
	{
		alert('Please enter a valid email address');
		document.getElementById(dist_email).focus();
		return false;
	}

	if (document.getElementById(dist_tcs_rep_email1).value.length > 0)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById(dist_tcs_rep_email1).value))
		{
			//valid email
		}
		else
		{
				alert('The Email Address You Entered Is Invalid. Please Try Again!');
				document.getElementById(dist_tcs_rep_email1).focus();
				return false;
		}
	}else
	{
		alert('Please enter a valid email address');
		document.getElementById(dist_tcs_rep_email1).focus();
		return false;
	}

	if (document.getElementById(dist_tcs_rep_email2).value.length > 0)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById(dist_tcs_rep_email2).value))
		{
			//valid email
		}
		else
		{
				alert('The Email Address You Entered Is Invalid. Please Try Again!');
				document.getElementById(dist_tcs_rep_email2).focus();
				return false;
		}
	}else
	{
		alert('Please enter a valid email address');
		document.getElementById(dist_tcs_rep_email2).focus();
		return false;
	}

}



function validateSystem(ds_name, ds_desc, file, ds_components)
{

	if(document.getElementById(ds_name).value == ""){
		alert('Please enter a part number for this system and try again.');
		document.getElementById(ds_name).focus();
		return false;
	}
	if(document.getElementById(ds_desc).value == ""){
		alert('Please enter a short description for this system and try again.');
		document.getElementById(ds_desc).focus();
		return false;
	}
	if(document.getElementById(file).value == ""){
		alert('Please select an image from your PC to upload.');
		document.getElementById(file).focus();
		return false;
	}
	if(document.getElementById(ds_components).value == ""){
		alert('Please add one or more components to this system and try again.');
		document.getElementById(ds_components).focus();
		return false;
	}
	if(document.getElementById(ds_components).value == "0"){
		alert('Please add one or more components to this system and try again.');
		document.getElementById(ds_components).focus();
		return false;
	}

}




function validateParts(prod_id, prod_desc, prod_price)
{

	if(document.getElementById(prod_id).value == ""){
		alert('Please select a product to add to the pricing table.');
		document.getElementById(prod_id).focus();
		return false;
	}
	if(document.getElementById(prod_id).value == "0"){
		alert('Please select a product to add to the pricing table.');
		document.getElementById(prod_id).focus();
		return false;
	}
	if(document.getElementById(prod_desc).value == ""){
		alert('Please enter a short description for this product.');
		document.getElementById(prod_desc).focus();
		return false;
	}
	if(document.getElementById(prod_price).value == ""){
		alert('Please enter a price.');
		document.getElementById(prod_price).focus();
		return false;
	}

}


function validateCust(cust_company, cust_phone, cust_email, cust_name, qty)
{

	if(document.getElementById(cust_company).value == ""){
		alert('Please enter a company name.');
		document.getElementById(cust_company).focus();
		return false;
	}
	if(document.getElementById(cust_phone).value == ""){
		alert('Please enter a phone number where we can reach you.');
		document.getElementById(cust_phone).focus();
		return false;
	}
	if (document.getElementById(cust_email).value.length > 0)
	{
		if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,6})+$/.test(document.getElementById(cust_email).value))
		{
			//valid email
		}
		else
		{
				alert('The Email Address You Entered Is Invalid. Please Try Again!');
				document.getElementById(cust_email).focus();
				return false;
		}
	}else
	{
		alert('Please enter a valid email address');
		document.getElementById(cust_email).focus();
		return false;
	}
	if(document.getElementById(cust_name).value == ""){
		alert('Please enter your name.');
		document.getElementById(cust_name).focus();
		return false;
	}
	if(document.getElementById(qty).value == ""){
		alert('How many systems do you need?');
		document.getElementById(qty).focus();
		return false;
	}

}

function validateNode(node_name)
{

	if(document.getElementById(node_name).value == ""){
		alert('Please enter a name for this node and try again.');
		document.getElementById(node_name).focus();
		return false;
	}
}

function popUp1(url) { open(url,"","height=300,width=400,scrollbars=no; window.focus()"); }

function popUp2(url) { open(url,"","height=450,width=550,scrollbars=no; window.focus()"); }

function popUp3(url) { open(url,"","height=460,width=500,scrollbars=1; window.focus()"); }

function popUp4(url) { open(url,"","height=500,width=500,scrollbars=auto; window.focus()"); }

function popUp5(url) { open(url,"","height=630,width=500,scrollbars=no; window.focus()"); }

function popUp6(url) { open(url,"","height=150,width=300,scrollbars=no; window.focus()"); }

function popUp7(url) { open(url,"","height=550,width=625,scrollbars=auto; window.focus()"); }

function popUp8(url) { open(url,"","height=600,width=610,scrollbars=auto; window.focus()"); }

function popUp9(url) { open(url,"","height=500,width=500,scrollbars=auto; window.focus()"); }

function popUp10(url) { open(url,"","height=500,width=450,scrollbars=1; window.focus()"); }

function popUp11(url) { open(url,"","height=300,width=400,scrollbars=1; window.focus()"); }

function makevisible(cur,which)
  {
    if (which==0)
      cur.filters.alpha.opacity=100
    else
      cur.filters.alpha.opacity=40
  }


function openWin( windowURL, windowName, windowFeatures )
  {
    return window.open( windowURL, windowName, windowFeatures ) ;
  }

function makevisible(cur,which){
if (which==0)
cur.filters.alpha.opacity=100
else
cur.filters.alpha.opacity=70
}


function borderit(which,color){
//if IE 4+ or NS 6+
if (document.all||document.getElementById){
which.style.borderColor=color
}
}


function clickclear(thisfield, defaulttext) {
if (thisfield.value == defaulttext) {
thisfield.value = "";
}
}

function clickrecall(thisfield, defaulttext) {
if (thisfield.value == "") {
thisfield.value = defaulttext;
}
}

