//window.onerror = HandleError
function HandleError(){
	return true;
}
var AreaIn;
//Menus 
function SetMenuClass(obj,SwfPaddng){
	document.getElementById(obj).className='ActiveMenu';
	document.getElementById('MenuLogoContainer').style.paddingTop=SwfPaddng+"px";
	if(AreaIn=="Members"){
		document.getElementById('Home').innerHTML="Members Home";
		document.getElementById('Home').href="MembersArea.php";
	}
}
function SetRegisterClass(){
	document.getElementById('men_logo').style.visibility="hidden";
}
//Generic Functions
function tmt_formManager(f,c){
	if(MM_findObj(f)){eval("MM_findObj('"+f+"')."+c);}
}
function tmt_formAction(f,p){
	if(MM_findObj(f)){eval("MM_findObj('"+f+"').action='"+p+"'");}
}
function MM_findObj(n, d) { //v4.0
  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 && document.getElementById) x=document.getElementById(n); return x;
}
function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}
function findObj(theObj, theDoc){
  var p, i, foundObj;
  
  if(!theDoc) theDoc = document;
  if( (p = theObj.indexOf("?")) > 0 && parent.frames.length){
    theDoc = parent.frames[theObj.substring(p+1)].document;
    theObj = theObj.substring(0,p);
  }
  if(!(foundObj = theDoc[theObj]) && theDoc.all) foundObj = theDoc.all[theObj];
  for (i=0; !foundObj && i < theDoc.forms.length; i++) 
    foundObj = theDoc.forms[i][theObj];
  for(i=0; !foundObj && theDoc.layers && i < theDoc.layers.length; i++) 
    foundObj = findObj(theObj,theDoc.layers[i].document);
  if(!foundObj && document.getElementById) foundObj = document.getElementById(theObj);
  
  return foundObj;
}
function calmenuleft(imgid){
	//alert(imgid)
	var LL = findObj(imgid)
	var xPos = eval(LL).offsetLeft;
	var tempEl = eval(LL).offsetParent;
  	while (tempEl != null) {
  		xPos += tempEl.offsetLeft;
  		tempEl = tempEl.offsetParent;
  	}
	return xPos;
}
function calmenutop(imgid){
	var TT = findObj(imgid)
	var yPos = eval(TT).offsetTop;
	var tempEl = eval(TT).offsetParent;
  	while (tempEl != null) {
  		yPos += tempEl.offsetTop;
  		tempEl = tempEl.offsetParent;
  	}
	return yPos;
}
function reposmenus(){
	newwidth=getWidth();
	if(newwidth!=currentwidth){
	var curloc = document.location.href
    MM_goToURL('parent',curloc); 
	return document.MM_returnValue;
	}
}
function getHeight(){
	return window.innerHeight ? window.innerHeight :(document.getBoxObjectFor ? Math.min(document.documentElement.clientHeight, document.body.clientHeight) : ((document.documentElement.clientHeight != 0) ? document.documentElement.clientHeight : (document.body ? document.body.clientHeight : 0)));
}
function getWidth(){
	return (document.layers||(document.getElementById&&!document.all)) ? window.outerWidth : (document.all ? document.body.clientWidth : 0);
}
function navigate(str){
	MM_goToURL('parent',str);return document.MM_returnValue
}
//Endof Generic Functions
//Popup & Preview
function launchScrollingpopup(url,w,h){
	var width=w, height=h;
    var left = (screen.width/2) - width/2;
    var top = (screen.height/3) - height/3;
    MM_openBrWindow(url,'','scrollbars=yes,top='+top+',left='+left+',width='+w+',height='+h)
}
function launchpopup(url,w,h){
	var width=w, height=h;
    var left = (screen.width/2) - width/2;
    var top = (screen.height/4) - height/4;
    MM_openBrWindow(url,'','top='+top+',left='+left+',width='+w+',height='+h+',resizable=yes')
}

function close_window() {
    window.close();
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  popupwindow=window.open(theURL,winName,features);
}
//Endof Popup & Preview
function CheckContactUsFields(){
	var requiredCount=0;
	var requiredRows=new Array('FullNameRow','EmailRow','EnquiryRow');
	var requiredFields=new Array('Name','Email','Enquiry');
	for (var i=0;i<requiredFields.length;i++) {
		var fieldValue=document.getElementById(requiredFields[i]).value
		if(!fieldValue){
			document.getElementById(requiredRows[i]).style.backgroundColor="#E66A37";
			requiredCount++;
		}else{
			document.getElementById(requiredRows[i]).style.backgroundColor="#E6E7E8";
		}
	}
	if(requiredCount>0){
		alert('The Following Field(s) are Required');
	}else{
		document.getElementById('Recipient').value="admin@nzaae.co.nz";
		//document.getElementById('Recipient').value="brian@cobussen.biz";
		tmt_formAction('ContactForm','Mailer.php')
		tmt_formManager('ContactForm','submit()');
	}
}
function CheckRegistrationFields(){
	var requiredCount=0;
	var requiredRows=new Array('loginRow','passwordRow','First_NameRow','Second_NameRow','EmailRow','PhoneRow');
	var requiredFields=new Array('login','password','First_Name','Second_Name','Email','Phone');
	for (var i=0;i<requiredFields.length;i++) {
		var fieldValue=document.getElementById(requiredFields[i]).value
		if(!fieldValue){
			document.getElementById(requiredRows[i]).style.backgroundColor="#E66A37";
			requiredCount++;
		}else{
			document.getElementById(requiredRows[i]).style.backgroundColor="#E6E7E8";
		}
	}
	if(requiredCount>0){
		alert('The Following Field(s) are Required');
	}else{
		document.getElementById('Recipient').value="admin@nzaae.co.nz";
		//document.getElementById('Recipient').value="brian@cobussen.biz";
		tmt_formAction('RegisterForm','Mailer.php')
		tmt_formManager('RegisterForm','submit()');
	}
}
function LogintoMembersArea(){
	tmt_formAction('LoginForm','Auth.php');
	tmt_formManager('LoginForm','submit()');
}
function gotoRegister() {
	MM_goToURL('parent','Register.php');
	return document.MM_returnValue;
}
//Members Registration
function AskForLoginDetails(){
	var emailAddress=document.getElementById('Email').value
	if(!emailAddress){
		alert('Please enter an email address');
		return false;
	}else{
		LookForEmail(emailAddress);
	}
}
function LookForEmail(Email){
   var xmlHttp;
   try 
    {   
	xmlHttp=new XMLHttpRequest();    
	}
    catch (e) 
    {   
	try 
	{      
	xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");      
	}
    catch (e)
    {      
	try
    {        
	xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");        
	}
    catch (e)
    {        
	alert("Your browser does not support AJAX!");        
	return false;       
	}      
	}    
	}
    xmlHttp.onreadystatechange=function()
    {
    if(xmlHttp.readyState==4)
    {
	ONUM=xmlHttp.responseText;
	alert(ONUM)
    }
	}
	var url="RetreivePasswordStatus.php?Email="+Email;
    xmlHttp.open("GET",url,true);
    xmlHttp.send(null);  
}
function gotoadmin(){
	MM_goToURL('parent','Administration/Login.php');return document.MM_returnValue;
}

