var vidSubmitAttempts=0;

function embedFlash(fPath, wMode, bgColor, fWidth, fHeight, fVars){
	document.write("<object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,65,0' width='" + fWidth + "' height='" + fHeight + "' align='middle'>");
	document.write("<param name='allowScriptAccess' value='sameDomain' />");
	document.write("<param name='wmode' value='" + wMode + "'>");
	document.write("<param name='movie' value='" + fPath + "?" + fVars + "' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='bgcolor' value='" + bgColor + "' />");
	document.write("<embed wmode='" + wMode + "' src='" + fPath + "?" + fVars + "' quality='high' bgcolor='" + bgColor + "' width='" + fWidth + "' height='" + fHeight + "' name='homebanner' align='middle' allowScriptAccess='sameDomain' type='application/x-shockwave-flash' pluginspage='http://www.macromedia.com/go/getflashplayer' />");
	document.write("</object>");
}

function preloadImg(){
		var img1 = new Image();
		img1.src = "images/menu_item1_over.gif";
		var img2 = new Image();
		img2.src = "images/menu_item2_over.gif";
		var img3 = new Image();
		img3.src = "images/menu_item3_over.gif";
		var img4 = new Image();
		img4.src = "images/menu_item4_over.gif";
		var img5 = new Image();
		img5.src = "images/home_over.gif";
		var img6 = new Image();
		img6.src = "images/contact_us_over.gif";
		var img7 = new Image();
		img7.src = "images/menu_sub1_over.gif";
		var img8 = new Image();
		img8.src = "images/menu_sub2_over.gif";
		var img9 = new Image();
		img9.src = "images/menu_sub3_over.gif";
		var img10 = new Image();
		img10.src = "images/menu_sub4_over.gif";
		var img11 = new Image();
		img11.src = "images/menu_sub5_over.gif";
		var img12 = new Image();
		img12.src = "images/menu_sub6_over.gif";
		var img13 = new Image();
		img13.src = "images/downwithdust_link_over.gif";
}

function popCoupon(){
	var wWidth = 500;
	var wHeight = 450;
	var sWidth = screen.availWidth;
	var sHeight = screen.availHeight;
	var wLeft = (sWidth / 2) - (wWidth / 2);
	var wTop = (sHeight / 2) - (wHeight / 2);
	var popWin = window.open("win_pop.php","coupon","height=" + wHeight + ",width=" + wWidth + ",left=" + wLeft + ",top=" + wTop);
}

function popCoupon2(){
	var wWidth = 500;
	var wHeight = 450;
	var sWidth = screen.availWidth;
	var sHeight = screen.availHeight;
	var wLeft = (sWidth / 2) - (wWidth / 2);
	var wTop = (sHeight / 2) - (wHeight / 2);
	var popWin = window.open("feedback_win_pop.php","coupon","height=" + wHeight + ",width=" + wWidth + ",left=" + wLeft + ",top=" + wTop);
}

function popRules(){
	var wWidth = 500;
	var wHeight = 450;
	var sWidth = screen.availWidth;
	var sHeight = screen.availHeight;
	var wLeft = (sWidth / 2) - (wWidth / 2);
	var wTop = (sHeight / 2) - (wHeight / 2);
	var popWin = window.open("rules_pop.php","rules","height=" + wHeight + ",width=" + wWidth + ",left=" + wLeft + ",top=" + wTop);
}

function popClip(fileName,fileSize,caption,fileType){
	var wWidth = 500;
	var wHeight = 450;
	var sWidth = screen.availWidth;
	var sHeight = screen.availHeight;
	var wLeft = (sWidth / 2) - (wWidth / 2);
	var wTop = (sHeight / 2) - (wHeight / 2);
	var popWin = window.open("flash_pop.php?fileName=" + fileName + "&fileType=" + fileType + "&caption=" + caption + "&fileSize=" + fileSize,"video","height=" + wHeight + ",width=" + wWidth + ",left=" + wLeft + ",top=" + wTop);
}

function checkVideoFeedback(){
	var hasError = 0;
	for(i=1; i<=4; i++){
		if(document.getElementById("textbox" + i).value == ""){
			hasError = 1;
			document.getElementById("label" + i).style.color = "red";
		}else{
			document.getElementById("label" + i).style.color = "#333";
		}
	}
	// Check for valid email address
	var emailText = document.getElementById("textbox4").value;
	if(document.getElementById("textbox4_valid")){ // if this is the updated videos page
		if(emailText != "" && (emailText.indexOf("@") == -1 || emailText.indexOf(".") == -1)){
			hasError = 1;
			vidSubmitAttempts++;
			document.getElementById("textbox4_valid").style.visibility = "visible";
			document.getElementById("label4").style.color = "red";
		}else{
			document.getElementById("textbox4_valid").style.visibility = "hidden";	
		}
	}

	if(hasError == 1){
		if(vidSubmitAttempts > 2){
			window.location.href = "http://www.downwithdust.com/thank_you.php";
		}
		document.getElementById("error").style.display = "";
		return false;
	}else{
		return true;	
	}
}

function checkFeedback(){
	var hasError = 0;
	for(i=1; i<=16; i++){
		if(document.getElementById("textbox" + i).value == ""){
			hasError = 1;		
			document.getElementById("label" + i).style.color = "red";
		}else{
			document.getElementById("label" + i).style.color = "#333";
		}
	}
	
	numChecked = 0;
	for(i=0; i<document.getElementById("feedback_form")["what_prompted[]"].length; i++){
		if(document.getElementById("feedback_form")["what_prompted[]"][i].checked) numChecked++;
	}
	if(numChecked==0){
		hasError = 1;
		document.getElementById("label20").style.color = "red";
	}else{
		document.getElementById("label20").style.color = "#333";
	}

	numChecked = 0;
	for(i=0; i<document.getElementById("feedback_form")["use_comment"].length; i++){
		if(document.getElementById("feedback_form")["use_comment"][i].checked) numChecked++;
	}
	if(numChecked==0){
		hasError = 1;
		document.getElementById("label17").style.color = "red";
	}else{
		document.getElementById("label17").style.color = "#333";
	}

	numChecked = 0;
	for(i=0; i<document.getElementById("feedback_form")["use_again"].length; i++){
		if(document.getElementById("feedback_form")["use_again"][i].checked) numChecked++;
	}
	if(numChecked==0){
		hasError = 1;
		document.getElementById("label18").style.color = "red";
	}else{
		document.getElementById("label18").style.color = "#333";
	}
	
	numChecked = 0;
	for(i=0; i<document.getElementById("feedback_form")["contact_you"].length; i++){
		if(document.getElementById("feedback_form")["contact_you"][i].checked) numChecked++;
	}
	if(numChecked==0){
		hasError = 1;
		document.getElementById("label19").style.color = "red";
	}else{
		document.getElementById("label19").style.color = "#333";
	}

	if(hasError == 1){
		document.getElementById("error").style.display = "";
		returnTop();
		return false;
	}else{
		return true;	
	}
}

function returnTop(){
	document.location.href="#";	
}