//Generic Functions
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 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
}
function navigate_external(str){
	MM_openBrWindow(str,'','top=0,left=0,width=1024,height=768,scrollbars=yes,resizable=yes,status=yes')
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//Endof Generic Functions

function CreateMenuBarStyle(){
	var LocationReference=calmenuleft('MenuLocatorMaster');
	LocationReference=eval(LocationReference+MenuAdjustment);
	var TopMenu=document.getElementById('TopMenu');
	var SiteMenu=document.getElementById('SiteMenu');
	LocationReferenceAdjust=eval(LocationReference)+'px !important;';
	var ss1 = document.createElement('style');
	var def = '#MenuBar {\nposition: absolute !important;\n top:135px !important;\n left: '+LocationReferenceAdjust+'\n z-index:15;!important;\n display:block !important;\n height:30px !important;\n width: 520px;\n visibility: visible;\n}\n';
    ss1.setAttribute("type", "text/css");
    if (ss1.styleSheet) {   // IE
        ss1.styleSheet.cssText = def;
    } else {                // the world
        var tt1 = document.createTextNode(def);
        ss1.appendChild(tt1);
    }
    var hh1 = document.getElementsByTagName('head')[0];
    hh1.appendChild(ss1);
}
function BackEndCreateMenuBarStyle(){
	var LocationReference=calmenuleft('MenuLocatorMaster');
	LocationReference=eval(LocationReference);
	var TopMenu=document.getElementById('TopMenu');
	var SiteMenu=document.getElementById('SiteMenu');
	LocationReferenceAdjust=eval(LocationReference)+'px !important;';
	var ss1 = document.createElement('style');
	var def = '#MenuBar {\nposition: absolute !important;\n top:10px !important;\n left: '+LocationReferenceAdjust+'\n z-index:15;!important;\n display:block !important;\n height:30px !important;\n width: 520px;\n visibility: visible;\n}\n';
    ss1.setAttribute("type", "text/css");
    if (ss1.styleSheet) {   // IE
        ss1.styleSheet.cssText = def;
    } else {                // the world
        var tt1 = document.createTextNode(def);
        ss1.appendChild(tt1);
    }
    var hh1 = document.getElementsByTagName('head')[0];
    hh1.appendChild(ss1);
}
//Link to Admin
function gotoadmin(){
	MM_goToURL('parent','Administration/Login.php');return document.MM_returnValue;
}
//End of Link to Admin
//Hide Video for Jqueary Image
function HideVideo(){
	return false;
	var VideoContainer=document.getElementById('VideoObjectContainer');
	if(!VideoContainer){
		return false;
	}
	else if(VideoContainer){
		var CurrentState=document.getElementById('MovieContainer').className;
		
	}
	if(CurrentState=="display"){
		document.getElementById('MovieContainer').className="hidden";
	}else{
		document.getElementById('MovieContainer').className="display";
	}
}
//Contact Functions
function AssetsTested(){
	document.getElementById('CheckedAssets').value="";
	
	var Assets=new Array('steelC','fibreC','timberC','concreteC');
	for (var i=0;i<Assets.length;i++) {
		var currentAsset=document.getElementById(Assets[i]);
		if(currentAsset.checked==1){
			AssetValue=document.getElementById(Assets[i]).value
			CurrentList=document.getElementById('CheckedAssets').value
			document.getElementById('CheckedAssets').value+=AssetValue+" ";
		}
	}
}
function ReloadHP(){
	alert('Thank you for your submission.\nWe will endeavour to respond as soon as possible.\nA copy of your submission has been sent to the email address supplied.');
	MM_goToURL('parent','index.php');
	return document.MM_returnValue;
}
function ContactCSP(str){
	document.location.href='Contact_Us.php';
}
function ContactJamie(){
	document.location.href='mailto:jamie.flintoff@rei-lux.com.au';
}
//Gallery
function RetreiveGalleryCategories(str,PageName){
	if(str=="xx"){
		return false;
	}
	else if(str=="All"){
	    var URL=("Gallery.php")
	    MM_goToURL('self',URL);
	    return document.MM_returnValue;
	}else{
	    var URL=("Gallery.php?SelectedCategory="+str)
	    MM_goToURL('self',URL);
	    return document.MM_returnValue;
	}
}

 function downloadme(x){ 
    myTempWindow = window.open(x,'','left=10000,screenX=10000'); 
    myTempWindow.document.execCommand('SaveAs','null',x); 
    myTempWindow.close(); 
} 
