// 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 checkcontactform() {

if (document.contactus.p_first_name.value=="")
	{alert('Please key your first name');	document.contactus.p_first_name.focus(); return false}

if (document.contactus.p_last_name.value=="")
	{alert('Please key your last name');	document.contactus.p_last_name.focus(); return false}

if (document.contactus.p_user_email.value=="")
	{alert('Please key your email address');	document.contactus.p_user_email.focus(); return false}

	var emailIDM=document.contactus.p_user_email;
	
	if (echeck(emailIDM.value)==false){
		emailIDM.value=""
		emailIDM.focus()
		return false
	}

if (document.contactus.p_city.value=="")
	{alert('Please key your city, suburb or town name');	document.contactus.p_city.focus(); return false}

if (document.contactus.p_state_country.value=="")
	{alert('Select your state or country');	document.contactus.p_state_country.focus(); return false}

if (document.contactus.p_postcode.value=="")
	{alert('Please key your postcode');	document.contactus.p_postcode.focus(); return false}

if (document.contactus.p_Hear_about_us.value=="")
	{alert('Please let us know how you heard about us');	document.contactus.p_Hear_about_us.focus(); return false}

if (document.contactus.p_message.value=="")
	{alert('Please key in your message');	document.contactus.p_message.focus(); return false}




		
	alert ("Thank you, a member of our staff will contact you shortly");
	}




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;
}

/* used for image swap on mouse over */
function SimpleSwap(el,which){
        el.src=el.getAttribute(which||"origsrc");
}


function checkWarranty() {
	
if (document.warranty.w_first_name.value=="")
	{alert('Please key your first name');	document.warranty.w_first_name.focus(); return false}

if (document.warranty.w_last_name.value=="")
	{alert('Please key your last name');	document.warranty.w_last_name.focus(); return false}

if (document.warranty.w_phone_1.value=="")
	{alert('Please key your phone number');	document.warranty.w_phone_1.focus(); return false}

if (document.warranty.w_user_email.value=="")
	{alert('Please key your email address');	document.warranty.w_user_email.focus(); return false}	

	var emailIDM=document.warranty.w_user_email;
	
	if (echeck(emailIDM.value)==false){
		emailIDM.value=""
		emailIDM.focus()
		return false
	}

if (document.warranty.w_address_1.value=="")
	{alert('Please key your address');	document.warranty.w_address_1.focus(); return false}

if (document.warranty.w_city.value=="")
	{alert('Please key your city');	document.warranty.w_city.focus(); return false}

if (document.warranty.w_state.value=="")
	{alert('Please key your state');	document.warranty.w_state.focus(); return false}

if (document.warranty.w_zip.value=="")
	{alert('Please key your postcode');	document.warranty.w_zip.focus(); return false}

if (document.warranty.w_model_number.value=="")
	{alert('Please provide the model number');	document.warranty.w_model_number.focus(); return false}

if (document.warranty.w_date_purchased.value=="")
	{alert('Please key the date purchased ');	document.warranty.w_date_purchased.focus(); return false}
	
if (document.warranty.w_retailer_name.value=="")
	{alert('Please provide the dealer / retailer name ');	document.warranty.w_retailer_name.focus(); return false}
	
if (document.warranty.w_retailer_location.value=="")
	{alert('Please provide the dealer / retailer location');	document.warranty.w_retailer_location.focus(); return false}		
}



	
	
