// create DOM flag
var DOM=(document.getElementById) ? true : false;

/** used to show/hide divs**/
function layerswap(){
	if(!DOM){return;}
	var lyr = arguments[0];
	var start = arguments[2];
	var end = arguments[3];
	for(i = start; i < end; i++){
	    	document.getElementById(lyr + i).style.visibility="hidden";
		}
	document.getElementById(lyr + arguments[1]).style.visibility="visible";
}
/*************************/

// show layer based on which toothbrush called the page
function showlayer(page,pagereferrer){
	if (page == "" || page > 20 || page == 0){
		if (pagereferrer == "power") {page = 4;}
		else {page = 20;}
	}
document.getElementById("lyr-"+page).style.visibility="visible";
}

//  when page first loads dont allow the user to link to anything  (home page only)
// this same function is also used to control where the image map links to
function showimagemap(url){
	document.getElementById('image-map').style.visibility="visible";
	var linkis = document.getElementById('linkto1');
	linkis.href = url;
}


// compute number of items selected
function checkbox_checker(){
var checkbox_choices = 0;
for (counter = 0; counter < document.compare.Product.length; counter++){
	if (document.compare.Product[counter].checked)
	{ checkbox_choices = checkbox_choices + 1; }

}
return checkbox_choices;
}

// dont allow more than 3 selections.
function check_max(){
	if (checkbox_checker() > 3 ){
		document.getElementById('error').style.visibility="visible";
		document.getElementById('error_submit').style.visibility="hidden";
		return (false);
	}else{
		document.getElementById('error').style.visibility="hidden";
		document.getElementById('error_submit').style.visibility="hidden";
		return true;
	}
}

// display message and dont allow submit if no selections have been made.
function check_min(){
if (checkbox_checker() == 0 ){
	document.getElementById('error_submit').style.visibility="visible";
	return (false);
	}else{document.compare.submit(); return true;}
}


/** DOM rollovers **/
function swapImage(){
	if(!DOM){return;}
	for(i=0; i < arguments.length; i++){
		document.getElementById(arguments[i]).setAttribute('src',arguments[++i]);
	} 
}
/*************************/

/** popper **/
function Pop(URL,winName,popW,popH){
	// set window parameters
	var winStats='toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=no,width='+popW+',height='+popH+',';
	if(navigator.appName.indexOf("Microsoft")>=0){winStats+='left=75,top=50';}
	else{winStats+='screenX=75,screenY=50';}
	var mainWindow=window.open(URL,winName,winStats);
}

/*************************/

/** queue up rollover images for navs **/

// power page image pre loads
	boxtriumphoff = new Image();
	boxtriumphoff.src = "images/power/box_triumph_off.gif";
	boxtriumphon = new Image();
	boxtriumphon.src = "images/power/box_triumph_on.gif";

	boxvitalityoff = new Image();
	boxvitalityoff.src = "images/power/box_vitality_off.gif";
	boxvitalityon = new Image();
	boxvitalityon.src = "images/power/box_vitality_on.gif";
	
	box400off = new Image();
	box400off.src = "images/power/box_400_off.gif";
	box400on = new Image();
	box400on.src = "images/power/box_400_on.gif";
	
	box5000off = new Image();
	box5000off.src = "images/power/box_5000_off.gif";
	box5000on = new Image();
	box5000on.src = "images/power/box_5000_on.gif";

	box7000off = new Image();
	box7000off.src = "images/power/box_7000_off.gif";
	box7000on = new Image();
	box7000on.src = "images/power/box_7000_on.gif";

	box8000off = new Image();
	box8000off.src = "images/power/box_8000_off.gif";
	box8000on = new Image();
	box8000on.src = "images/power/box_8000_on.gif";

	box900off = new Image();
	box900off.src = "images/power/box_900_off.gif";
	box900on = new Image();
	box900on.src = "images/power/box_900_on.gif";

	boxcapoweroff = new Image();
	boxcapoweroff.src = "images/power/box_ca_power_off.gif";
	boxcapoweron = new Image();
	boxcapoweron.src = "images/power/box_ca_power_on.gif";

	boxkidsoff = new Image();
	boxkidsoff.src = "images/power/box_kids_off.gif";
	boxkidson = new Image();
	boxkidson.src = "images/power/box_kids_on.gif";
	
	boxpowermaxoff = new Image();
	boxpowermaxoff.src = "images/power/box_powermax_off.gif";
	boxpowermaxon = new Image();
	boxpowermaxon.src = "images/power/box_powermax_on.gif";

	boxsonicoff = new Image();
	boxsonicoff.src = "images/power/box_sonic_off.gif";
	boxsonicon = new Image();
	boxsonicon.src = "images/power/box_sonic_on.gif";
	
