/*
var browserName=navigator.appName;

function setCSSRoot(path) {
	document.write('<link rel="stylesheet" href="'+path+'/masterstyle.css" type="text/css" />');
}
*/


//***************************************************//
//         Text sizing version .9                    //
//***************************************************//

var sizesArray = new Array("96%", "97%", "98%", "99%", "100%", "101%", "102%", "103%", "104%");
//var sizesArray = new Array(".92em", ".94em", "1.02em", "1.04em", "1.06em", "1.08em", "1.10em", "1.12em", "1.14em");
var sizePointer;
var ruleCounter;
// ruleCounter is used for Mozilla due to the necessity to write the new CSS rule in the last position so that it is applied.


if (getCookie("sizePref") != "") {
	sizePointer = Number(getCookie("sizePref"))
	// now apply the font
	if (document.styleSheets[0].cssRules) {
		ruleCounter = document.styleSheets[0].cssRules.length
	// Mozilla
	document.styleSheets[0].insertRule("* {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
		//ruleCounter = ruleCounter + 1
	}
	else {
	//IE
	document.styleSheets[0].addRule("*", "{font-size: " + sizesArray[sizePointer] + ";}")
	}
}
else {
	sizePointer = 4;
}
var ie=false;
if (navigator.appName.indexOf("Microsoft") != -1){
	ie=true;
}
	


function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=")
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1 
    c_end=document.cookie.indexOf(";",c_start)
    if (c_end==-1) c_end=document.cookie.length
    return unescape(document.cookie.substring(c_start,c_end))
    } 
  }
return "";
}

