
//Save - add to if necessary

function setVisibility(objectID,state) {
	var object = document.getElementById
		(objectID);
	object.style.visibility = state;
}
function toggleVisibility(objectID) {
	var object = document.getElementById
		(objectID);
	state = object.style.visibility;
	if (state == 'hidden')
		object.style.visibility = 'visible';
	else {
		if (state == 'visible')
			object.style.visibility = 'hidden';
		else object.style.visibility = 'visible';
	}
}

function setDisplay(objectID,state) {
	var object = document.getElementById
		(objectID);
	object.style.display = state;
}

function toggle(elementID){
var target1 = document.getElementById(elementID)
if (target1.style.display == 'none') {
target1.style.display = 'block'
} else {
target1.style.display = 'none'
}
} 

function toggle2(elementID){
var target1 = document.getElementById(elementID)
if (target1.style.display == 'none') {
target1.style.display = 'block'
} else {
target1.style.display = 'none'
}
}

function toggle3(elementID){
var target1 = document.getElementById(elementID)
if (target1.style.display == 'none') {
target1.style.display = 'block'
} else {
target1.style.display = 'none'
}
}

function toggle4(elementID){
var target1 = document.getElementById(elementID)
if (target1.value == 'Add To Cart') {
target1.value = 'Continue'
} else {
target1.value = 'Add To Cart'
}
}

function toggle5(elementID){
var target1 = document.getElementById(elementID)
if (target1.value == 'Proceed with Order') {
target1.value = 'Continue'
} else {
target1.value = 'Proceed with Order'
}
}

function findAreaM2E(form1)
{	
	var metersToCms = form1.Meters.value * 100 
	var centimeters = form1.CM.value
	var totalCentimeters = Math.round(metersToCms) + Math.round(centimeters)
	var standardInches = totalCentimeters / 2.54
	var finalFeet = Math.floor(standardInches / 12)
	var finalInches = Math.ceil(standardInches - (finalFeet * 12))
	form1.feetLabel.value = finalFeet + " " + "ft "	
	form1.inchLabel.value = finalInches + " " + "in"
}
function findAreaE2M(form2)
{	
	var feetToIn = form2.feet.value * 12
	var inches = form2.inches.value
	var totalInches = Math.round(feetToIn) + Math.round(inches)
	var centimeters = totalInches * 2.54
	var finalMeters = Math.floor(centimeters / 100)
	var finalCentimeters = Math.ceil(centimeters - (finalMeters * 100))
	form2.meterLabel.value = finalMeters + "m"	
	form2.centimeterLabel.value = finalCentimeters + "cm"	
}

function validateDesignForm(designForm) {
	var WFToIn = ((designForm.customWidthFeet.value * 12) + (designForm.customWidthInch.value * 1));	
	var HFToIn = ((designForm.customHeightFeet.value * 12) + (designForm.customHeightInch.value * 1));	
	var squarefeet = Math.ceil((WFToIn * HFToIn) / 144);
	var minHeight = designForm.minHeight.value * 1;
	if (WFToIn == 0 || HFToIn == 0){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>Please enter or select a size</span>";
		return false;
	}
	else if (minHeight == 36 && (( WFToIn < 36 || HFToIn < 36 ) || ( squarefeet < 24 )) ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>3 ft by 8 ft minimum</span>";
		return false;
	}
	else if (minHeight == 36 && ((HFToIn >= 36 && HFToIn < 48  && WFToIn < 96) || (WFToIn >= 36 && WFToIn < 48  && HFToIn < 96))  ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>3 ft by 8 ft minimum</span>";
		return false;
	}
	else if (minHeight == 36 && ((HFToIn >= 48 && HFToIn < 72 && WFToIn < 72) || (WFToIn >= 48 && WFToIn < 72 && HFToIn < 72))  ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>3 ft by 8 ft minimum</span>";
		return false;
	}
	
	else if (minHeight > 36 && (( WFToIn < 48 || HFToIn < 48 ) || ( squarefeet < 24 ) || (WFToIn < 72 && HFToIn < 72))  ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>4 ft by 6 ft minimum</span>";
		return false;
	}	
	else{
		return true;
	}	
}

function testIsValidObject() {
if (document.designForm.opt == null || document.designForm.opt == undefined) {
return false;
}
return true;
}

