window.onerror = HandleError
function HandleError(){
	return true;
}
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 reposmenus(){
	newwidth=getWidth();
	if(newwidth!=currentwidth){
	var curloc = document.location.href
    MM_goToURL('parent',curloc); 
	return document.MM_returnValue;
	}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
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 navigate(str){
	MM_goToURL('parent',str);return document.MM_returnValue
}
function loadimages(){
	MM_preloadImages('Buttons/Painting.gif','Buttons/Waterblasting.gif','Buttons/Maintenance.gif','Buttons/Abseiling.gif','Buttons/Building.gif','Buttons/About.gif','Buttons/Contact.gif','images/paint_active.gif','images/waterblasting_active.gif','images/abseiling_active.gif','Buttons/Refurbishment.gif','Buttons/Recladding.gif','Buttons/Roof_Access.gif','Buttons/Nationwide.gif','Buttons/Mulitrade.gif');
}
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 calmenuleft(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 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 MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function loadserviceimg(ing,str){
	MM_swapImage(ing,'',str,1)
}
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 BC_swapClass() {
   BC_swapClassRestore()
   var i,j=0,x,a=BC_swapClass.arguments; 
   document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oClassName) x.oClassName=x.className; x.className=a[i+2];}
}
function BC_swapClassRestore() { //v3.0
  var i,x,a=document.MM_sr; 
  for(i=0;a&&i<a.length&&(x=a[i])&&x.oClassName;i++) x.className=x.oClassName;
}
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 preparemail(){
	var requiredCount=0;
	var requiredRows=new Array('FirstNameRow','LastNameRow','CompanyRow','ContactRow','EmailRow','EnquiryRow');
	var requiredFields=new Array('First_Name','Last_Name','Business','Contact_Number','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="#FD7302";
			requiredCount++;
		}else{
			document.getElementById(requiredRows[i]).style.backgroundColor="#D9D9DB";
		}
	}
	if(requiredCount>0){
		alert('The Following Field(s) are Required');
	}else{
	document.getElementById('Recipient').value="enquiries@apsltd.co.nz";
	tmt_formManager('former','method=\'post\'');
	tmt_formAction('former','mail.php');
	tmt_formManager('former','submit()');
	}
}
//Project Navigation
function NavToProject(str){
	if(!str){
		return false;
	}
	MM_goToURL('parent',str);
	return document.MM_returnValue
}
//HP Tooltips
function Tooltipinfo(tooltip) {
	var TooltipArray=new Array();
	TooltipArray[0]="Trades include:<br>&#8226;&nbsp;Painting<br>&#8226;&nbsp;Building";
	TooltipArray[1]="<b>Reconstruction:</b><br>Specialists in large scale leaky building projects";
	TooltipArray[2]="<b>Waterproofing:</b><br>Some blurb here about waterproofing";
	TooltipArray[3]="<b>Height Safety:</b><br>Access systems for manufacturing, warehouse & commercial buildings";
	TooltipArray[4]="<b>Nationwide:</b><br>NZ-wide painting & signage projects";
	
	TheTip=TooltipArray[tooltip];
	Tip(TheTip, FADEIN, 300, WIDTH, 200)
}
function CeaseTips(){
	UnTip();
	BC_swapClassRestore()
}
function CaptionImages(obj,imgTip){
	var TooltipArray=new Array();
	TooltipArray[0]="<b>Full multi-trade services <br>for commercial property <br>maintenance</b>";
	TooltipArray[1]="<b>Re-cladding of multi-storey <br>leaky buildings</b>";
	TooltipArray[2]="<b>Certified applicators of <br>waterproofing systems</b>";
	TooltipArray[3]="<b>Design, supply and install <br>fall arrest / abseil systems</b>";
	TooltipArray[4]="<b>Nationwide property <br>maintenance and <br>re-branding</b>";
	
	TheTip=TooltipArray[imgTip];
	Tip(TheTip, FADEIN, 300)
}
function CeaseCaptionImages(obj){
	UnTip();
}
//Link to Admin
function gotoadmin(){
	MM_goToURL('parent','http://web.mydns.net.nz/www.apsclient.co.nz/Login/');return document.MM_returnValue;
}
//End of Link to Admin
