//for refresh
var sURL = unescape(window.location.pathname);

jQuery.noConflict();

var verify="";
function verifyOwner(what,page){
	j=what.mho.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.mho[i].checked) var verify = what.mho[i].value
	}
	
	if (verify == "confirmed") {
		createCookie('mhoCookie','confirmed',21)
		if (page == "quote") {
			window.parent.location="../quote/index.php";
		} else if (page == "factory_pricing") {
			window.location.href="factory_pricing.html";
		} else if (page == "ontime_delivery") {
			window.location.href="ontime_delivery.html";
		} else {
			window.location.href="appliance_professionals.html";
		}		
	} else {
		//alert("Sorry, you must be a Multi-housing Owner to use this website.");
			window.location.href="sorry.html";
	}
}

var unit_type="";

function unitType(what,open){
	j=what.unit_type.length; //alert(j)
	for (i=0; i<j; i++){
		if(what.unit_type[i].checked) var unit_type = what.unit_type[i].value
	}	
	if (unit_type == "new") {
		Effect.SlideUp(what,{duration:0.4});
		Effect.SlideDown(open+"_new",{duration:0.5}); return false;			
	} else {
		var newApp = document.getElementById(open+"_new");
		newApp.style.display = 'block';
		newApp.style.position = 'absolute';
		newApp.style.float = 'none';
		newApp.style.visibility = 'hidden';
		//end ie6 display none hack
		Effect.SlideUp(what,{duration:0.4}); 
		Effect.SlideDown(open+"_replace",{duration:0.5}); return false;
	}
}

function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}


function checkCookie(page) {
	var mhoCookie = readCookie('mhoCookie')
	if (mhoCookie) {
		//alert("mmm....cookie!");
		if (page == "quote") {
			window.parent.location="../quote/index.php";
		} else if (page == "factory_pricing") {
			window.location.href="factory_pricing.html";
		} else if (page == "ontime_delivery") {
			window.location.href="ontime_delivery.html";
		} else {
			window.location.href="appliance_professionals.html";
		}
	} else {
		//alert("no cookies here!");
		//display the page
	}
}

function checkCookieQuote(frompage) {
	var mhoCookie = readCookie('mhoCookie')
	if (mhoCookie) {
		if (frompage == "home") {
			window.location.href="quote/index.php";
		} else if (frompage == "lightbox") {
			window.parent.location="../quote/index.php";
		} else {
			window.location.href="../quote/index.php";
		}
	} else {
		if (frompage == "home") {
			tb_show(null, "verify/multihousing_verify.php?page=quote&KeepThis=true&TB_iframe=true&height=258&width=515", false);
		} else if (frompage == "lightbox") {
			window.location.href="multihousing_verify.php";
		} else {
			tb_show(null, "../verify/multihousing_verify.php?page=quote&KeepThis=true&TB_iframe=true&height=258&width=515", false);
		}
	}
}

function closePanel(panel) {
	Effect.SlideUp(panel,{duration:0.5});
}

function isNumeric(units) {
   var ValidChars = "0123456789.";
   var IsNumber=true;
   var Char;

   for (i = 0; i < units.length && IsNumber == true; i++) 
      { 
      Char = units.charAt(i); 
      if (ValidChars.indexOf(Char) == -1) 
         {
         IsNumber = false;
         }
      }
   return IsNumber; 
}

function checkNewUnits(form) {
	if (form.new_quantity.value.length == 0) {
	      alert("Please enter how many new units you'd like quoted.");
	      form.new_quantity.focus();
	      return false;
	} else if (isNumeric(form.new_quantity.value) == false) {
	      alert("Please use a numeric value.  Example: 100");
	      form.new_quantity.focus();
	      return false;
      	}
   return true;
}

function checkReplaceUnits(form) {
	if (form.replacement_quantity.value.length == 0) {
	      alert("Please enter how many replacement units you'd like quoted.");
	      form.replacement_quantity.focus();
	      return false;
	} else if (isNumeric(form.replacement_quantity.value) == false) {
	      alert("Please use a numeric value.  Example: 100");
	      form.replacement_quantity.focus();
	      return false;
      	}
   return true;
}




