

function open_large_image(url) {
    var  new_url, name, features, new_window;
    new_url = "http://www.gatorcustomblinds.com/show_image.php?file=" + url;
    name = "Product_Image";
    features = "width=400,height=550,fullscreen=no,location=no,resizable=yes,status=no,scrollbars=yes,toolbar=no";
    new_window = window.open(new_url, name,features);
    new_window.focus();

}




function open_calc() {
    var  new_url, name, features, new_window;
    new_url = "http://www.gatorcustomblinds.com/multi-headrail-calculator.php";
    name = "Multi_headrail_calculator";
    features = "width=550,height=140,fullscreen=no,location=no,resizable=yes,status=no,scrollbars=auto,toolbar=no";
    new_window = window.open(new_url, name,features);
    new_window.focus();

}



function callAHAH(url, pageElement, callMessage, errorMessage)

{

document.getElementById(pageElement).innerHTML=callMessage;

try{ req=new XMLHttpRequest(); }

catch(e){

try { req = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions IE */ }

catch (f) {

try{ req = new ActiveXObject("Microsoft.XMLHTTP");/* some versions IE */ }

catch (E){ req = false;}

}}

req.onreadystatechange = function()

{ responseAHAH(pageElement, errorMessage); }

req.open("GET",url,true); 

req.send(null); }



function responseAHAH(pageElement, errorMessage) {

if(req.readyState == 4) { if(req.status == 200) { 

output = req.responseText;

document.getElementById(pageElement).innerHTML = output; 

} else { 

document.getElementById(pageElement).innerHTML = errorMessage+"\n"+responseText; } 

} }



function makeactive(page, tag)

{

  callAHAH(page, tag, '<br/><br/><span style="color:#FF0000"><strong>Loading Color Chart. Please wait...</strong></span><br/><br/>', 'Error');

}

function openColorSamplePopup(url) {
    var  new_url, name, features, new_window;
    new_url = "http://www.gatorcustomblinds.com/popup.php?file=" + url;
    name = "Option_Sample";
    features = "width=400,height=550,fullscreen=no,location=no,resizable=yes,status=no,scrollbars=auto,toolbar=no";
    new_window = window.open(new_url, name,features);
    new_window.focus();

}







// validate ZIP and ZIP+4 codes

function validateZipCode($zip_field) {

    var $valid_chars = "0123456789-";

    var $hyphen_count = 0;



    if ($zip_field.length != 5 && $zip_field.length != 10) {

        return false;

    }

    for (var i=0; i < $zip_field.length; i++) {

        $zc = "" + $zip_field.substring(i, i+1);

        if ($zc == "-") $hyphen_count++;

        if ($valid_chars.indexOf($zc) == "-1") {

            return false;

        }

        if (($hyphen_count > 1) || (($zip_field.length==10) && ""+$zip_field.charAt(5)!="-")) {

            return false;

        }

    }

    return true;

}



// Larger Sample Window

function popupWindow(url) {

  window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,left=150')

}





 var add_tax = false;
	 
  function calculate_total() {
  		var state =  document.getElementById("state");
  		var florida_tax =  document.getElementById("florida_tax");
  		var total = document.getElementById("total");
  		
  	
  		if (state.value == "FL") {
  			florida_tax.style.display = "";
  			//total.value = parseFloat(total.value) + parseFloat(florida_tax ?>);
  			var num1 = new Number(total.value);
  			total.value = num1.toFixed(2);
  			add_tax = true;
  		} else {
  			florida_tax.style.display = "none";
  			if (add_tax == true) {
  			
  			  // alert(parseFloat(total.value)  - parseFloat());
  			   
  				//total.value = parseFloat(total.value)  - parseFloat();
  					var num2 = new Number(total.value);
  					total.value = num2.toFixed(2);
  			//	total.value  = total.value  + ".00";
  				add_tax = false;
  			}
  		}
  		
  }
  
 function copyFields() {
 		 var s_first_name = document.getElementById("first_name");
 		 var b_first_name = document.getElementById("firstName");
 		 b_first_name.value = s_first_name.value;
 		 
 		 var s_last_name = document.getElementById("last_name");
 		 var b_last_name = document.getElementById("lastName");
 		 b_last_name.value = s_last_name.value;
 		 
 		 var s_address = document.getElementById("address");
 		 var b_address = document.getElementById("address1");
 		 b_address.value = s_address.value;
 		 
 		 var s_city = document.getElementById("city");
 		 var b_city = document.getElementById("billing_city");
 		 b_city.value = s_city.value;

 		 var s_state = document.getElementById("state");
 		 var b_state = document.getElementById("state_billing");
 		 b_state.value = s_state.value;
 		 
 		 
 		 var s_zip = document.getElementById("zip_code");
 		 var b_zip = document.getElementById("zip");
 		 b_zip.value = s_zip.value;
 		  
 }
 
 var form_submitted = false;
 
 function hideButton() {
 	
 	result = validate_form();
 	if (result == false) {
 		return false;
 	}
 	
 	var but = document.getElementById("submitButton");
 	but.style.display = "none";
 	var showBut = document.getElementById("showButton");
 	showBut.style.display = "";
 	var result = false;
 	
 
 	if ( form_submitted )	{
   		 alert ( " Processing. Please wait..." );
    		return false;
  	}	else	{
    		form_submitted = true;
    		return true;
  	}
  
 	
 }
 
 function validate_form() {
 		var message = " Please enter \n";
 		var errors  = 0;
 		var first_name = document.getElementById("first_name");
 		if (first_name.value.toString().length < 2) {
 			errors++;
 			message = message + " First Name \n";
 		}
 		
 		var last_name = document.getElementById("last_name");
 		if (last_name.value.toString().length < 2) {
 			errors++;
 			message = message + " Last Name \n";
 		}
 		
 		var address = document.getElementById("address");
 		if (address.value.toString().length < 2) {
 			errors++;
 			message = message + " Address \n";
 		}
 		
 		var city = document.getElementById("city");
 		if (city.value.toString().length < 2) {
 			errors++;
 			message = message + " City \n";
 		}
 		
 		var state = document.getElementById("state");
 		if (state.value ==  "") {
 			errors++;
 			message = message + " State \n";
 		}
 		
 		var zip_code = document.getElementById("zip_code");
 		if (zip_code.value.toString().length < 2) {
 			errors++;
 			message = message + " Zip code \n";
 		}
 		
 		var phone = document.getElementById("phone");
 		if (phone.value.toString().length < 2) {
 			errors++;
 			message = message + " Day Phone \n";
 		}
 		
 		var email = document.getElementById("email");
 		if (email.value.toString().length < 2) {
 			errors++;
 			message = message + " Email \n";
 		}
 		
 		
 		if (errors > 0) {
 			alert(message);
 			return false;
 		}
 		
 		return true;
 }