// 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);
	}
	
/* used for credit card payment form */	

/* This script and many more are available free online at
The JavaScript Source!! http://javascript.internet.com
Created by: Cyanide_7 |  */
var isNN = (navigator.appName.indexOf("Netscape")!=-1);

function autoTab(input,len, e) {
  var keyCode = (isNN) ? e.which : e.keyCode; 
  var filter = (isNN) ? [0,8,9] : [0,8,9,16,17,18,37,38,39,40,46];
  if(input.value.length >= len && !containsElement(filter,keyCode)) {
    input.value = input.value.slice(0, len);
    input.form[(getIndex(input)+1) % input.form.length].focus();
  }

  function containsElement(arr, ele) {
    var found = false, index = 0;
    while(!found && index < arr.length)
    if(arr[index] == ele)
    found = true;
    else
    index++;
    return found;
  }

  function getIndex(input) {
    var index = -1, i = 0, found = false;
    while (i < input.form.length && index == -1)
    if (input.form[i] == input)index = i;
    else i++;
    return index;
  }
  return true;
}
	
function check_agree() {
	if(!document.Checkout.agreement.checked){
		alert ("You need to agree to our terms and conditions to continue");
		return false;
	}
}

	
