<!--

//get platform info - mostly irrelevant for this purpose
agt=navigator.userAgent.toLowerCase();
ie=(document.all) ? 1:0
ie4=(agt.indexOf('msie 4')!=-1) ? 1:0
ie5=(agt.indexOf('msie 5')!=-1) ? 1:0
ie6=(agt.indexOf('msie 6')!=-1) ? 1:0
ns4=(document.layers && parseInt(navigator.appVersion)>=4) ? 1:0
win=( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) )
mac=(agt.indexOf("mac")!=-1);

imgs=(document.images) ? 1:0

//rollovers function
function swapImage(theImage,newSrc){
	if(imgs){
		theOverImage=theImage; oldSrc=document.images[theImage].src;
		document.images[theImage].src=newSrc
		}
	}
function swapBack(){
	if(imgs){
		document.images[theOverImage].src=oldSrc
		}
	}

//preload those rollovers
function preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.p) d.p=new Array();
    var i,j=d.p.length,a=preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.p[j]=new Image; d.p[j++].src=a[i];}}
}


// open a popup win
function openWindow(theURL,winName,features) { //v2.0
  	window.open(theURL,winName,features);
}

function sendToFriendProduction() {
//	location [full location for secure domain]
	var stfPage = 'http://www.hamperingaround.com.au/send/sendToFriend.asp'; 	
//	page properties		
	var pagePps = "menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=10,top=10,width=380,height=400"
//	call opening function	
	openWindow(stfPage,'SendToFriend',pagePps);
}

function sendToFriendTest() {
//	location [full location for secure domain]
	var stfPage = 'http://www.hamperingaround.com.au/test/send/sendToFriend.asp'; 	
//	page properties (we turn on titlebar and toolbar so we know it is test region)
	var pagePps = "menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=1,left=10,top=10,width=380,height=400"
//	call opening function	
	openWindow(stfPage,'SendToFriend',pagePps);
}



function TCdeliveryProduction() {
//	location [full location for secure domain]
	var tcdPage = 'http://www.hamperingaround.com.au/cart/TCdelivery.asp?content=terms'; 	
//	page properties		
	var tcpagePps = "menubar=0,resizable=1,scrollbars=1,status=0,titlebar=0,toolbar=0,left=10,top=10,width=500,height=500"
//	call opening function	
	openWindow(tcdPage,'TCdelivery',tcpagePps);
}

function TCdeliveryTest() {
//	location [full location for secure domain]
	var tcdPage = 'http://www.hamperingaround.com.au/test/cart/TCdelivery.asp?content=terms-test'; 	
//	page properties (we turn on titlebar and toolbar so we know it is test region)
	var tcpagePps = "menubar=0,resizable=1,scrollbars=1,status=0,titlebar=1,toolbar=1,left=10,top=10,width=500,height=500"
//	call opening function	
	openWindow(tcdPage,'TCdelivery',tcpagePps);
}







function isNum(val){
	for (i=0; i<val.length; i++) {
		if (val.charAt(i) < "0") {
			return false;
		}
		if (val.charAt(i) > "9") {
			return false;
		}
	}
	return true;
}

function isEmail(src) {
     var emailReg = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
     var regex = new RegExp(emailReg);
     return regex.test(src);
}

// require "name" & "email" fields
function validForm(passForm){

	var a = passForm.name;
	var x = passForm.email;
	
	if(a.value=='') {
		a.focus(); 
		alert("Please provide your name"); 
	    return false;
	}
	if(!isEmail(x.value)) {
		x.focus(); 
		alert("Please provide your email address"); 
	    return false;
	}
}



// just like VBscript function
function DateAdd(timeU, byMany, dateObj) {
	var millisecond=1;
	var second=millisecond*1000;
	var minute=second*60;
	var hour=minute*60;
	var day=hour*24;
	var year=day*365;

	var newDate;
	var dVal=dateObj.valueOf();
	switch(timeU) {
	case "ms": newDate=new Date(dVal+millisecond*byMany); break;
	case "s": newDate=new Date(dVal+second*byMany); break;
	case "mi": newDate=new Date(dVal+minute*byMany); break;
	case "h": newDate=new Date(dVal+hour*byMany); break;
	case "d": newDate=new Date(dVal+day*byMany); break;
	case "y": newDate=new Date(dVal+year*byMany); break;
	}
	return newDate;
}



//-->
