// IMAGE SWAP
function changeImage(imageName, over) 
{
	if(window.document.images) 
  	{
    	if (over)
      		window.document.images[imageName].src = "images/navigation/" + imageName + "_over.gif";
    	else
      		window.document.images[imageName].src = "images/navigation/" + imageName + ".gif";
  	}
}

function reDo() 
{ 
	window.location.reload(); 
} 

window.onresize = reDo;

//Define global variables
var timerID = null;
var timerOn = false;
var timecount = 2000;

// Change this to the time delay that you desire
var what = null;
var newbrowser = true;
var check = false; 

function init(elementName) 
{ 
	if (document.layers) 
	{ 
		layerRef="document.layers"; 
		styleSwitch=""; 
		visibleVar="show"; 
		screenSize = window.innerWidth; 
		what ="ns4"; 
	} 
	else if(document.all) 
	{ 
		layerRef="document.all"; 
		styleSwitch=".style"; 
		visibleVar="visible"; 
		screenSize = document.body.clientWidth + 18; 
		what ="ie4"; 
	} 
	else if(document.getElementById) 
	{ 
		layerRef="document.getElementByID"; 
		styleSwitch=".style"; 
		visibleVar="visible"; 
		what="dom1"; 
	} 
	else 
	{ 
		what="none"; 
		newbrowser = false; 
	} 

	check = true; 

	hideAll(elementName)
} 

// Toggles the layer visibility on 
function showlayer(elementName) 
{
	if(check) 
	{ 
		if (what =="none") 
		{ 
			return; 
		} 
		else if (what == "dom1") 
		{ 
			document.getElementById(elementName + "_div").style.visibility="visible"; 
			document.images[elementName].src = "images/navigation/" + elementName + "_over.gif";
		} 
		else 
		{ 
			eval(layerRef+'["'+elementName+'_div"]'+styleSwitch+'.visibility="visible"'); 
			document.images[elementName].src = "images/navigation/" + elementName + "_over.gif";
		} 
	} 
	else 
	{ 
		return; 
	} 
} 
 
// Toggles the layer visibility off 
function hidelayer(elementName) 
{ 
	if(check) 
	{ 
		if (what =="none") 
		{ 
			return; 
		} 
		else if (what == "dom1") 
		{ 
			document.getElementById(elementName + "_div").style.visibility="hidden"; 
		} 
		else 
		{ 
			eval(layerRef+'["'+elementName+'_div"]'+styleSwitch+'.visibility="hidden"'); 
		} 
	} 
	else 
	{ 
		return; 
	} 
} 
 
function hideAll(elementName) 
{ 
	if (elementName != "introduction")
		hidelayer('introduction'); 
	if (elementName != "our_products")
		hidelayer('our_products');
	if (elementName != "how_they_work")
		hidelayer('how_they_work');
	if (elementName != "why_ultratone")
		hidelayer('why_ultratone');
	if (elementName != "contact_us")
		hidelayer('contact_us');
	if (elementName != "professional_product")
		hidelayer('professional_product');
	if (elementName != "introduction")
		document.images['introduction'].src = "images/navigation/introduction.gif";
	if (elementName != "our_products")
		document.images['our_products'].src = "images/navigation/our_products.gif";
	if (elementName != "how_they_work")
		document.images['how_they_work'].src = "images/navigation/how_they_work.gif";
	if (elementName != "why_ultratone")
		document.images['why_ultratone'].src = "images/navigation/why_ultratone.gif";
	if (elementName != "contact_us")
		document.images['contact_us'].src = "images/navigation/contact_us.gif";
	if (elementName != "professional_product")
		document.images['professional_product'].src = "images/navigation/professional_product.gif";
} 
 
function hideAllMouseOut(layerName, imageName) 
{ 
	if (layerName != "introduction")
		hidelayer('introduction'); 
 
	if (layerName != "our_products")
		hidelayer('our_products'); 
 
	if (layerName != "how_they_work")
		hidelayer('how_they_work'); 
 
	if (layerName != "why_ultratone")
		hidelayer('why_ultratone');
 
	if (layerName != "contact_us")
		hidelayer('contact_us');
 
	if (layerName != "professional_product")
		hidelayer('professional_product');
 
	document.getElementById('secondary').style.background = 'url(images/navigation/background_secondary.gif)';
	document.images[imageName].src = "images/navigation/" + imageName + ".gif";
} 
 
function startTime(elementName, imageName) 
{ 
	if (timerOn == false) 
	{ 
		timerID=setTimeout( "hideAllMouseOut('" + elementName + "','" + imageName + "')" , timecount); 
		timerOn = true; 
	} 
} 
 
function stopTime() 
{ 
	if (timerOn) 
	{ 
		clearTimeout(timerID); 
		timerID = null; 
		timerOn = false; 
	} 
 
	document.getElementById('secondary').style.background = 'url(images/navigation/background_secondary_over.gif)';
} 
 
function onLoad() 
{ 
	init(); 
}

function brochureValidation() 
	{
		missinginfo = "";
		
		if(!document.brochure_form.facial_plus.checked && !document.brochure_form.futura_systems.checked && !document.brochure_form.sportif_athletic.checked && !document.brochure_form.professional_salon.checked) 
		{
			missinginfo += "\n     -  Required brochure(s)";
		}
		
		if (document.brochure_form.title.value == "0") 
		{
			missinginfo += "\n     -  Title";
		}
		
		if (document.brochure_form.name.value == "")
		{
			missinginfo += "\n     -  Name";
		}
		
		if (!isValidEmail(document.brochure_form.email.value))
		{
			missinginfo += "\n     -  Email";
		}
		
		if (document.brochure_form.street.value == "")
		{
			missinginfo += "\n     -  Street";
		}
		
		if (document.brochure_form.country.value == "")
		{
			missinginfo += "\n     -  Country";
		}
		
		if (document.brochure_form.town_city.value == "")
		{
			missinginfo += "\n     -  Town/City";
		}
		
		if (document.brochure_form.county_state.value == "")
		{
			missinginfo += "\n     -  County/State";
		}
		
		if (document.brochure_form.post_zip_code.value == "")
		{
			missinginfo += "\n     -  Post/Zip code";
		}
	
		if (missinginfo != "") 
		{
			missinginfo ="_____________________________\n" +
			"You failed to correctly fill in your:\n" +
			missinginfo + "\n_____________________________" +
			"\nPlease re-enter and submit again!";
			alert(missinginfo);
			return false;
		}
		
		else return true;
	}
	
function isValidEmail(str) 
{
	return (str.indexOf(".") > 2) && (str.indexOf("@") > 0);
}
