/*RAE Javascript*/


function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function P7_hideEl(evt) { //v1.5 by PVII-www.projectseven.com
 var b,r,m=false;if(document.layers){b=evt.target;if(b.p7aHide){
 b.visibility="hidden";}else{routeEvent(evt);}
 }else if(document.all&&!window.opera){b=event.srcElement;while(b){
 if(b.p7aHide){break;}b=b.parentElement;}if(!b.contains(event.toElement)){
 b.style.visibility="hidden";}}else if(document.getElementById){
 b=evt.currentTarget;r=evt.relatedTarget;while(r){if(b==r){m=true;
 break;}r=r.parentNode;}if(!m){b.style.visibility="hidden";}}
}

function P7_autoHide() { //v1.5 by PVII-www.projectseven.com
 var i,g;for(i=0;i<arguments.length;i++){
 if((g=MM_findObj(arguments[i]))!=null){g.p7aHide=true;if(document.layers){
 g.captureEvents(Event.MOUSEOUT);}g.onmouseout=P7_hideEl;}}
}

function P7_autoShowHide() { //v1.2 by PVII-www.projectseven.com
 var g,b,k,f,ag=arguments,a=parseInt(ag[0]);
 if(!document.p7setc){p7c=new Array();document.p7setc=true;for(var u=0;u<10;u++){
 p7c[u]=new Array();}}for(k=0;k<p7c[a].length;k++){if((g=MM_findObj(p7c[a][k]))!=null){
 b=(document.layers)?g:g.style;b.visibility="hidden";}}for(k=1;k<ag.length;k++){
 if((g=MM_findObj(ag[k]))!=null){b=(document.layers)?g:g.style;b.visibility="visible";
 f=false;for(var j=0;j<p7c[a].length;j++){if(ag[k]==p7c[a][j]){f=true;}}
 if(!f){p7c[a][p7c[a].length++]=ag[k];}}}
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);


function doRedirect(){setTimeout("timedRedirect()", 5*1000);}
function timedRedirect(){window.location.replace(sTargetURL);}

function show_photo(pFileName, pCaption, pDescription) {
// close other child window
if (window.pixsWin) {pixsWin.close()}

// specify window paramaters
	photoWin = window.open( "", "photo", "width=500,height=400,status=0,scrollbars=0,titlebar=no,resizable=0,screenX=50,screenY=50,left=30,top=150,copyhistory=0,toolbar=0,galleyimg=no");

// write content to window
	photoWin.document.write('<html><head><title>' + pCaption + '</title></head>');	
	photoWin.document.write('<body bgcolor=#000 text=#ffffcc onmousedown = "javascript:window.close()" >' );
	photoWin.document.write('<center>');
	photoWin.document.write('<img src="' + pFileName + '" galleryimg=no title=Copyright_&copy_1_FieldsappersRAE_2003-7><p>');
	photoWin.document.write('<font face="arial,helvetica" font size=-1>');	
	photoWin.document.write( ' ' + pDescription +' </font><br>');
	photoWin.document.write('</font><p></body></html>');
	photoWin.document.close();	
	if (window.focus) {photoWin.focus()}

// If NetScape, bring window to front
	if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}
//e-mail address check
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					
	}
//Validation of Forms	
function ValidateForm(){
	var firstnameID=document.member.Requested_First_Name
	var familynameID=document.member.Requested_Family_Name
	var realnameID=document.member.realname
	var emailID=document.member.email
	var checkID=document.member.Agree
	if ((firstnameID.value==null)||(firstnameID.value=="")){
		alert("Please Enter First Name of Person you would like to contact!")
		firstnameID.focus()
		return false
	}
	if ((familynameID.value==null)||(familynameID.value=="")){
		alert("Please Enter Family Name of Person you would like to contact!")
		familynameID.focus()
		return false
	}
	if ((realnameID.value==null)||(realnameID.value=="")){
		alert("Please Enter your Full Name")
		realnameID.focus()
		return false
	}	
	if ((emailID.value==null)||(emailID.value=="")){
		alert("Please Enter your Email ID")
		emailID.focus()
		return false
	}
	if(!document.member.Agree.checked){
		alert("Please tick box acknowledging that you understand our terms of use below"); 
		return false;
	 }
	if (echeck(emailID.value)==false){
		emailID.value=""
		emailID.focus()
		return false
	}
	return true
 }