/*********************Global Values************************************/
var strCurrentTab	= "1"
var intStartTab		= 1
var intLastTab		= 7
/**********************************************************************/
/************Setup position of map logo (absolute)*********************/

function mapImage_onload() {
	document.getElementById("mapImage").style.position	= "absolute"
	document.getElementById("mapImage").style.left		= (window.screen.availWidth - 10) - 85
	document.getElementById("mapImage").style.top		= 5
}

/**********************************************************************/
/************Functions to setup tab functions(over/out/click)**********/

function tab1_onclick() {tabClick("1","sections/section1")}
function tab2_onclick() {tabClick("2","sections/section2")}
function tab3_onclick() {tabClick("3","sections/section6")}
function tab4_onclick() {tabClick("4","sections/section3")}
function tab5_onclick() {tabClick("5","sections/section4")}
function tab6_onclick() {tabClick("6","sections/section5")}
function tab7_onclick() {tabClick("7","sections/section7")}

function tab1_onmouseover() {tabOver("1")}
function tab2_onmouseover() {tabOver("2")}
function tab3_onmouseover() {tabOver("3")}
function tab4_onmouseover() {tabOver("4")}
function tab5_onmouseover() {tabOver("5")}
function tab6_onmouseover() {tabOver("6")}
function tab7_onmouseover() {tabOver("7")}

function tab1end_onmouseover() {tabOver("1")}
function tab2end_onmouseover() {tabOver("2")}
function tab3end_onmouseover() {tabOver("3")}
function tab4end_onmouseover() {tabOver("4")}
function tab5end_onmouseover() {tabOver("5")}
function tab6end_onmouseover() {tabOver("6")}


function tab1_onmouseout() {tabOut("1")}
function tab2_onmouseout() {tabOut("2")}
function tab3_onmouseout() {tabOut("3")}
function tab4_onmouseout() {tabOut("4")}
function tab5_onmouseout() {tabOut("5")}
function tab6_onmouseout() {tabOut("6")}
function tab7_onmouseout() {tabOut("7")}

function tab1end_onmouseout() {tabOut("1")}
function tab2end_onmouseout() {tabOut("2")}
function tab3end_onmouseout() {tabOut("3")}
function tab4end_onmouseout() {tabOut("4")}
function tab5end_onmouseout() {tabOut("5")}
function tab6end_onmouseout() {tabOut("6")}

/**********************************************************************/

/************Functions to setup top link functions(over/out/click)*****/

function top1_onclick() {topclick("top1","Sections/Maintenance/Registration/default.asp","1")}
function top2_onclick() {
	var favoriteurl="http://www.research-lincs.org.uk"; 
	var favoritetitle="Lincolnshire Research Observatory"; 
	window.external.AddFavorite(favoriteurl,favoritetitle); 
}
function top3_onclick() {
	//tabClick("6","")
	topclick("top3","sections/section5/LoadSection.asp?contact=1","all")
}
function top1b_onclick() {
	tabClick("1","sections/section1")
	topclick("top1","sections/section1/LoadSection.asp?details=1","")
}

function top1_onmouseover() {topover("top1")}
function top2_onmouseover() {topover("top2")}
function top3_onmouseover() {topover("top3")}
function top1b_onmouseover() {topover("top1b")}

function top1_onmouseout() {topout("top1")}
function top1b_onmouseout() {topout("top1b")}
function top2_onmouseout() {topout("top2")}
function top3_onmouseout() {topout("top3")}

/**********************************************************************/

/********************Top link functions(over/out/click)****************/

function topout(topID){document.getElementById(topID).className = "menuitem"}
function topover(topID){document.getElementById(topID).className = "menuitem_hover"}
function topclick(topID,pageURL,strNew) {
	if (strNew != "") {
		window.parent.section.main.location = pageURL
	}
	else {
		window.parent.section.location = pageURL
	}
}

/**********************************************************************/

/********************Tab functions(over/out/click)*********************/

