


//***************************************************//
//         Text sizing version .9                    //
//***************************************************//

var sizesArray = new Array("60%", "70%", "80%", "90%", "100%", "110%", "120%", "130%", "140%");
//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("#navcolbg {font-size: " + sizesArray[sizePointer] + ";}", ruleCounter)
		//ruleCounter = ruleCounter + 1
	}
	else {
	//IE
	document.styleSheets[0].addRule("#navcolbg", "{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("#navcolbg {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("#navcolbg", "{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("#navcolbg {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("#navcolbg", "{font-size: " + sizesArray[sizePointer] + ";}")
		}
	}
	
}

function convertor()
{
 tsvr='//espanol.pandemicflu.gov/pandemicflu/enes/24/_';
 tsvra='/24/_';
 intsvr=(location.href.indexOf(tsvr)!=-1);
 intsvra=(location.href.indexOf(tsvra)!=-1);
 sep=(intsvra)?'/_':'//';
 orgloc=location.href.substring(location.href.indexOf(sep)+2);
 idx=orgloc.indexOf('/');
 if(idx==-1) idx=orgloc.indexOf('?');
 if(idx==-1){
  hname=orgloc;orgloc='';
 }else{
  hname=orgloc.substring(0,idx);orgloc=orgloc.substring(idx);
 }
 if(intsvr){
  hname=hname.replace(/__/,':');hname=hname.replace(/_/g,'.');
  tsvr='//';
 }else if(!intsvra){
  hname=hname.replace(/:/,'__');hname=hname.replace(/\./g,'_');
 }
 if (orgloc.indexOf('http://espanol.hhs.gov/enes/dstopmedicarefraud/jscripts/chinese.html')!=-1 || orgloc.indexOf('http://espanol.hhs.gov/enes/dstopmedicarefraud/jscripts/vietnamese.html')!=-1)
  orgloc='';
 location.href=location.protocol+tsvr+hname+orgloc;
 return false;
}


var maxpage = 0;
var curpage = 0;

$(document).ready(function () {
	
		
	//billboardTimer();
	
	$("#bselector .blist").addClass("fixfloat");
	$("#bselector .blist").removeClass("fixfloat");
	
	/*
	$("#bselector .blist").hover(
		function(){
			$(this).addClass("mptext_js:dscrollover");					
		},
		function(){
			$(this).removeClass("mptext_js:dscrollover");
		});
	*/
	$("#bselector .blist").click(
		function(){
			active($(this));			
			//alert('ok');
	});
	/*
	$("#bselector .blist .btitle a").click(
		function(){			
			alert('ok');						
			active($(this).parents(".blist").get(0));			
	});
	*/
	function nextSlide(){			
		var doNext = true;
		$("#bselector .blist").each(
			function(i){
				if(doNext){							
					if($(this).hasClass("bbactived")){						
						if( i >= $("#bselector .blist").size() - 1){									
							$("#bselector .blist:eq(0)").addClass("bbactived");							
							active( $("#bselector .blist:eq(0)") );
							doNext = false;
						}
						else{
							var indx = i + 1;							
							active($('#bselector .blist').eq(indx));
							doNext = false;
						}						
					}
				}				
		});
	}
	
	function active(obj){
		$("#bselector .blist").removeClass("bbactived");	
		obj.addClass("bbactived");						
	}
	
	function billboardTimer(){						
		$("#bselector .bbactived").everyTime(10000, "nextTimer", 
			function() {	  	
				nextSlide();  	
	 	});
	}
	
	// News
	
	$(".news .newsbody .blurb").each(
		function(i){	
			if(i > 0)		
				$(this).hide();				
	});
	
	$(".autoindex .news .newsbody .blurb:eq(0)").hide();
	
	
	maxpage = $(".autoindex .autopage").size();
	curpage = 0;
	
	updateAutoNav();
	/*
	var navstr="<p>";
	
	if(maxpage >= 2){		
		navstr += "<a href='javascript:previousPage()' id='previous'>Previous</a> ";
		for(n=1; n <= maxpage;n++){
			navstr += "<a ";			
			if(curpage == n-1){
				navstr += "id='pageactived' ";
			}
			navstr += "href='javascript:activePage(" + n + ")'>" + n + "</a> ";
		}
		navstr += "<a href='javascript:nextPage()' id='next'>Next</a></p>";		
	}	
	$("#autoindexpage").html(navstr);
	*/
	
	
	
	$(".autoindex .autopage").each(
		function(i){
			if(curpage != i){
				$(this).toggle();
			}
		});
	
	$(".news .newsbody a").click( function (){		
		var obj = $(this).parents(".newsbody").get(0);
		//$(obj).addClass("expanded");
		$(obj).children(".blurb").toggle();
	});
	
	/*
	$(".news .expanded a").click( function (){				
		var obj = $(this).parents(".newsbody").get(0);
		$(obj).removeClass("expanded");
		
	});
	*/
			
});

function nextPage(){		
	if(curpage < maxpage-1){			
		$(".autoindex .autopage").eq(curpage).toggle();
		$(".autoindex .autopage").eq(++curpage).toggle();			
		updateAutoNav()
	}
}

function previousPage(){		
	if(curpage > 0){			
		$(".autoindex .autopage").eq(curpage).toggle();
		$(".autoindex .autopage").eq(--curpage).toggle();			
		//$(".autoindex .autopage").eq(curpage).children(".news .newsbody .blurb:eq(1)").toggle();
		updateAutoNav()
	}
}

function activePage(n){	
	$(".autoindex .autopage").eq(curpage).toggle();
	curpage = n-1;
	$(".autoindex .autopage").eq(curpage).toggle();	
	updateAutoNav()					
}


function updateAutoNav(){
	var navstr="<p>";	
	if(maxpage >= 2){		
		navstr += "<a href='javascript:previousPage()' id='previous'>Anterior</a> ";
		for(n=1; n <= maxpage;n++){
			navstr += "<a ";			
			if(curpage == n-1){
				navstr += "id='pageactived' ";
			}
			navstr += "href='javascript:activePage(" + n + ")'>" + n + "</a> ";
		}
		navstr += "<a href='javascript:nextPage()' id='next'>Pr\363xima p\341gina</a></p>";		
	}	
	$("#autoindexpage").html(navstr);

}


// Active seleted navigation tab
function navigation_actived(){
	
//	var navItems = ["/", "/about/", "/careers/", "/grants/", "/children/", "/safety/", "/diseases/", "/policies/", "/resource/", "/disasters/"];
	var navItems = ["/", "/aboutfraud", "/protectyourself", "/heatsuccess", "/innews/"];
	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 != "/enes/" ){
		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";
	}
}


