// JavaScript Document
function MM_findObj(n, d) 
	{ //v4.01
		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_showHideLayers() 
	{ //v6.0
		var i,p,v,obj,args=MM_showHideLayers.arguments;
		for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
		if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}

	function open_window(link,w,h) //opens new window
	{
		var win = "width="+w+",height="+h+",menubar=no,location=no,resizable=yes,scrollbars=yes";
		newWin = window.open(link,'newWin',win);
		newWin.focus();
	}

	function confirmDelete() //unsubscription confirmation
	{
		temp = window.confirm('');
		if (temp) //delete
		{
			window.location="index.php?killuser=yes";
		}
	}

	function validate_custinfo(payment_method) //validate customer information
	{
		if (document.custinfo_form.first_name.value=="")
		{
			alert("Please input your name");
			document.custinfo_form.first_name.focus();
			return false;
		}
		if (document.custinfo_form.last_name.value=="")
		{
			alert("Please input your name");
			document.custinfo_form.last_name.focus();
			return false;
		}
		if (document.custinfo_form.email.value=="")
		{
			alert("Please input your email address");
			document.custinfo_form.email.focus();
			return false;
		}
		if (document.custinfo_form.email.value!="")
		{
			var ss_email = document.custinfo_form.email.value;
			if(!ss_email.match(/^\w+([\.-]?\w+)*[\.]?@\w+([\.-]?\w+)*(\.\w{2,4})+$/i))
			{
				alert("Please enter valid email address");
				document.custinfo_form.email.focus();
				return false;
			}
		}
		if (document.custinfo_form.phone.value=="")
		{
			alert("Please enter phone number");
			document.custinfo_form.phone.focus();
			return false;
		}
		
		if (document.custinfo_form.address.value=="")
		{
			alert("Please input address");
			document.custinfo_form.address.focus();
			return false;
		}
		
		if (document.custinfo_form.city.value=="")
		{
			alert("Please input city");
			document.custinfo_form.city.focus();
			return false;
		}
		if (document.custinfo_form.state.value=="")
		{
			alert("Please input state");
			document.custinfo_form.state.focus();
			return false;
		}
		if (document.custinfo_form.zip.value=="")
		{
			alert("Please input ZIP");
			document.custinfo_form.zip.focus();
			return false;
		}
		if (document.custinfo_form.country.value=="")
		{
			alert("Please input country");
			document.custinfo_form.country.focus();
			return false;
		}

		document.custinfo_form.payment_method.value = payment_method;
		
		return true;
	}
	
	function validate_subscribe() //validate customer information
	{
		if (document.news_letter.name.value=="")
		{
			alert("Please input your name");
			document.news_letter.name.focus();
			return false;
		}
		if (document.news_letter.suburb.value=="")
		{
			alert("Please enter suburb");
			document.news_letter.suburb.focus();
			return false;
		}
		if (document.news_letter.email.value=="")
		{
			alert("Please input your email address");
			document.news_letter.email.focus();
			return false;
		}
		if (document.news_letter.phone.value=="")
		{
			alert("Pelase enter phone number");
			document.news_letter.phone.focus();
			return false;
		}
		return true;
	}
