// coded by turtles 2007
//
// http://www.turtle-media.com/
//
// all rights reserved
//
var root
//root = 'http://www.daily7-daily10.com/'
root = 'http://www.a-gallery.com.hk/'

//////////////////////////////////////////////////////////////////////
/**
 * 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 Address")
		   return false
		}

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

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

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

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

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

 		 return true					
	}

///////////////////////////////////////////////////////////////////////////////////////////////////////////
function validateSignup(){
	var nameID=document.newsSignup.name
	var emailID=document.newsSignup.cm-hrijb-hrijb
	
	if ((nameID.value==null)||(nameID.value=="")){
		alert("Please enter your name")
		document.newsSignup.name.focus()
		return false
	}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		var emailID=document.newsSignup.cm-hrijb-hrijb.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		var emailID=document.newsSignup.cm-hrijb-hrijb.focus()
		return false
	}
	
	return true
 }
 
function validateContact(){
	var nameID=document.contactFrm.cname
	var emailID=document.contactFrm.email
	var msgID=document.contactFrm.msg
	
	if ((nameID.value==null)||(nameID.value=="")){
		alert("Please enter your name")
		document.contactFrm.cname.focus()
		return false
	}
	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please enter your email address")
		var emailID=document.contactFrm.email.focus()
		return false
	}
	
	if (echeck(emailID.value)==false){
		emailID.value=""
		var emailID=document.contactFrm.email.focus()
		return false
	}
	
	if ((msgID.value==null)||(msgID.value=="")){
		alert("Please enter a message")
		document.contactFrm.msg.focus()
		return false
	}
	
	return true
 } 

