
/*

function chkXss() {
	var chkIndUrl = document.URL
	//alert(chkIndUrl);
	//check if url address contain < for XSS attempt (e.g <script>, <iframe>, <img>, etc...
	//doesn't work as soon as the browser see html reserved such as <script>,
	// the browser IE took over the function
	//work only if <dkdfjasldjf junk is enter on url address.
	//alert(chkIndUrl);
	if (chkIndUrl.indexOf('<script') != -1 || chkIndUrl.indexOf('%3C') != -1){
		window.location = "/index.htm";			
		//alert("script tag on url")
		//return false;		
	}
}

window.onload = chkXss; 
*/
//initialize dynamic iframe variable
var oIFrame = null;

//Creating IFrame dynamically

function createIFrame(name){
		//create the iframe
		var oIFrameElement = document.createElement("iframe");
		//attributes
		oIFrameElement.width=0;
		oIFrameElement.height=0;
		oIFrameElement.frameBorder=0;
		oIFrameElement.name = name;
		oIFrameElement.id = name;
		//add the iframe to the document structure
		document.body.appendChild(oIFrameElement);
		oIFrame = frames[name];
	
	
	
}


//use to show and hide any dropdown menu
function showmenu(elmnt)
{
	if (document.getElementById(elmnt).style.display == "block"){
		hidemenu(elmnt)
	}
	else{
	document.getElementById(elmnt).style.display="block"
	}
}
function hidemenu(elmnt)
{
     document.getElementById(elmnt).style.display="none"
}



//Used when the main page is load
//call all the necessary functions 
function firstLoad(){
	//call aToZ function to display A To Z for the left column
	aToZ();	
	
	

}//end of firstload function

//function to load Health NewsInfo
function HealthNewsInfo(a){
	
		//if frame hiddenHealth is not defined equal to true
		if (!frames["hiddenHealth"] == true){
			createIFrame("hiddenHealth");						
			//setTimeout use to wait for 5 seconds for it to process
			//setTimeout ("CurrNewsInfo()", 5000);
			//setInterval rerun for every 60 seconds
			//setInterval ("HealthNewsInfo()", 60000);				
		}	
				
		top.frames["hiddenHealth"].location = "/phcommon/public/media/media_p.cfm?option=2";
		if (a == 1){
		CurrNewsInfo('1');
		}
}	
function displayHealthNews(sHealth){
	var OutHealthNews = document.getElementById("OutHealthNews");
	OutHealthNews.innerHTML = sHealth;	
	
}


//function to load Current News and Alert news

function CurrNewsInfo(a){
	//if frame hidden current is not defined equal to true
	if (!frames["hiddenCurrent"] == true){
		//alert("current");
		createIFrame("hiddenCurrent");	
	}	
	top.frames["hiddenCurrent"].location = "/phcommon/public/media/media_p.cfm?option="+a;			
}	
function displayCurrNews(sText){
	var OutCurNews = document.getElementById("OutCurNews");
	OutCurNews.innerHTML = sText;	

}

//function to load Current News and Alert news

function MAdvisoryInfo(){
	//if frame hidden current is not defined equal to true
	if (!frames["hiddenMAdvisory"] == true){
		//alert("current");
		createIFrame("hiddenMAdvisory");	
	}	
	top.frames["hiddenMAdvisory"].location = "/phcommon/public/portlet/index.cfm";			
}	
function displayMAdvisory(sText){
	var MAdvisory = document.getElementById("MAdvisory");
	MAdvisory.innerHTML = sText;	

}




//use to dynamically set the global navigation level to on State 
function chgOnState(a){
	//the a paramter is the object that the color will be change to emphasis it is currently on the page
	var obj= document.getElementById(a);
	obj.style.color = "#c97962";
	obj.style.fontSize = "12px";	
}
//use to load the A - Z buttons 
function aToZ(){
	//6 alpha per line for it to looks good in IE and FireFox
	var cont = "";
	cont = cont + "<table align='center' class='atoz'><tr>";
	for (i=65;i<=90; i++){
		cont = cont + "<td class='atoz' align='center'>" + 
			"<input type='Submit' class='aTozButton' name='ALPHA' value='" + String.fromCharCode(i) +  "'></td>"
		if (i == 70 || i==76 || i ==82 || i == 88 ){
		cont = cont + "</tr><tr>";
		
		}
	}
	cont = cont + "<td colspan=4 class='atoz' align='center'><input type='Submit' class='aTozButton' name='ALPHA' value='ALL'></td>"
	cont = cont + "</tr></table>";	
	var divAtoZ = document.getElementById("divAtoZ");
		divAtoZ.innerHTML = cont;	
		
}//end of aToZ function

//use to load the A - Z buttons horizontally
function aToZHor(){
	//6 alpha per line for it to looks good in IE and FireFox
	var cont = "";
	cont = cont + "<table width='90%'><tr><td align=right><font color=white>A-Z Index</font></td>";
	for (i=65;i<=90; i++){
		cont = cont + "<td class='aTozH' align='center'>" + 
			"<input type='Submit' class='aTozH' name='ALPHA' value='" + String.fromCharCode(i) +  "'></td>"		
	}
	cont = cont + "<td class='aTozH' align='center'><input type='Submit' class='aTozH' name='ALPHA' value='ALL'></td>"
	cont = cont + "</tr></table>";	
	var divAtoZH = document.getElementById("divAtoZH");
		divAtoZH.innerHTML = cont;	
		
}//end of aToZ function

