// JavaScript Document
var timeStart = new Boolean(false);
var timeOutID;
var timeConstant = 2000;


function switchDiv(id,classID)
{
	document.getElementById(id).className = classID;
	document.getElementById(id).style.cursor = "pointer";
}

function showNav(id) //,classID
{
	if (timeStart == true)
	{
		clearInterval(timeOutID);
		timeStart = false;
	}
	document.getElementById(id).style.display = "block";
//	document.getElementById(id).className = classID;
	document.getElementById(id).style.cursor = "pointer";
	
	timeOutID = setInterval('clearMenu()',timeConstant);
	timeStart = true;
}

function hideNav(id) //,classID
{
	stopTimer();
	document.getElementById(id).style.display = "none";
//	document.getElementById(id).className = classID;
}

function showNavsub(id) //,classID
{
	document.getElementById(id).style.display = "block";
	document.getElementById(id).style.cursor = "pointer";
}

function hideNavsub(id) //,classID
{
	document.getElementById(id).style.display = "none";
}

function clearMenu()
{
	clearInterval(timeOutID);
	timeStart = false;
}

function stopTimer()
{
	clearInterval(timeOutID);
	timeStart = false;
}

function startTimer()
{
	if (timeStart == true)
	{
		clearInterval(timeOutID);
		timeStart = false;
	}	
	timeOutID = setInterval('clearMenu()',timeConstant);
	timeStart = true;
}

//function to print page
function printPage()
{
	window.print();
}

//function to email page
function mailPage()
{
  mail_str = "mailto:?subject= " + document.title;
  mail_str += "&body= I recommend you read this -- " + document.title;
  mail_str += ". You should check this out at, " + location.href; 
  location.href = mail_str;
}

//functio to add to favourites
function addFav()
{
	window.external.AddFavorite(location.href, document.title);
}
function fontChange(fnt)
{
	document.getElementById('maincontent').style.fontSize = fnt;
}
function imgOpen(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no,outerWidth=800,outerHeight=600');
}

function openNote(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no');
}
function openWin(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no');
}

function notify()
{
	alert("You are now leaving the Murray &amp; Roberts Group website.\Murray &amp; Roberts can not be held responsible for the content, accuracy or timeliness of any other websites.");
}

function applyeffect(){
						if (document.all){
						photoslider.filters.revealTrans.Transition=Math.floor(Math.random()*25)
						photoslider.filters.revealTrans.stop()
						photoslider.filters.revealTrans.apply()
						}
						}
						
						
						
						function playeffect(){
						if (document.all)
						photoslider.filters.revealTrans.play()
						}
						
						function keeptrack(){
						window.status="Image "+(which+1)+" of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: "+(which+1);
						}
						
						
						function backward(){
						if (which>0){
						which--
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						keeptrack()
						}
						}
						
						function forward(){
						if (which<photos.length-1){
						which++
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						keeptrack()
						}
						}
						
						function lastslide(){
						if (which<photos.length-1){
						which = photos.length-1
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						window.status= "Image " +photos.length+" of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: " +photos.length;
						}
						}
						
						function firstslide(){
						which = 0
						applyeffect()
						document.images.photoslider.src=photos[which]
						playeffect()
						window.status="Image 1 of "+photos.length
						document.getElementById('pagenum').innerHTML = "page: 1";
						}
						
function openTransform(URL)
{
	window.open(URL,'','scrollbars,resizable,outerWidth=800,outerHeight=600');
}

/* random banner image script */
var myImages = new Array();

myImages[0] = 'images/banner1.jpg';
myImages[1] = 'images/banner2.jpg';
myImages[2] = 'images/banner3.jpg';
myImages[3] = 'images/banner4.jpg';
myImages[4] = 'images/banner5.jpg';
myImages[5] = 'images/banner6.jpg';
myImages[6] = 'images/banner7.jpg';
myImages[7] = 'images/banner8.jpg';
myImages[8] = 'images/banner9.jpg';
myImages[9] = 'images/banner10.jpg';
myImages[10] = 'images/banner11.jpg';
myImages[11] = 'images/banner12.jpg';
myImages[12] = 'images/banner13.jpg';

function showImage(){
	var td = document.getElementById('banner');
	var index = Math.floor(Math.random() * myImages.length);
	
	td.style.backgroundImage = "url(" + myImages[index] + ")";
}

// Left Navigation functions
function showDis(id)
{
	document.getElementById('dis').style.display = "block";
	document.getElementById('hidenav').style.display = "none";
}
function hideDis(id)
{
	document.getElementById('dis').style.display = "none";
	document.getElementById('hidenav').style.display = "block";
}

function openWin(url)
{
	window.open(url,'','scrollbars=yes,resizable=yes,toolbars=no,menu=no,width=450,height=300');
}

// JavaScript Document
function expcol(id,img)
{
	myTbl = document.getElementById(id);
	myImg = document.getElementById(img)
	
	if(myTbl.style.display == "block")
	{
		myTbl.style.display = "none";
		myImg.src = "images/plus_icon.gif";
	}
	else
	{
		myTbl.style.display = "block";
		myImg.src = "images/minus_icon.gif";
	}
}

var imgs, imdex, request_string, site_id, linkserver, gif_server;

var formStepOptional = "False"; //defaults to 'False' ? ie the step is not optional, or this is not a form step. If the step is an optional one in the form, this value should be set to ?True?.

var customTagVariables = ""; //to cater for custom variables that a client might have. all variables are ';' delimited
var customTagValues = "";  //the custom values for the custom variables. all values are ';' delimited

var fv="0";
var av="0";

site_id = "mandr_main";
gif_server = "http://elite005.intervigil.com/mandr_main/";

