function MM_swapImgRestore() { var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc; }
function MM_findObj(n, d) { var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); if(!x && d.getElementById) x=d.getElementById(n); return x; }
function MM_swapImage() { var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3) if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}}
function ChangeColor(tableRow, highLight) { if (highLight) { tableRow.style.backgroundColor = '#98CCE6'; } else { tableRow.style.backgroundColor = 'white'; } }
function ChangeColor2(tableRow, highLight) { if (highLight) { tableRow.style.backgroundColor = '#98CCE6'; tableRow.style.color = 'white'; } else { tableRow.style.backgroundColor = 'white'; tableRow.style.color = '#4AB5FF'; } }
function DoNav(theUrl) { document.location.href = theUrl; }
function DoNavNewWin(theUrl) { window.open (theUrl, 'newwindow', config='height=800, width=800, toolbar=yes, menubar=yes, scrollbars=yes, resizable=yes, location=no, directories=no, status=no'); }
function clickclear(thisfield, defaulttext) { if (thisfield.value == defaulttext) { thisfield.value = ""; } }
function clickrecall(thisfield, defaulttext) { if (thisfield.value == "") { thisfield.value = defaulttext; } }
function formCheck() { msg = ""; if (document.keywordform.prod_name.value.length < 3) { msg = "Please enter a keyword at least 3 characters long\n"; } if (msg != "") { alert(msg); return false; } else { return true; } }

function formContact() { msg = "";
if (document.contactMethod.ContactMessage.value == "") { msg = "Please include a Message\n"; }
if (document.contactMethod.province.selectedIndex == 0) { msg = "Please select your Province\n"; }
if (document.contactMethod.ContactEmail.value == "") { msg = "Please include your Email Address\n"; }
if (document.contactMethod.ContactName.value == "") { msg = "Please include your Name\n"; }
if (msg != "") { alert(msg); return false; } else { return true; } }


function valButton(btn) { var cnt = -1; for (var i=btn.length-1; i > -1; i--) { if (btn[i].checked) {cnt = i; i = -1;} } if (cnt > -1) return btn[cnt].value; else return null; }

function chkNumeric(strString)
   {
   var strValidChars = "0123456789-()";
   var strChar;
   var blnResult = true;
   if (strString.length == 0) return false;
   for (i = 0; i < strString.length && blnResult == true; i++)
      {
      strChar = strString.charAt(i);
      if (strValidChars.indexOf(strChar) == -1)
         {
         blnResult = false;
         }
      }
   return blnResult;
   }

function orderForm() { 
	msg = "";
	var btn4 = valButton(contactMethod.delivery); 
	if (btn4 == null) { 
		msg= "Please select if you will be picking up your order or if you would like to receive a quote on shipping\n"; 
		document.getElementById('delivery').focus();
	}
	if (document.contactMethod.ContactMessage.value == "") { 
		msg = "Please include a Message\n"; 
		document.getElementById('ContactMessage').focus(); 
	}
	var btn3 = valButton(contactMethod.ship); 
	if (btn3 == null) { 
		msg= "Please select Home or Business/Commercial\n"; 
		document.getElementById('ship').focus(); 
	}
	if (chkNumeric(document.contactMethod.ContactPhone1.value) == false) { 
		msg = "Please only include numerical values in the Phone Number box\n"; 
		document.getElementById('ContactPhone1').focus(); 
	}
	if (document.contactMethod.ContactPhone1.value.length == 0) { 
		msg = "Please include a Contact Phone Number\n"; 
		document.getElementById('ContactPhone1').focus(); 
	}
	if (document.contactMethod.ContactEmail.value !== document.contactMethod.ContactEmail2.value) { 
		msg = "Your Email Address does not match\n"; 
		document.getElementById('ContactEmail2').focus(); 
	}
	if (document.contactMethod.ContactEmail.value == "") { 
		msg = "Please include your Email Address\n"; 
		document.getElementById('ContactEmail').focus(); 
	}
	if (document.contactMethod.FirstName.value == "") { 
		msg = "Please include your First Name\n"; 
		document.getElementById('FirstName').focus(); 
	}
	if (document.contactMethod.LastName.value == "") { 
		msg = "Please include your Last Name\n"; 
		document.getElementById('LastName').focus(); 
	}	
	if (contactMethod.delivery2.checked) { 
		if (contactMethod.shippingAddress.value == "" || contactMethod.city.value == "" || contactMethod.postalCode.value == "") { 
			msg = "Please include a Shipping Address"; 
			document.getElementById('shippingAddress').focus(); 
		}
	}
	if (msg != "") { 
		alert(msg); 
		return false;
	} else { 
		document.contactMethod.purch.value = document.getElementById('purchase2').innerText + document.getElementById('purchase').innerText;
		return true; 
	}
}

function shipMessage() {
	var e = document.getElementById("province");
	var str = e.options[e.selectedIndex].index;
	if (str > 12) {
		alert("Please note that we ship limited items outside of Canada.  Limited items include such things as: baby gear, strollers, linens, gifts & accessories.  Large furniture pieces will not be shipped unless otherwise noted.");
	}
}

var rector=6; var stopit=0; var a=1;
function init(which){ stopit=0; shake=which; shake.style.left=0; shake.style.top=0; }
function rattleimage(){ if ((!document.all&&!document.getElementById)||stopit==1) return; if (a==1){ shake.style.top=parseInt(shake.style.top)+rector; } else if (a==2){ shake.style.left=parseInt(shake.style.left)+rector; } else if (a==3){ shake.style.top=parseInt(shake.style.top)-rector } else { shake.style.left=parseInt(shake.style.left)-rector; } if (a<4) a++; else a=1; setTimeout("rattleimage()",50) }
function stoprattle(which){ stopit=1; which.style.left=0; which.style.top=0; }

function confirmCS(product_id,wishlist_id) {
if (document.colorform.sizes.selectedIndex == -1) {
	alert('Please pick a colour & size');
	document.colorform.colors.focus();
} else {
	//alert(document.colorform.sizes.selectedIndex);
	DoNav('../order.cfm?prodid='+product_id+'&bv='+document.colorform.sizes.options[document.colorform.sizes.selectedIndex].value+'&wishlist='+wishlist_id+'');
}
}