function findDesignCost(designForm) {
	var WFToIn = ((designForm.customWidthFeet.value * 12) + (designForm.customWidthInch.value * 1));	
	var HFToIn = ((designForm.customHeightFeet.value * 12) + (designForm.customHeightInch.value * 1));	
	var squarefeet = Math.ceil((WFToIn * HFToIn) / 144);
	var fUnitPrice = designForm.formUnitPrice.value * 1;
	var fGalleryPrice = designForm.formGalleryPrice.value * 1;
	var fUnitPriceDisplay = fUnitPrice.toFixed(2);
	var fGalleryPriceDisplay = fGalleryPrice.toFixed(2);
	var minHeight = designForm.minHeight.value * 1;
	var cost = squarefeet * fUnitPrice;
	if (WFToIn == 0 || HFToIn == 0){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>Please enter a size</span>";
		//return false;
	}
	//else if (minHeight == 36 && (( WFToIn < 36 || HFToIn < 36 ) || ( WFToIn < 96 && HFToIn < 96 )) ){
	else if (minHeight == 36 && (( WFToIn < 36 || HFToIn < 36 ) || ( squarefeet < 24 )) ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>3 ft by 8 ft minimum</span>";
		//return false;
	}
	//else if (minHeight > 36 && (( WFToIn < 48 || HFToIn < 48 ) || ( WFToIn < 72 && HFToIn < 72 ))  ){
	else if (minHeight > 36 && (( WFToIn < 48 || HFToIn < 48 ) || ( squarefeet < 24 ))  ){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>4 ft by 6 ft minimum</span>";
		//return false;
	}	
	else if (cost < (24 * fUnitPrice)){
		document.getElementById('costLabel').innerHTML = "<span style='color:red'>Below minimum size</span>";
		//return false;
	}
	else{
		if (fUnitPrice < fGalleryPrice) {
		//<span style="text-decoration:line-through">#dollarformat(GalleryPrice)#</span>
		document.getElementById('costLabel').innerHTML = "<span style='color:blue'> $" + cost.toFixed(2) + " (" + squarefeet + " sq ft @ <font style='text-decoration:line-through'>$" + fGalleryPriceDisplay + "</font> $" + fUnitPriceDisplay + ")</span>";
		}
		else {
		document.getElementById('costLabel').innerHTML = "<span style='color:blue'>$" + cost.toFixed(2) + " (" + squarefeet + " sq ft @ $" + fUnitPriceDisplay + ")</span>";
		}
		//return true;
	}	
}

function clearDesignCost(designForm)
{
	document.getElementById('costLabel').innerHTML = "&nbsp;";
}

function findCost(uploadForm)
{	
	var WFToIn = ((uploadForm.WF.value * 12) + (uploadForm.WI.value * 1));	
	var HFToIn = ((uploadForm.HF.value * 12) + (uploadForm.HI.value * 1));	
	var squarefeet = Math.ceil((WFToIn * HFToIn) / 144);
	var cost = squarefeet * 8.95;
	var costcanvas = squarefeet * 12.95;
	if (cost < (12 * 8.95)){
	uploadForm.costLabel.value = "Below minimum of 12 sq. ft.";
	uploadForm.costvinylLabel.value = "";
	uploadForm.costcanvasLabel.value = "";
	}
	else
	{
	uploadForm.costLabel.value = "$" + cost.toFixed(2) + " (" + squarefeet + " sq.ft. @ $8.95)";
	uploadForm.costvinylLabel.value = "Vinyl $" + cost.toFixed(2) + " (" + squarefeet + " sq.ft. @ $8.95)";
	uploadForm.costcanvasLabel.value = "Canvas $" + costcanvas.toFixed(2) + " (" + squarefeet + " sq.ft. @ $12.95)";
	}	
}
function clearCost(uploadForm)
{
	uploadForm.costLabel.value = '';
}
function customMinimum(resizeForm)
{	
	WFToIn = ((resizeForm.NWF.value * 12) + (resizeForm.NWI.value * 1));	
	HFToIn = ((resizeForm.NHF.value * 12) + (resizeForm.NHI.value * 1));	
	squarefeet = Math.ceil((WFToIn * HFToIn) / 144);	
	if (squarefeet < 12){
	alert("The size you entered does not meet the 12 square foot minimum requirement");
	}		
}

function ShowHideLayer(boxID) {
	/* Obtain reference for the selected boxID layer and its button */
	var box = document.getElementById("box"+boxID);
	var boxbtn = document.getElementById("btn"+boxID);
	
	/* If the selected box is currently invisible, show it */
	if(box.style.display == "none" || box.style.display=="") {
		box.style.display = "block";
 		boxbtn.src = "images-misc/collapse.gif";
	}
	/* otherwise hide it */
	else {
		box.style.display = "none";
		boxbtn.src = "images-misc/expand.gif";
	}
}

function add_favorite ( name, value )
{
  //var results = document.cookie.match ( '(^|;) ?' + name + '=([^;]*)(;|$)' );
  //if (results){
  //var cookie_string = name + "=" + results[2] + ","  + escape ( value ); }
  //else{
  var cookie_string = name + "="  + escape ( value ); 
  //}
  
  document.cookie = cookie_string;
}

function delete_cookie ( cookie_name )
{
  var cookie_date = new Date ( );  // current date & time
  cookie_date.setTime ( cookie_date.getTime() - 1 );
  document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}

function validateAffState() {
//check a field to make sure it has something filled in
if (document.affForm.State.value == 'NY') {
alert('The Murals Your Way affiliate program is not available to residents of New York.');
return false;
}
}






















