
function navOnState(pageID){
	navon = M_object('L1State_' + pageID)
	navon.src=navon.getAttribute("oversrc");
	navon.setAttribute("origsrc",navon.getAttribute("oversrc"));
}

function MS_swap(Mitem,Mtype){
	Mitem.src=Mitem.getAttribute(Mtype || "origsrc");
}

function MS(img_swap){
	img_swap.setAttribute("origsrc",img_swap.src);
	img_swap.setAttribute("onload","");
   	img_swap.oversrc_img = new Image();
  	img_swap.oversrc_img.src=img_swap.getAttribute("oversrc");
    img_swap.onmouseover = new Function("MS_swap(this,'oversrc');");
    img_swap.onmouseout = new Function("MS_swap(this);");
	img_swap.style.cursor = 'pointer';
}

/*ripped from prototype.js*/
function M_object(element) {
	if (arguments.length > 1) {
		for (var i = 0, elements = [], length = arguments.length; i < length; i++)
			elements.push(M_object(arguments[i]));
		return elements;
	}
	if (typeof element == 'string')
		element = document.getElementById(element);
	return element;
}

//Check for added variable to podium url
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];
		}
	} 
	return -100;
}

function addLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function') {
		window.onload = func;
	} else {
		window.onload = function() {
			if (oldonload) {
				oldonload();
			}
			func();
		}
	}
}

function insertFooterCode(){
	var footerContainer = document.createElement("div");
	footerContainer.innerHTML = M_object("podium_footer").innerHTML;
	document.body.appendChild(footerContainer);
}
function SwitchPage(){
	switch(pdGlobal.currentPages[0].type){
		case "application":
			
			if(pdGlobal.currentPages[0].id != 204){
				HideContentOnLoad();
			}else{
				HidePortalOnLoad();
			}
			//alert("app");
			//HideContentOnLoad();
						
		break;
		
		case "portal":
		HideContentOnLoad();
		break;
		
		case "content":
		HidePortalOnLoad();
		break;
		}
	}
function SetPageTitles(){
	var LevelOne = "";
	var LevelTwo = undefined;
	switch(pdGlobal.currentPages[0].type){
		case "application":
			$("#page-title").html(pdGlobal.currentPages[0].title);
			LevelOne =pdGlobal.currentPages[0].title
			break;
		case "portal":
			$("page-title").html(pdGlobal.currentPages[0].title);
			LevelOne =pdGlobal.currentPages[0].title
		break;
		case "content":
			if(pdGlobal.currentPageLevel >= 2){
				$("#page-title").html(pdGlobal.currentPages[1].title);
				LevelTwo = pdGlobal.currentPages[1].title
			}
			
			
		break;
	}
	//alert(LevelOne +" : "+LevelTwo);
	if(LevelTwo != undefined){
		fvars ={flashTxt:LevelTwo}
	} else {
		fvars ={flashTxt:LevelOne}
	}
	$('div#page-title').flash(
		{ 
			src: '/flash/pagetitles.swf',
			width: 545,
			height: 35,
			wmode:'transparent',
			flashvars: fvars
			},
					{ version: 9, update : false },
					function(htmlOptions) {
						htmlOptions.flashvars.txt = this.innerHTML;
						this.innerHTML = '<span>'+this.innerHTML+'</span>';
						var $alt = $(this.firstChild);
						$alt.addClass('alt');
						$(this)
							.addClass('flash-replaced')
							.prepend($.fn.flash.transform(htmlOptions));
				}
			);
	
}

function HidePortalOnLoad(){  //HideEnglishOnLoad
	document.write("<link rel='stylesheet' type='text/css' href='/hide-portal.css'/>")
}
function HideContentOnLoad(){  //HideSpanishOnLoad
	document.write("<link rel='stylesheet' type='text/css' href='/hide-content.css'/>")
}

