function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
// Simple DHTML window management system
// written by Edward Coddington 7-3-03
// for Digital Slingshot Inc.
var active = "";

function popUpManager(newMenu) {
	if(!document.all){
		if(newMenu == "brand"){
			location.href='http://www.always-forever.com/store/shopping.html';
		}
		if(newMenu == "prod"){
			location.href='http://www.always-forever.com/store/shopping.html#producttype';
		}
		if(newMenu == "occasion"){
			location.href='http://www.always-forever.com/store/shopping.html#giftoccasion';
		}
	} else {
	if(active != "") {
		eval("document.all." + active + ".style.visibility='hidden'");
	}
	eval("document.all." + newMenu + ".style.visibility='visible'");
	active = newMenu;
	}
}

function addToCart(formNum,type){
eval("document.forms[" + formNum + "].toWhat.value='" + type + "'");
eval("document.forms[" + formNum + "].submit()");
}

function openWindow() {
	myWin = window.open("map.html","mywindow","scrollbars=1, resizable=1, width=400, height=480")
}

function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-') + '$' + num + '.' + cents);
}

function sendToFriend(prodID){
var newWin = window.open("sendEmail.php?ID=" + prodID, 'temp','toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=426,height=220');
}

function isEmailAddress (string) {
  var addressPattern = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
  return addressPattern.test(string);
}
function checkEmail (field) {
  if (!isEmailAddress(field.value)) {
    alert('Please enter your full email address.\n         i.e.(user@aol.com)');
    field.focus();
    field.select();
  }
}

function shipWindow() {
	myWin = window.open("shipPopUp.php","myShipWindow","scrollbars=1, resizable=1, width=450, height=480")
}

function sort_products(url) {
	document.location = url;
}