// manual page image pre loads
	boxarticaoff = new Image();
	boxarticaoff.src = "images/manual/box_artica_off.gif";
	boxarticaon = new Image();
	boxarticaon.src = "images/manual/box_artica_on.gif";

	boxcontroloff = new Image();
	boxcontroloff.src = "images/manual/box_control_off.gif";
	boxcontrolon = new Image();
	boxcontrolon.src = "images/manual/box_control_on.gif";

	boxcrossactoff = new Image();
	boxcrossactoff.src = "images/manual/box_crossact_off.gif";
	boxcrossacton = new Image();
	boxcrossacton.src = "images/manual/box_crossact_on.gif";

	boxindicatoroff = new Image();
	boxindicatoroff.src = "images/manual/box_indicator_off.gif";
	boxindicatoron = new Image();
	boxindicatoron.src = "images/manual/box_indicator_on.gif";

	boxpulsaroff = new Image();
	boxpulsaroff.src = "images/manual/box_pulsar_off.gif";
	boxpulsaron = new Image();
	boxpulsaron.src = "images/manual/box_pulsar_on.gif";

	boxstage1off = new Image();
	boxstage1off.src = "images/manual/box_stage1_off.gif";
	boxstage1on = new Image();
	boxstage1on.src = "images/manual/box_stage1_on.gif";

	boxstage2off = new Image();
	boxstage2off.src = "images/manual/box_stage2_off.gif";
	boxstage2on = new Image();
	boxstage2on.src = "images/manual/box_stage2_on.gif";
	
	boxstage3off = new Image();
	boxstage3off.src = "images/manual/box_stage3_off.gif";
	boxstage3on = new Image();
	boxstage3on.src = "images/manual/box_stage3_on.gif";
	
	boxstage4off = new Image();
	boxstage4off.src = "images/manual/box_stage4_off.gif";
	boxstage4on = new Image();
	boxstage4on.src = "images/manual/box_stage4_on.gif";

	boxvitalizeoff = new Image();
	boxvitalizeoff.src = "images/manual/box_vitalize_off.gif";
	boxvitalizeon = new Image();
	boxvitalizeon.src = "images/manual/box_vitalize_on.gif";
	
	
/*****************************************************/
/*          home page image preloads                 */

	flossoff = new Image();
	flossoff.src = "/sk/images/home/button_floss_off.gif";
	flosson = new Image();
	flosson.src = "/sk/images/home/button_floss_on.gif";

	gooff = new Image();
	gooff.src = "/sk/images/home/button_go_off.gif";
	goon = new Image();
	goon.src = "/sk/images/home/button_go_on.gif";

	manualoff = new Image();
	manualoff.src = "/sk/images/home/button_manual_off.gif";
	manualon = new Image();
	manualon.src = "/sk/images/home/button_manual_on.gif";

	poweroff = new Image();
	poweroff.src = "/sk/images/home/button_power_off.gif";
	poweron = new Image();
	poweron.src = "/sk/images/home/button_power_on.gif";

	toothpasteoff = new Image();
	toothpasteoff.src = "/sk/images/home/button_toothpaste_off.gif";
	toothpasteon = new Image();
	toothpasteon.src = "/sk/images/home/button_toothpaste_on.gif";

	whitenoff = new Image();
	whitenoff.src = "/sk/images/home/button_whiten_off.gif";
	whitenon = new Image();
	whitenon.src = "/sk/images/home/button_whiten_on.gif";

	
