var propinvest = new Array() ;
propinvest[0] = new Image(180,21) ;
propinvest[1] = new Image(180,21) ;

propinvest[0].src = "images/lmenu-propinvest-off.gif" ;
propinvest[1].src = "images/lmenu-propinvest-on.gif" ;


var propmanage = new Array() ;
propmanage[0] = new Image(180,21) ;
propmanage[1] = new Image(180,21) ;

propmanage[0].src = "images/lmenu-propmanage-off.gif" ;
propmanage[1].src = "images/lmenu-propmanage-on.gif" ;


var blockmanage = new Array() ;
blockmanage[0] = new Image(180,21) ;
blockmanage[1] = new Image(180,21) ;

blockmanage[0].src = "images/lmenu-blockmanage-off.gif" ;
blockmanage[1].src = "images/lmenu-blockmanage-on.gif" ;


var corpfinance = new Array() ;
corpfinance[0] = new Image(180,21) ;
corpfinance[1] = new Image(180,21) ;

corpfinance[0].src = "images/lmenu-corporatefin-off.gif" ;
corpfinance[1].src = "images/lmenu-corporatefin-on.gif" ;


var invrelations = new Array() ;
invrelations[0] = new Image(180,21) ;
invrelations[1] = new Image(180,21) ;

invrelations[0].src = "images/lmenu-investorrelations-off.gif" ;
invrelations[1].src = "images/lmenu-investorrelations-on.gif" ;


var people = new Array() ;
people[0] = new Image(180,21) ;
people[1] = new Image(180,21) ;

people[0].src = "images/lmenu-people-off.gif" ;
people[1].src = "images/lmenu-people-on.gif" ;


var press = new Array() ;
press[0] = new Image(180,21) ;
press[1] = new Image(180,21) ;

press[0].src = "images/lmenu-inthepress-off.gif" ;
press[1].src = "images/lmenu-inthepress-on.gif" ;


var contact = new Array() ;
contact[0] = new Image(180,21) ;
contact[1] = new Image(180,21) ;

contact[0].src = "images/lmenu-contact-off.gif" ;
contact[1].src = "images/lmenu-contact-on.gif" ;


var coronation = new Array() ;
coronation[0] = new Image(180,21) ;
coronation[1] = new Image(180,21) ;

coronation[0].src = "images/lmenu-coronation-off.gif" ;
coronation[1].src = "images/lmenu-coronation-on.gif" ;


var visiblefilms = new Array() ;
visiblefilms[0] = new Image(180,21) ;
visiblefilms[1] = new Image(180,21) ;

visiblefilms[0].src = "images/lmenu-visiblefilms-off.gif" ;
visiblefilms[1].src = "images/lmenu-visiblefilms-on.gif" ;


function changeImg(array,index){

	if(array == "propinvest")
	{

		document.images["propinvest"].src = propinvest[index].src ;

	}else if(array == "propmanage")
	{

		document.images["propmanage"].src = propmanage[index].src ;

	}else if(array == "blockmanage")
	{

		document.images["blockmanage"].src = blockmanage[index].src ;

	}else if(array == "corpfinance")
	{

		document.images["corpfinance"].src = corpfinance[index].src ;

	}else if(array == "invrelations")
	{

		document.images["invrelations"].src = invrelations[index].src ;

	}else if(array == "people")
	{

		document.images["people"].src = people[index].src ;

	}else if(array == "press")
	{

		document.images["press"].src = press[index].src ;

	}else if(array == "contact")
	{

		document.images["contact"].src = contact[index].src ;

	}else if(array == "coronation")
	{

		document.images["coronation"].src = coronation[index].src ;

	}else if(array == "visiblefilms")
	{

		document.images["visiblefilms"].src = visiblefilms[index].src ;

	}

}







function newWindow(theurl,thewidth,theheight){

	newWin = window.open(theurl,'newWindow','width=' + thewidth + ',height=' + theheight + ',toolbar=no,location=no,scrollbars=yes,resizable=yes');

}





function launchPresentation(slideno){

	newWin = window.open('presentation.asp?Slide=' + slideno,'newWindow','width=682,height=555,toolbar=no,location=no,scrollbars=no,resizable=no');

}