imgs=new Array();
imdex = 0;

function linkClick(e)
{
	var ev,q,oEVT,txt,type;
	
	ev = e || window.event;
	if(ev){
		oEVT = getTagObject(ev,"A");
		
		if(oEVT.tagName != "A")
			oEVT = getTagObject(ev,"AREA");
			
		if(oEVT && (oEVT.tagName == "A" || oEVT.tagName == "AREA")){
			if((oEVT.hostname && oEVT.protocol && oEVT.href)){
				txt= ( (oEVT.tagName=="A") ?(oEVT.text||encodeURIComponent(oEVT.innerHTML)||oEVT.innerText||"") : encodeURIComponent(oEVT.outerHTML));	
				
				if (page_name == "") {
					page_name = location.pathname + location.search;
				}
				
				if(page_title == "") {
					page_title = document.title;
				}
				
				q = 'site='+escape(site_id)+'&lref='+escape(oEVT.href)+'&pth='+escape(page_name)+'&ptitle='+escape(page_title)+'&lnk='+txt+'&lId='+escape(oEVT.id)+'&ord=';doImage(q);
			}
		}		
	}
}

function getTagObject(oEVT,t){
	var o=oEVT.target||oEVT.srcElement;
	
	while (o.tagName&&(o.tagName!=t))
		o=o.parentElement||o.parentNode;
	return o;
}

function doImage(qs){

	var iSrc = gif_server + 'linkreceive.aspx?' + qs;
	
	if (document.images){
		imgs[imdex]=new Image();imgs[imdex].src= iSrc;imdex++;
	}
	else{
		document.write('<IMG BORDER="0" WIDTH="1" HEIGHT="1" SRC="' + gif_server + 'linkreceive.aspx?' + qs + '" >');
	}
}

function evtHDL(event,fn){
	if ((typeof(window[fn])=="function")){
		if (document.body.addEventListener){document.body.addEventListener(event,window[fn],true);}
		else if(document.body.attachEvent){document.body.attachEvent("on"+event,window[fn]);}
	}
}

function trackLinks(){
	
	//evtHDL("click","linkClick");
}

function trackForms(){
	
	//evtHDL("click","linkClick");
}

function getFlash()
{
	if (window.ActiveXObject){
		for(var k=12;k>0;k--){
			try{var obj = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+k);fv=k+".0";
				break;
			}catch(e){}
		}
	}
	else if (navigator.plugins&&navigator.plugins.length){
		for (var k=0;k<navigator.plugins.length;k++){
			if (navigator.plugins[k].name.indexOf('Shockwave Flash')!=-1){
				try{fv=navigator.plugins[k].description.split(' ')[2];
					fv=fv==''?'No version':fv;}catch(e){fv='No version'}
				break;
			}
		}
	}
}
function getAdobe()
{
	if (window.ActiveXObject){
		
		try{var obj = eval(new ActiveXObject("AcroPDF.PDF.1"))
			if(obj){av="7.00";return;}
		}catch(e){}
		
		try{var obj = eval(new ActiveXObject("PDF.PdfCtrl.1"))
			if(obj){av="4.00";return;}
		}catch(e){}
		
		for(var k=2;k<10;k++){
			try{var obj = new ActiveXObject("PDF.PdfCtrl."+k);av=k+".00";//Other!{4,7}
				break;
			}catch(e){}
		}
	}
	else if (navigator.plugins&&navigator.plugins.length){
		for (var k=0;k<navigator.plugins.length;k++){
			if (navigator.plugins[k].name.indexOf('Adobe Acrobat')!=-1){
				try{av=navigator.plugins[k].description.split('Version ')[1].split(' ')[0];
					av=av==''?'No version':av;}catch(e){av='No version'}
				break;
			}
		}
	}
}

function build_string( setting, value){
	request_string += "&" + setting + "=" + escape(value);
}

function vigilmetrixElite_tag(){

	if (page_name == "") {
		page_name = location.pathname + location.search;
	}
	if (page_title == "") {
		page_title = document.title;
	}

	var t = new Date();
	fv = "0"; av="0";
	
	request_string = "";	
	build_string( "site", site_id);
	build_string( "server", server_in_cluster);
	build_string( "ms", master_section);	
	build_string( "tz", t.getTimezoneOffset());
	build_string( "ti", page_title);
	build_string( "pn", page_name);
	build_string( "ref", window.document.referrer);
	build_string( "js", "1");
	build_string( "ck", navigator.cookieEnabled ? "1": "0");
	build_string( "lg", navigator.appName=="Netscape" ? navigator.language : navigator.userLanguage);
	build_string( "jv", navigator.javaEnabled()?"1":"0");
	build_string( "cp", campaign);
	build_string( "fn", formname);
	build_string( "fsnm", formstepname);
	build_string( "fsno", formstepnumber);
	build_string( "fsopt", formStepOptional); 
	build_string( "cvar", customTagVariables);
	build_string( "cval", customTagValues);
		
	if (typeof(screen)=="object"){
		build_string( "sw", screen.width);
		build_string( "sh", screen.height);
		build_string( "bpp", screen.colorDepth);		
	}
	else{
		build_string( "sw", 0);
		build_string( "sh", 0);
		build_string( "bpp", 0);		
	}
	getFlash();	
	build_string("fv",fv);
	getAdobe();
	build_string("av",av);

	if( request_string.length>2048 && navigator.userAgent.indexOf('MSIE')>=0)
		request_string= request_string.substring(0,2044);
	if (gif_server != "")
		document.write('<IMG BORDER="0" WIDTH="1" HEIGHT="1" SRC="' + gif_server + 'receive.aspx?' + request_string + '">');
}
