// JavaScript Document

function getQueryVariable(variable)
{
	var query = window.location.search.substring(1);
	var vars = query.split("&");
	for (var i=0;i<vars.length;i++)
	{
		var pair = vars[i].split("=");
		if (pair[0] == variable)
		{
			return pair[1];
		}
	}
} 

function how(){
	showPage();
}

function what(){
	showPage();
}

function who(){
	showPage();
}

function contact(){
	showPage();
}

var previousLink;
function toggleView(page){
	if(page != ""){
		var stageDiv = document.getElementById("body");
		var showContent = document.getElementById(page);
		stageDiv.innerHTML = showContent.innerHTML;
		
		highlightLink(page)
		
		var pageTitle = "Mercury | What We Do";
		if(window.location.href.indexOf("howwevedoneit.asp")>0){
			pageTitle = "Mercury | How We've Done It"
		}else if(window.location.href.indexOf("whatwedo.asp")>0){
			pageTitle = "Mercury | What We Do";
		}else if(window.location.href.indexOf("contactus.asp")>0){
			pageTitle = "Mercury | Contact Us"
		}else if(window.location.href.indexOf("whoswithus.asp")>0){
			pageTitle = "Mercury | Who's With Us"
		}
		document.title = pageTitle + " | " + showContent.title;
	}
}



function showPage(){
	var stageDiv = document.getElementById("body");
	if(getQueryVariable("view") != null){
	var page = getQueryVariable("view");
	//alert(page);
		if(page != ""){
			
			var showContent = document.getElementById(page);
			stageDiv.innerHTML = showContent.innerHTML;
			
			
			highlightLink(page);
			
			document.title = document.title + " | " + showContent.title;
		}
	}
	stageDiv.className = "bodyPadTop";
	

	if(getQueryVariable("section") != null){
		var section = document.getElementById(getQueryVariable("section"));
		section.scrollIntoView();
	}
	
}

function highlightLink (page){
	if(previousLink != null){
		previousLink.className = "";	
	}
	var theLink = document.getElementById("link_" + page);
	theLink.className = "subcurrent";
	previousLink = theLink;
}


function swapImg(theImg,imgName){
	var stageImg = document.getElementById(theImg);
	stageImg.src = "images/" + imgName;
	
}


function playMP3(file){

	var player=document.getElementById('player');
	//var mp3Ctrl = document.getElementById('MP3Control');
	if(player.src.indexOf("stop.asp") > -1){
		//mp3Ctrl.src = "images/form_button-stop.gif";
		player.src = "radiospots.asp";
		//mp3Ctrl.className = "stop";
	
	}else{
		//mp3Ctrl.src = "images/form_button-hear.gif";
		player.src = "stop.asp";
		//mp3Ctrl.className="play";
	}
}