//use to load the A - Z buttons horizontally
function aToZHor2(){
	//6 alpha per line for it to looks good in IE and FireFox
	var cont = "";
	cont = cont + "<table width='90%'><tr><td align=right><font color=white>A-Z Index</font></td>";
	for (i=65;i<=90; i++){
		cont = cont + "<td class='aTozH2' align='center'>" + 
			"<input type='Submit' class='aTozH2' name='ALPHA' value='" + String.fromCharCode(i) +  "'></td>"		
	}
	cont = cont + "<td class='aTozH2' align='center'><input type='Submit' class='aTozH2' name='ALPHA' value='ALL'></td>"
	cont = cont + "</tr></table>";	
	var divAtoZH2 = document.getElementById("divAtoZH2");
		divAtoZH2.innerHTML = cont;	
		
}//end of aToZ function


//use to open portlet content - open and close
function portletOpenClose(a){
	indText= a + "1";;
	indView = document.getElementById(indText);
	indopen=document.getElementById(a);	
	if (indopen.style.display == "block"){
		indopen.style.display = "none"		
		indView.innerHTML = "Open"	
	}
	else{
		indopen.style.display = "block"	
		indView.innerHTML = "Close"	
	
	}
}//end of portletOpenClose function


//function use to render content for the center column
function getCenterContent(indpath){


	var oXmlHttp = createXMLHttp();
	//true = asynochronous
	oXmlHttp.open("get", indpath, true);
	oXmlHttp.onreadystatechange = function (){
		//alert(oXmlHttp.readyState);
		if (oXmlHttp.readyState == 4){
			if (oXmlHttp.status == 200){
				//alert("Data returned is :" + oXmlHttp.responseText);
				//alert(oXmlHttp.getAllResponseHeaders());
				var sData = oXmlHttp.responseText;
				var disContent = document.getElementById("disContent");
					disContent.innerHTML = sData;				
				//document.write(sData);
				//alert(sData);
			}
			else{
				var disContent = document.getElementById("disContent");
					disContent.innerHTML = 	"An error occured: " + 	oXmlHttp.statusText;	
				//alert("An error occurred:" + oXmlHttp.statusText);
				//document.write(oXmlHttp.responseText);
			}
			//alert(oXmlHttp.responseText);
			//alert ("Got response : all data has been received and the connection has been closed");
		}
	
	
	
	}
	
	/*
	if (oXmlHttp.status == 200){
		alert("Data return is : " + oXmlHttp.responseText);
	}
	else {
		alert("An error occurred: " + oXmlHttp.statusText);
	
	}*/
	oXmlHttp.send(null);
	
}	
	
	//alert(sData);
	
function createXMLHttp(){
	if (typeof XMLHttpRequest != "undefined"){
		//alert ("other browser XMLHTTP OBJECT");		
		return new XMLHttpRequest();
		
	}
	else if (window.ActiveXObject){
		//var oXmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		var aVersions = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHttp.5.0",
				"MSXML2.XMLHttp.4.0","MSXML2.XMLHttp.3.0",
				"MSXML2.XMLHttp", "Microsoft.XMLHTTP"
				];
		for (var i=0; i < aVersions.length; i++){
			try {
				//alert("Microsoft XMLHttp object");
				var oXmlHttp = new ActiveXObject(aVersions[i]);
				return oXmlHttp;
			} catch (oError){
				//Do Nothing
				document.write ("Your browser doesn't support XMLHTTP.");
				}
		
		
		
		}
	}
	throw new Error ("XMLHttp object could not be created.");
	//document.write ("Hello");

}

//google radio button get check

function lasite(){
	document.gosearch.cx[0].checked = true

}

function trsite(){	
	document.gosearch.cx[1].checked = true

}


//use to open and close sub section in the side navigation
function sideAction(a){
	indAction=document.getElementById(a);
	indImg = a + 'Img';
	//indImg = document.getElementById(a +'Img');
	
	if (indAction.style.display == "block"){
		indAction.style.display = "none"
		document.images[indImg].src="/images/2008/arrow.gif";
		
		
	}
	else{
		indAction.style.display = "block"	
		document.images[indImg].src="/images/2008/arrow_down.gif";
	
	}
}//end of sideAction function

function sideOnState(b){
	indState = document.getElementById(b);
	if (indState.style.textDecoration == "underline"){
		indState.style.textDecoration = "none";
	}
	else
		{
		indState.style.textDecoration = "underline";
		}

}
 
function sslAdmin(){
	var relocate = "no"
	var indURL = document.URL	
	//didn't find it
	if (indURL.indexOf('https:') == -1){
		indURL = (indURL.replace(/http:/i, "https:"))
		relocate = "yes"
	}
	//didn't have admin in domain
	if (indURL.indexOf('admin.') == -1){
		indURL = (indURL.replace(/publichealth.lacounty/i, "admin.publichealth.lacounty"))
		indURL = (indURL.replace(/lapublichealth.org/i, "admin.publichealth.lacounty.gov"))
		indURL = (indURL.replace(/ph.lacounty.gov/i, "admin.publichealth.lacounty.gov"))
		relocate = "yes"	
	}
	// find www in the domain
	if (indURL.indexOf('www.admin.') != -1){
		indURL = (indURL.replace(/www.admin./i, "admin."))
		relocate = "yes"	
	
	
	}
	if (relocate == "yes"){
		window.location = indURL;	
	}
	

}




 