function tabOut(tabID) {
	var thisDesc	= document.getElementById('tabDesc');
	var startTab	= document.getElementById('tabstart');
	var endTab		= document.getElementById('tabend');
	
	var thisTab		= document.getElementById('tab' + tabID);
	var thisendTab	= document.getElementById('tab' + tabID + 'end');
	var thisendTab2	= document.getElementById('tab' + (parseInt(tabID) - 1) + 'end');
	
	thisDesc.innerHTML	= '&nbsp;'
	thisDesc.className	= "selectedTitleBar"
	thisTab.style.color = "black"
	
	if (strCurrentTab != tabID) {
		//update tab central backgrounds
		thisTab.style.backgroundImage	= 'url("images/Header/text.gif")';
			
		if (parseInt(tabID) == intStartTab) {
			//clicking tab 1
			startTab.src	= "images/Header/start2.gif";
			
			if (parseInt(strCurrentTab) == intLastTab) 
				{endTab.src		= "images/Header/endselected.gif";}
			else endTab.src		= "images/Header/end.gif"
			
			if (parseInt(strCurrentTab) != 2) 
				{thisendTab.src	= "images/Header/un_un.gif"} 
			else thisendTab.src	= "images/Header/un_selected.gif"
		}
		if (parseInt(tabID) > intStartTab && parseInt(tabID) < intLastTab) {
			//over tab 2-5
			if (parseInt(strCurrentTab) == intStartTab) 
				{startTab.src	= "images/Header/startselected.gif";}
			else startTab.src	= "images/Header/start2.gif";
			
			if (parseInt(strCurrentTab) == intLastTab) 
				{endTab.src		= "images/Header/endselected.gif";}
			else endTab.src		= "images/Header/end.gif";
			
			if (parseInt(tabID) == parseInt(strCurrentTab) + 1) 
				{thisendTab2.src= "images/Header/selected_un.gif"}
			else thisendTab2.src= "images/Header/un_un.gif"
				
			if (parseInt(tabID) == parseInt(strCurrentTab) - 1) 
				{thisendTab.src	= "images/Header/un_selected.gif"}
			else thisendTab.src	= "images/Header/un_un.gif"
		}
		if (parseInt(tabID) > (intLastTab - 1)) {
			//over tab 6
			if (parseInt(strCurrentTab) == intStartTab) 
				{startTab.src	= "images/Header/startselected.gif";}
			else startTab.src	= "images/Header/start2.gif";
			
			if (parseInt(strCurrentTab) == (intLastTab-1)) 
				{thisendTab2.src= "images/Header/selected_un.gif"}
			else thisendTab2.src= "images/Header/un_un.gif"
			
			endTab.src		= "images/Header/end.gif";
		}
	}
}

function tabOver(tabID) {
	
	var thisDesc	= document.getElementById('tabDesc');
	var startTab	= document.getElementById('tabstart');
	var endTab		= document.getElementById('tabend');
	
	var thisTab		= document.getElementById('tab' + tabID);
	var thisendTab	= document.getElementById('tab' + tabID + 'end');
	var thisendTab2	= document.getElementById('tab' + (parseInt(tabID) - 1) + 'end');
	
	thisTab.style.color = "#3367A0"
	
	if (strCurrentTab != tabID) thisDesc.className = "titleHover"
	
	switch (tabID) {
		case '1' : thisDesc.innerHTML = 'Go to the home page';break;
		case '2' : thisDesc.innerHTML = 'Search all available documents, static maps, datasets and further information held on the site';break;
		case '3' : thisDesc.innerHTML = 'Online Mapping';break;
		case '4' : thisDesc.innerHTML = 'Online Research and Consultation Awareness Calendar';break;
		case '5' : thisDesc.innerHTML = 'LRO Contacts and the Services we offer';break;
		case '6' : thisDesc.innerHTML = 'About The Lincolnshire Research Observatory';break;
		case '7' : thisDesc.innerHTML = 'Interactive reports, databases and benchmarking';break;
	}
	
	if (strCurrentTab != tabID) {
		//update tab central backgrounds
		thisTab.style.backgroundImage	= 'url("images/Header/texthover.gif")';
			
		if (parseInt(tabID) == intStartTab) {
			//over first tab
			startTab.src	= "images/Header/starthover.gif";
			
			if (parseInt(strCurrentTab) == intLastTab) 
				{endTab.src		= "images/Header/endselected.gif";}
			else endTab.src		= "images/Header/end.gif"
			
			if (parseInt(strCurrentTab) != (intStartTab + 1)) 
				{thisendTab.src	= "images/Header/hover_un.gif"} 
			else thisendTab.src	= "images/Header/hover_selected.gif"
		}
		if (parseInt(tabID) > intStartTab && parseInt(tabID) < intLastTab) {
			//over tab 2-5
			if (parseInt(strCurrentTab) == intStartTab) 
				{startTab.src	= "images/Header/startselected.gif";}
			else startTab.src	= "images/Header/start2.gif";
			
			if (parseInt(strCurrentTab) == intLastTab) 
				{endTab.src		= "images/Header/endselected.gif";}
			else endTab.src		= "images/Header/end.gif";
			
			if (parseInt(tabID) == parseInt(strCurrentTab) + 1) 
				{thisendTab2.src= "images/Header/selected_hover.gif"}
			else thisendTab2.src= "images/Header/un_hover.gif"
				
			if (parseInt(tabID) == parseInt(strCurrentTab) - 1) 
				{thisendTab.src	= "images/Header/hover_selected.gif"}
			else thisendTab.src	= "images/Header/hover_un.gif"
		}
		if (parseInt(tabID) > (intLastTab -1)) {
			//over final tab
			if (parseInt(strCurrentTab) == intStartTab) 
				{startTab.src	= "images/Header/startselected.gif";}
			else startTab.src	= "images/Header/start2.gif";
			
			if (parseInt(strCurrentTab) == (intLastTab - 1)) 
				{thisendTab2.src= "images/Header/selected_hover.gif"}
			else thisendTab2.src= "images/Header/un_hover.gif"
			
			endTab.src		= "images/Header/endhover.gif";
		}
	}
}

