function displayHowToMeasure(product_line_id) {
    window.open("{$site_url}/how_to_measure/" + product_line_id + "","","toolbar=no,location=no,directories=no,"+
                "status=no,menubar=no,scrollbars=yes,"+
                "resizable=yes,width=850,height=720,top=20,left=20");
}

var active_category_id = 0;
function rollOverSD( category_id )
{
	if(category_id != active_category_id)
	{
		//alert(category_id + " || " + active_category_id);
		highlight_div = document.getElementById("sd_" + category_id);
		highlight_lnk = document.getElementById("lnk_" + category_id);

		highlight_div.className = "sd_category_active";
		highlight_lnk.className = "sd_category_active";
	} 
}

function rollOutSD( category_id )
{
	if(category_id != active_category_id)
	{		
		highlight_div = document.getElementById("sd_" + category_id);
		highlight_lnk = document.getElementById("lnk_" + category_id);

		highlight_div.className = "sd_category_inactive";
		highlight_lnk.className = "sd_category_inactive";	
	}
}

function clearDefault(el) { if (el.defaultValue == el.value) el.value = "" }

function validate_installer_form(){
	errors=0;
	if($("email").value.length==0 || $("email").value==""){
		$message="Please enter your email address so that we can help coordinate your appointment.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if($("phone").value.length==0 || $("phone").value==""){
		$message="Please provide your phone number so the professional installer can coordinate a time for your appointment.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if($("addr1").value.length==0 || $("addr1").value==""){
		$message="Please provide your address as that is the key for the professional to give you the best appointment day and time possible.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if (!$('sf_form').getInputs('checkbox').pluck('checked').any()){
		$message= "Please select which window treatment you would like. It is very important that you know which window treatment you want before having the professional come measure.  If you're unsure, please work with us, The Shade Store, to determine which window treatment is right for you.";
		jQuery.prompt ($message, {opacity: 0.4});
	 	return false;
	}
	
	document.sf_form.submit();
	
}
var submit=false;
function validate_installer_form_admin(){
	if(!submit){
		submit=true;
	errors=0;
	if($("email").value.length==0 || $("email").value==""){
		$message="Please enter your email address so that we can help coordinate your appointment.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if($("phone").value.length==0 || $("phone").value==""){
		$message="Please provide your phone number so the professional installer can coordinate a time for your appointment.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if($("addr1").value.length==0 || $("addr1").value==""){
		$message="Please provide your address as that is the key for the professional to give you the best appointment day and time possible.";
		jQuery.prompt($message, {opacity: 0.4});
		return false;
	}
	
	if (!$('sf_form').getInputs('checkbox').pluck('checked').any()){
		$message= "Please select which window treatment you would like. It is very important that you know which window treatment you want before having the professional come measure.  If you're unsure, please work with us, The Shade Store, to determine which window treatment is right for you.";
		jQuery.prompt ($message, {opacity: 0.4});
	 	return false;
	}

	new Ajax.Request('/measure-and-install/ajax/find-an-installer', {
		  method: 'post',
		  parameters: $('sf_form').serialize(true),
		  onComplete: function(transport){
			  $('showcase').innerHTML = transport.responseText;
			  window.opener.loadLeadTable();
			 
			  self.close();
		  }

		  });
	}
	

}

