// JavaScript Document

function checkreg() {
if (document.Register.username.value=="")
	{alert('Please create a user name');	document.Register.username.focus(); return false}

if (document.Register.password_1.value=="")
	{alert('Please enter a password');	document.Register.password_1.focus(); return false}

if (document.Register.password_2.value=="")
	{alert('Please confirm your password');	document.Register.password_2.focus(); return false}
	
if (document.Register.first_name.value=="")
	{alert('Please key your first name');	document.Register.first_name.focus(); return false}

if (document.Register.last_name.value=="")
	{alert('Please key your last name');	document.Register.last_name.focus(); return false}

if (document.Register.phone_1.value=="")
	{alert('Please key your phone number');	document.Register.phone_1.focus(); return false}

if (document.Register.user_email.value=="")
	{alert('Please key your email address');	document.Register.user_email.focus(); return false}	

if (document.Register.address_1.value=="")
	{alert('Please key your address');	document.Register.address_1.focus(); return false}

if (document.Register.city.value=="")
	{alert('Please key your city');	document.Register.city.focus(); return false}

if (document.Register.state.value=="")
	{alert('Please key your state');	document.Register.state.focus(); return false}

if (document.Register.zip.value=="")
	{alert('Please key your postcode');	document.Register.zip.focus(); return false}

if (document.Register.country.value=="")
	{alert('Please select your country');	document.Register.country.focus(); return false}

}

function checkmailinglist() {
if (document.mailinglist.fname.value=="")
	{alert('Please key your name');	document.mailinglist.fname.focus(); return false}

if (document.mailinglist.email.value=="")
	{alert('Please key your email address');	document.mailinglist.email.focus(); return false}

	var emailIDM=document.mailinglist.email;
	
	if (echeck(emailIDM.value)==false){
		emailIDM.value=""
		emailIDM.focus()
		return false
	}

alert ("Thankyou, you have been added to our our mailing list");
}


function findPosX(obj) {
    var curleft = 0;
    if (obj.offsetParent) {
        while (1) {
            curleft+=obj.offsetLeft;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.x) {
        curleft+=obj.x;
    }
    return curleft;
}
function findPosY(obj) {
    var curtop = 0;
    if (obj.offsetParent) {
        while (1) {
            curtop+=obj.offsetTop;
            if (!obj.offsetParent) {
                break;
            }
            obj=obj.offsetParent;
        }
    } else if (obj.y) {
        curtop+=obj.y;
    }
    return curtop;
}

function cleartextbox(text_box){
	text_box.value = "";
}

function restoretextbox(text_box,boxval){
	if (text_box.value == ""){ 
		text_box.value = boxval; 
	}
}

function echeck(str) {

		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   alert("Please provide a valid email address.")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Please provide a valid email address.")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		   alert("Please provide a valid email address.")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		   alert("Please provide a valid email address.")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		   alert("Please provide a valid email address.")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		   alert("Please provide a valid email address.")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		   alert("Please provide a valid email address.")
		    return false
		 }

 		 return true					
	}

	function emailPage(page_url){
	win_name= "_ep";
	win_options= "toolbars=no,status=no,left=10,top=10,width=550,height=400,scrollbars=1,resize=yes,resizable";
	window.open(page_url,win_name,win_options);
	}
	

	function popBlowup(prodName, prodImage){
		var blowupWin = window.open("", "IMAGE_POPUP", "width=510,height=530,top=10,left=10,resizable=yes ");
		blowupWin.document.write("<html>\n");
		blowupWin.document.write("<head>\n");
		blowupWin.document.write('<meta http-equiv="content-type" content="text/html;charset=iso-8859-1" />\n');
		blowupWin.document.write('<title>' + prodName + '</title>\n');
		blowupWin.document.write("<link rel='stylesheet' href='<?php echo URL ?>style.css' type='text/css'>\n");
		blowupWin.document.write("</head>\n");
		blowupWin.document.write('<body topmargin="4" bottommargin="4" leftmargin="4" rightmargin="4" marginheight="4" marginwidth="4" class="popupwindow">\n');
		blowupWin.document.write('<table border="0" cellpadding="0" cellspacing="5" width="100%" align="center" class="popupwindow">\n<tr><td align="center" valign="top" colspan="2">\n');
		blowupWin.document.write('<img src="' + prodImage + '" border="1" /></td></tr><tr><td>\n');
		blowupWin.document.write('<span class=popupwindowtext>' + prodName + '</span>\n');
		blowupWin.document.write('</td><td align="right">\n');
		blowupWin.document.write('<a href="javascript:window.close();"><br><img src="<?php echo URL ?>ps_image/btn_close.gif" width="68" height="26" border="0" alt="close"/></a>&nbsp;&nbsp;');	
		blowupWin.document.write('</td></tr></table>\n');
		blowupWin.document.write("</body>\n");
		blowupWin.document.write("</html>\n");
		blowupWin.document.close();
		blowupWin.focus();
	}
	