function tabClick(tabID,pageURL) {
	//alert(intAccess)
	if (!Frozen) {
		var thisDesc	= document.getElementById('tabDesc');
		var startTab	= document.getElementById('tabstart');
		var endTab		= document.getElementById('tabend');
	
		var thisTab		= document.getElementById('tab' + tabID);
		var thisendTab	= document.getElementById('tab' + tabID + 'end');
		var thisendTab2	= document.getElementById('tab' + (parseInt(tabID) - 1) + 'end');
	
		var lastTab		= document.getElementById('tab' + strCurrentTab);
		var lastendTab	= document.getElementById('tab' + strCurrentTab + 'end');
		var lastendTab2	= document.getElementById('tab' + (parseInt(strCurrentTab) - 1) + 'end');
	
		//check that tab isnt already selected
		if (strCurrentTab != tabID) {
			//update tab central backgrounds
			thisTab.style.backgroundImage	= 'url("images/Header/textselected.gif")';
			lastTab.style.backgroundImage	= 'url("images/Header/text.gif")';
			
			//reset inbetween graphics
			if (lastendTab)	 {lastendTab.src	= "images/Header/un_un.gif"}
			if (lastendTab2) {lastendTab2.src	= "images/Header/un_un.gif"}
				
			if (parseInt(tabID) == intStartTab) {
				//clicking tab 1
				startTab.src	= "images/Header/startselected.gif";
				endTab.src		= "images/Header/end.gif";
				thisendTab.src	= "images/Header/selected_un.gif"
			}
			if (parseInt(tabID) > intStartTab && parseInt(tabID) < intLastTab) {
				//clicking tab 2-5
				startTab.src	= "images/Header/start2.gif";
				endTab.src		= "images/Header/end.gif";
				thisendTab2.src	= "images/Header/un_selected.gif"
				thisendTab.src	= "images/Header/selected_un.gif"
			}
			if (parseInt(tabID) > (intLastTab - 1)) {
				//clicking tab 6
				startTab.src	= "images/Header/start2.gif";
				endTab.src		= "images/Header/endselected.gif";
				thisendTab2.src	= "images/Header/un_selected.gif"
			}
		}
		//reset title bar class
		thisDesc.className	= "selectedTitleBar"
		lastTab.className	= "tab"
		thisTab.className	= "tabselected"
		strCurrentTab		= tabID;
		if (pageURL != "") {
			window.parent.section.location = pageURL
		}
	} else {
		alert("You must log in or become a visitor!")
	}
}

/**********************************************************************/