// --- Functions relating to the Printer Friendly page ----

function go_back() {

// Due to issues with history.go(-1) and certain browsers not recognizing the 

// '?print=on' argument as a different page, this code simulates the 'back'

// functionality.

  var test=String(document.location).substring(0,String(document.location).indexOf("print=on"))

  if (test.charAt(test.length-1)=='?') {test=test.substring(0,test.length-1);}

  document.location=test;

}



function printer() {

  document.location=document.location+"?print=on";

}



function printMode() {

  if (String(document.location).match("print=on")) {

    document.write('<body onLoad="window.print()"><link rel="stylesheet" href="' + siteurl +'libs/print.css" />');

  }

}



// --- ----------------------------------------------- ----





// browser detection

var agt = navigator.userAgent.toLowerCase();

var major = parseInt(navigator.appVersion);

var ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));

var opera = (agt.indexOf("opera") != -1);

var mac = (agt.indexOf("mac") != -1);

var ie4 = (ie && (major == 4) && (agt.indexOf("msie 4")!=-1) );



//Layer toggling

function toggleVisibility() {

  var inc, endInc=arguments.length;

  for (inc=0; inc<endInc; inc+=2) {

    var id = arguments[inc];

    if (arguments[inc+1] == 'hidden') param = "hidden";

    else if(arguments[inc+1]=='visible') param = "visible";

//alert(id);

    if (document.layers) document.layers[id].visibility = param;

    else if (document.all) eval("document.all." + id + ".style.visibility = \"" + param + "\"");

    else if (document.getElementById) eval("document.getElementById(id).style.visibility = \"" + param + "\"");

  }

}



function changeFeature(divId) {

  changeImages(current_client+'_text','./images/home/'+current_client+'.gif',divId+'_text','./images/home/'+divId+'_on.gif');

  toggleVisibility(current_client,'hidden',divId,'visible');

  current_client = divId;

}



function plato(arg) {

	if (document.images) {

		rslt = new Image();

		rslt.src = arg;

		return rslt;

	}

}



function changeImages() {

	if (document.images && (preloadFlag == true)) {

		for (var i=0; i<changeImages.arguments.length; i+=2) 

		{

			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];

		}

	}

}



var preloadFlag = false;

function preloadImages() {

	if (document.images) 

	{

	  var imgFiles = preloadImages.arguments;

      for (var i=0; i<imgFiles.length; i+=2) 

      {

        eval(imgFiles[i]+' = plato(imgFiles[i+1])');

        eval(imgFiles[i]+'.src = "'+imgFiles[i+1]+'"');

      }

		preloadFlag = true;

	}

}


preloadImages('clients','http://www.atre.net/images/top_nav/clients_on.gif','services','http://www.atre.net/images/top_nav/services_on.gif','careers','http://www.atre.net/images/top_nav/careers_on.gif','contact','http://www.atre.net/images/top_nav/contact_on.gif','company','http://www.atre.net/images/top_nav/company_on.gif');

	





function opendemoWindow(url, name) {

  popupWin = window.open(url, name, 'resizable=no,toolbar=no,height=390,width=530')

}



function showDivs(divId) {

  for (var i=0; i<divs.length; i++) {

    if (divId != divs[i]) toggleVisibility(divs[i],'hidden');

  }

  toggleVisibility(divId,'visible');

}



function toggleVisibility() {

  var inc, endInc=arguments.length;

  for (inc=0; inc<endInc; inc+=2) {

    var id = arguments[inc];

    if (arguments[inc+1] == 'hidden') param = "hidden";

    else if(arguments[inc+1]=='visible') param = "visible";

    if (document.layers) document.layers['container'].layers[id].visibility = param;

    else if (document.all) eval("document.all." + id + ".style.visibility = \"" + param + "\"");

    else if (document.getElementById) eval("document.getElementById(id).style.visibility = \"" + param + "\"");

  }

}