function largerFont () {
	
	if (document.styleSheets[0].cssRules) {
	// Mozilla
		if (document.styleSheets[0].cssRules[0]) {
			if (sizePointer != 8) {
				ruleCounter = document.styleSheets[0].cssRules.length;
				sizePointer = sizePointer + 1;
				document.styleSheets[0].insertRule("* {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
				//document.write('<style>* {font-size: ' + sizesArray[sizePointer] + ';}</style>');
				document.cookie = 'sizePref='+ sizePointer + '; path=/; domain=.hhs.gov';
			}
		}	
	}
	
	else if (document.styleSheets[0].rules) {
	// IE
		if (sizePointer < 8) {
			sizePointer = sizePointer + 1;
			document.cookie = 'sizePref='+ sizePointer + '; path=/; domain=.hhs.gov';
			document.styleSheets[0].addRule("*", "{font-size: " + sizesArray[sizePointer] + ";}")
			}
		}		
	}

function smallerFont () {	
	if (document.styleSheets[0].cssRules) {
		
	// Mozilla
		if (document.styleSheets[0].cssRules[0]) {	
			if (sizePointer != 0) {
				sizePointer = sizePointer - 1;
				ruleCounter = document.styleSheets[0].cssRules.length;
				document.styleSheets[0].insertRule("* {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
				document.cookie = 'sizePref='+ sizePointer + '; path=/; domain=.hhs.gov';
			}
		}	
	}
	
	else if (document.styleSheets[0].rules) {
	// IE		
		if (sizePointer > 0) {
			sizePointer = sizePointer - 1;
			document.cookie = 'sizePref='+ sizePointer + '; path=/; domain=.hhs.gov';
			document.styleSheets[0].addRule("*", "{font-size: " + sizesArray[sizePointer] + ";}")
		}
	}
	
}

// Active seleted navigation tab
function navigation_actived(){
	
	var navItems = ["/", "/about/", "/careers/", "/grants/", "/children/", "/safety/", "/diseases/", "/policies/", "/resource/", "/disasters/"];
	var activedName="";
	var curURL = document.location.href;	
	if(curURL.substring(curURL.length-1) == "/"){
		curURL = curURL.substring(curURL.indexOf("//")+2,curURL.length-1);
	}
	else{
		curURL = curURL.substring(curURL.indexOf("//")+2,curURL.lastIndexOf("/"));
	}
	
	var indx = curURL.indexOf("/");	
	if( indx == -1){
		activedName = "/";
	}
	else{
		activedName = curURL.substring(indx)+"/";
		
	}
	
	var nav = document.getElementById("topnavigation");
	
	navtd=nav.getElementsByTagName("td");		
	
	
	if( activedName != "/" ){
		for(i=1; i < navtd.length;i++){		
			nav=navtd[i].getElementsByTagName("a");
			URLpath = nav[0].href.replace(/http?:\/\/.*?\//,"/");		
			URLpath = URLpath.replace(/\/index.htm.?/,"\/");
			tmp = activedName;
			//tmp = activedName.replace(/\//g,"\\/");
			//URLpath = URLpath.replace(/\//g,"\\/");
			//alert(URLpath + "\n" +  nav[i].href + "\n" + tmp);
			//alert(tmp + "\n" + URLpath);
			//excute = "isActived = /" + URLpath + "/.test(tmp)";
			//alert(URLpath + "\n" + tmp + "\n" + excute);
			//alert(tmp + "\n" + URLpath);
			//alert(excute + "\n" + tmp);
			//eval(excute);						
			if(tmp.indexOf(URLpath) != -1){			
				//alert("good" + "\n" + URLpath + "\n" + activedName);			
				if(i>=1){
					navtd[i-1].className = "nextactived";				
					navtd[i].className = "actived";							
				}
				else{
					navtd[0].className = "actived home";
				}
				break;
			}
			
		}
	}
	else{		
		navtd[0].className = "actived home";
	}
}


function description()
{
  var winW = 500, winH = 500;

	if (parseInt(navigator.appVersion)>3) {
	 if (navigator.appName=="Netscape") {
	  winW = window.innerWidth;
	  winH = window.innerHeight;
	  //winH = document.body.clientHeight;
	  
	 }
	 if (navigator.appName.indexOf("Microsoft")!=-1) {
	  winW = document.body.offsetWidth;
	  winH = document.body.offsetHeight;
	  //winH = document.body.clientHeight;	  
	  
	 }
	}
	
	var pWinH = 400, pWinW = 400, url;	
	
	var altText = "";

	if(description.arguments.length == 1){
		url = description.arguments[0];
	}
	else if (description.arguments.length == 4){
		url = description.arguments[0];
		pWinW =description.arguments[1];
		pWinH = description.arguments[2]+60;
		displaytitle = description.arguments[3]
	}
	else if (description.arguments.length == 5){
		url = description.arguments[0];
		pWinW =description.arguments[1];
		pWinH = description.arguments[2]+60;
		displaytitle = description.arguments[3];
		altText = description.arguments[4];
	}
  var disp_setting="dependent=yes,toolbar=no,location=no,directories=no,status=no,statusbar=no,menubar=no,scrollbars=no,resizable=yes";
  	disp_setting += ",height=" + pWinH;
  	disp_setting += ",width=" + pWinW;
  	disp_setting += ",left=" + ((winW - pWinW) / 2);
  	disp_setting += ",top=" + ((winH - pWinH) / 2);  	
 
 	
  	
  var desc=window.open('about:blank',"winp",disp_setting); 
  var htmlHead="<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'><html lang='en'><head><title>"+displaytitle+"</title><META http-equiv='Content-Type' content='text/html; charset=utf-8'>"
	htmlHead = htmlHead + "<meta http-equiv='Keywords' content='hhs, health, human, services, health and human services, secretary, surgeon general, hipaa, hippa, civil rights, bioterror, terrorism, smallpox, anthrax, sars, chemical, biological, social, social services, disease, families, children, substances, abuse, aging, diabetes, aids, food, drug, drugs, administration, safety, wellness, disaster, emergency, grants, funding, policy, policies, regulate, regulation, regulations, care, healthcare, privacy, medical, doctor, medicine, test, treatment, welfare, mental'>"
	htmlHead =htmlHead +"</head><body style='margin: 0px 5px 0px 5px;'>" 		
  	var body="<table border=0 cellpadding=0 cellspacing=0 summary='This table is used to format page content' width='100%' height='100%'><tr><td valign='top'><center>"
  	body = body + "<img src='" + url + "'  alt='" + altText + "'></center><p>" +displaytitle+"</p>"
  	body = body + "</td></tr><tr><td valign='bottom'><p align='right' style='padding-right:5%;padding-bottom:10px;'><INPUT type='button' value='Cerrar' OnClick='window.close()'> </p></td></tr></table>"
  	var htmlfoot ="</body></html>"
 
  desc.document.write(htmlHead)
 desc.document.write(body)
  desc.document.write(htmlfoot)
   
   desc.focus();
}


function windowHeight() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement &&
      ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  
  return myHeight;
}


// Validation object for the 2009 Region 10 Annual HHS Tribal Consultation Registration
consulation = {
			whitespace:" \t\n\r",
			validate: function()
	    {    		    	
	    	
	  		if(consulation.isEmpty(document.registerform.first_name.value))
	  		{
	  			alert("Error: se requiere el nombre .");
	  			document.registerform.first_name.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.last_name.value))
	  		{
	  			alert("Error: se requiere el apellido.");
	  			document.registerform.last_name.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.organization.value))
	  		{
	  			alert("Error: se requiere la Organizaci\363n/Afiliaci\363n.");
	  			document.registerform.organization.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.address.value))
	  		{
	  			alert("Error: se requiere la Direcci\363n.");
	  			document.registerform.address.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.city.value))
	  		{
	  			alert("Error: se requiere la ciudad.");
	  			document.registerform.city.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.state.value))
	  		{
	  			alert("Error: se requiere el Estado.");
	  			document.registerform.state.focus();
	  			return false;
	  		}	  		
	  		if(consulation.isEmpty(document.registerform.zip_code.value))
	  		{
	  			alert("Error: se requiere el c\363digo postal.");
	  			document.registerform.zip_code.focus();
	  			return false;
	  		}
	  		
	  		if(consulation.isEmpty(document.registerform.daytime_phone.value))
	  		{
	  			alert("Error: se requiere el n\372mero de tel\351fono diurno");
	  			document.registerform.daytime_phone.focus();
	  			return false;
	  		}	  		
	  		if(!consulation.isEmail(document.registerform.email_address))
	  		{   			
	  			return false;
	  		}
	  		//if (document.registerform.tribal_aff.value.length == 0)		  		
	  		if(consulation.isEmpty(document.registerform.tribal_aff.value))			
	  		{
	  			alert("Error: se requiere la afiliaci\363n tribal." );
	  			document.registerform.tribal_aff.focus();	  			
	  			return false;
	  		}	  		  		
	  		return true;
	    },
    	isEmpty:function(s)
	    {    	
	    	var i;    	
	    	if((s == null) || (s.length ==0)){    		
	    		return true;
	    	}
	    	for (i=0; i < s.length; i++)
	    	{
	    		var c = s.charAt(i);
	    		if(consulation.whitespace.indexOf(c) == -1)
	    			return false;
	    	}
	    	return true;    
	    },    
    	isEmail: function(field)
	    {
	    	var s = field.value;
	    	if (consulation.isEmpty(s))
	    	{
	    		alert("La direcci\363n de correo electr\363nico no puede estar vac\355a.");
	    		field.focus();
	    		return false;
	    	}
	    	if( /[^@]+@([\w|-]+\.)+[\w|-]+/.test(s) ){
	    		return true;
	    	}
	    	alert("\241El formato de la direcci\363n de correo electr\363nico no es v\341lido!");
	    	field.focus();
	    	return false;
	    }
};

