// JavaScript Document

// Example:
// simplePreload( '01.gif', '02.gif' ); 
function simplePreload()
{ 
  var args = simplePreload.arguments;
  document.imageArray = new Array(args.length);
  for(var i=0; i<args.length; i++)
  {
    document.imageArray[i] = new Image;
    document.imageArray[i].src = args[i];
  }
}

simplePreload( 'images/border/logo.gif','images/nav/home.gif','images/nav/home_on.gif','images/nav/restaurant.gif','images/nav/restaurant_on.gif','images/nav/events.gif','images/nav/events_on.gif','images/nav/wine.gif','images/nav/wine_on.gif','images/nav/contact.gif','images/nav/contact_on.gif' ); 

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 calcPostage() {
	var value, total;
	if (document.postage.country.value == "Australia") {
		value = 4;
		total = parseInt(document.postage.rawCost.value) + parseInt(value);
		document.postage.postageCost.value = formatCurrency(value);
		document.postage.totalCost.value = formatCurrency(total);
	} else {
		value = 40;
		total = parseInt(document.postage.rawCost.value) + parseInt(value);
		document.postage.postageCost.value = formatCurrency(value);
		document.postage.totalCost.value = formatCurrency(total);
	}
}

function setOrigin(catId){
	var value = document.form1.origin.value; 
	window.location.href = "gallery.php?catId="+catId+"&origin="+value;
}


function countryShow() {
	if (document.form1.country.value == "none") {
		document.form1.countryOther.style.display='';
		document.form1.countryOther.focus();
	} else {
		document.form1.countryOther.style.display='none';
	}
}
function stateShow() {
	if (document.form1.state.value == "none") {
		document.form1.stateOther.style.display='';
		document.form1.stateOther.focus();
	} else {
		document.form1.stateOther.style.display='none';
	}
}


var popUpWin=0;
function popUpWindow(URLStr, left, top, width, height) {
  if(popUpWin) {
	  if(!popUpWin.closed) popUpWin.close();
  }
  var winleft = (screen.width - width) / 2;
  var winUp = (screen.height - height) / 2;
  popUpWin = open(URLStr, 'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,copyhistory=no,width='+width+',height='+height+',left='+winleft+', top='+winUp+',screenX='+winleft+',screenY='+winUp+'');
}