// JavaScript Document
function show_tab(div_name,div_name1){
	var x = document.getElementById(div_name);
	var y = document.getElementById(div_name1).getElementsByTagName('div');
	x.style.display = 'block';
	for (var i = 0; i < y.length; i++) { 
		if (y[i].style.display == 'block' && y[i].id != div_name) { 
			y[i].style.display = 'none';
		}
	}
}

function toggle_disp(id){
	var a = document.getElementById(id);
	if(a.style.display == 'none'){
		a.style.display = 'block';
	}
	else{
		a.style.display = 'none';
	}
}

/**
 * DHTML email validation script. Courtesy of SmartWebby.com (http://www.smartwebby.com/dhtml/)
 */

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("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   alert("Invalid E-mail ID")
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    alert("Invalid E-mail ID")
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    alert("Invalid E-mail ID")
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    alert("Invalid E-mail ID")
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    alert("Invalid E-mail ID")
		    return false
		 }

 		 return true					
	}

function ValidateEmail(){
	var emailID=document.subscription.email
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }

function validate_required(field,alerttxt)
{
with (field)
{
if (value==null||value=="")
  {alert(alerttxt);return false}
else {return true}
}
}

function validate_number(field,alerttxt)
{
	var stripped = field.value.replace(/[\(\)\.\-\ ]/g, '');
	if(stripped.value == null || stripped.value =="")
	{ alert(alerttxt); return false}
	else if (isNaN(parseInt(stripped)))
	{ alert(alerttxt); return false}
	else {return true}
}	

function checkboxvalidate(form,field,alerttxt)
{
	if(document.form.field.checked == false)
	{alert(alerttxt); return false}
	else {return true}
}

function getCheckedValue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}
		
function validate_form(thisform)
{
with (thisform)
{
if (validate_required(fname,"Please enter your first name")==false)
  {fname.focus();return false} 
if (validate_required(lname,"Please enter your last name")==false)
  {lname.focus();return false} 
if (validate_required(street_address,"Please enter a street address!")==false)
  {street_address.focus();return false} 
if (validate_required(city,"Please enter your Suburb/Locality")==false)
  {city.focus();return false} 
if (validate_required(pcode,"Please enter your postcode")==false)
  {pcode.focus();return false} 
}
}

// DROP DOWN MENU FUNCTIONS
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