// Validation function for Submit a question for the CHIP Webcast

var CHIPWebcast = {
	defaultText: "Ingrese sus preguntas aqu\355.",	
	isBlank: function(obj, message){
		if (obj.value == ''){
			alert(message);
			obj.focus();
			return false;
		}
		return true;
	},
	isEmail: function(obj, message){
		if(!( /[^@]+@[^@]+\.[^@]+/.test(obj.value))){
			alert(message);
			obj.focus();
			return false;
		}
		return true;		
	},
	
	textAreaOnClick: function(obj){		
		if(obj.value == CHIPWebcast.defaultText){
			obj.value="";
		}
	},
	
	validate: function (objForm){
		if ( (!CHIPWebcast.isBlank(objForm._name, 'Se requiere el nombre.')) || (!CHIPWebcast.isEmail(objForm.email, 'Se necesita una direcci\363n de correo electr\363nico v\341lida.')) 	){			
			return false;
		}		
		if (objForm.question.value == "" || objForm.question.value == CHIPWebcast.defaultText){
			alert("Por favor ingrese su pregunta en la casilla correspondiente.");
			objForm.question.focus();
			return false;
		}
		return true;
	}  	
};


/***********************************************************************************************************
CNAME 
************************************************************************************************************/

function cnameLink()
{
	
	var baseURL;
	baseURL="http://eshhs.convertlanguage.com/enes";
	var curURL = location.href;
	
	
	curURL=curURL.substring(curURL.indexOf("/",8));
	if(curURL.substring(curURL.length-1) == "/")
		curURL+="index.html";	
	linkURL = baseURL + curURL;			
	//alert(linkURL);
	document.write("<p><a href='" + linkURL + "' onclick='linkClick();'>In English</a></p>");
}