function launchRNS(url){

	newWin = window.open('rns-announcements/' + url,'newWindow','width=700,height=500,toolbar=no,location=no,scrollbars=yes,resizable=no');

}

function launchCMSRNS(url){

	newWin = window.open('rns.asp?id=' + url,'newWindow','width=700,height=500,toolbar=no,location=no,scrollbars=yes,resizable=yes');

}

function agriTerms(){

	newWin = window.open('agriimterms.asp','newWindow','width=500,height=500,toolbar=no,location=no,scrollbars=yes,resizable=yes');

}



function closePresentation()
{
	clearInterval(slideshow);
	window.close();
}





var currPhoto = 0;
var prevPhoto = 0;
var photoList = "slide1.jpg;slide2.jpg;slide3.jpg;slide4.jpg;slide5.jpg;slide6.jpg;slide7.jpg;slide8.jpg;slide9.jpg;slide10.jpg;slide11.jpg";
var duration = 15;
var i = duration;
var slideshow;
var isInterval = false;

function startPresentation(startSlide,startFrom) 
{
	if(!isInterval)
	{	
		if(startFrom)
		{
			currPhoto = startSlide;
			rotatePhoto('',currPhoto,false);
		}

		// Time is in seconds X 1000
		slideshow = setInterval("countdown()", 1000);
		isInterval = true;
	}
}




function pausePresentation()
{
	if(!isInterval)
	{
		startPresentation(currPhoto,false);
		document.getElementById('pause').innerHTML= "Pause";
	}else
	{
		clearInterval(slideshow);
		isInterval = false;
		document.getElementById('pause').innerHTML= "Resume";
	}
}




function countdown()
{
	i = i - 1;
	if(i > 0)
	{
		if(i != 1)
		{
			document.getElementById('countdowntext').innerHTML= i + " seconds until next slide";
		}else
		{
			document.getElementById('countdowntext').innerHTML= i + " second until next slide";
		}
	}else
	{
		rotatePhoto('next',-1,false);
		i = duration;
		document.getElementById('countdowntext').innerHTML= i + " seconds until next slide";
	}
}




function rotatePhoto(direction,changeTo,restartCountdown)
{

	var photoArr = photoList.split(';');


	if(changeTo >= 0)
	{

		currPhoto = changeTo;

	}else
	{	

		prevPhoto = currPhoto;

		if(direction == 'prev')
		{
			currPhoto = currPhoto - 1;
		}else
		{
			currPhoto = currPhoto + 1;
		}

	
		if(currPhoto == -1)
		{
			currPhoto = photoArr.length - 1;
		}


		if(photoArr[currPhoto] == null)
		{
			currPhoto = 0;
		}

	}


	if(restartCountdown && isInterval)
	{
		clearInterval(slideshow);
		i = duration;
		slideshow = setInterval("countdown()", 1000);
		document.getElementById('countdowntext').innerHTML= i + " seconds until next slide";
		isInterval = true;
	}

	document.images.slide.src = "images/slides/" + photoArr[currPhoto];

	document.getElementById('slidetext').innerHTML="Slide " + (currPhoto + 1) + " of 11";

}



	var icon;


function toggleLayer(whichLayer)
{

	if (document.getElementById)
	{

		// this is the way the standards work

		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
		icon = document.getElementById(whichLayer + "icon");

	}
	else if (document.all)
	{
		// this is the way old msie versions work

		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
		icon = document.all[whichLayer + "icon"];

	}
	else if (document.layers)
	{

		// this is the way nn4 works
	
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
		icon = document.images[whichLayer + "icon"];

	}

	if(eval(icon))
	{
		if(icon.src == 'http://www.braemar-group.co.uk/images/contract.gif')
		{
			icon.src = 'http://www.braemar-group.co.uk/images/expand.gif';
		}else
		{
			icon.src = 'http://www.braemar-group.co.uk/images/contract.gif';
		}
	}
}


function swapImage(imageUrl) {

	var mainImage = document.getElementById("mainimage");
	
	mainImage.src = imageUrl;

}