function linkClick(){	
	oh=new Array();
	tsd=new Array();
	tsh='eshhs.convertlanguage.com';
	oh[0]='www.globalhealth.gov';
	tsd[0]='/enes/dglobalhealth/';
	oh[1]='www.hhs.gov';
	tsd[1]='/enes/';
	idx=location.href.indexOf(tsh);	
	if(idx==-1){
		for (i=0;i<oh.length;i++){
			idx=location.href.indexOf(oh[i]);
			if(idx>-1) break;
		}
		idx=idx+oh[i].length;
		hname=tsh+tsd[i];
	}
	else{
		for (i=0;i<tsd.length;i++){
			idx=location.href.indexOf(tsd[i]);
			if(idx>-1) break;
		}
		idx=idx+tsd[i].length;
		hname=oh[i];
	}
	
	path=location.href.substring(idx);
	hend=hname.charAt(hname.length-1);
	pstart=path.charAt(0);
	if(hend=='/' && pstart=='/')
		path=path.substring(path.indexOf('/')+1);
	if(hend!='/' && pstart!='/')
		path='/'+path;
	this.href=location.protocol+'//'+hname+path;
	return true;
}

/***********************************************************************************************************
END CNAME 
************************************************************************************************************/

/***********************************************************************************************************
Used to provide radio buttons under hhs search form in header
************************************************************************************************************/
function HHSsearch_options()
{	
	if (!document.HHS.site[0].checked){								
		//document.HHS.getfields.value = null;	
		document.HHS.client.value = document.HHS.proxystylesheet.value = "HHS";    		
	}
	else{		
		//document.HHS.getfields.value = "*";
		//alert(document.HHS.client.value + "\n" + document.HHS.proxystylesheet.value);
		document.HHS.client.value = "HHS";
		document.HHS.proxystylesheet.value = "HHS";
		
	}
}

function NVPOsearch_options()
{		
	
	if (!document.HHS.site[0].checked){								
		//document.HHS.getfields.value = null;	
		alert('ok');
		document.HHS.client.value = document.HHS.proxystylesheet.value = "HHS";    		
		
	}
	else{		
		//document.HHS.getfields.value = "*";
		//alert(document.HHS.client.value + "\n" + document.HHS.proxystylesheet.value);
		document.HHS.client.value = "nvpo";
		document.HHS.proxystylesheet.value = "nvpo";
		
	}
}

function OHRPsearch_options()
{
	if (!document.HHS.site[0].checked){			
		//document.HHS.getfields.value = null;	
		document.HHS.client.value = document.HHS.proxystylesheet.value = "HHS";    		
		
	}
	else{				
		//document.HHS.getfields.value = "*";
		document.HHS.client.value = "OHRP";
		document.HHS.proxystylesheet.value = "OHRP";
		
	}
}



