//***************************************************//
//         Text sizing version .9                    //
//***************************************************//

var sizesArray = new Array("96%", "97%", "98%", "99%", "100%", "101%", "102%", "103%", "104%")
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] + ";}")
		}
	}
	
}

function activeTab(obj,tabcontentid){	
	var tab;
	//alert(obj.nodeName + "\n" + tabcontentid + "\nok");
	obj = obj.parentNode;
	
	if(obj){					
		if (ie){
			tab = obj.parentNode.parentNode.parentNode.firstChild;
			visible = obj.parentNode.parentNode.parentNode.parentNode.lastChild.firstChild.firstChild;
			actived=getElementbyClass(obj.parentNode.parentNode.parentNode.parentNode,"actived");
			if(actived){
				actived.className = "inactive";
			}
		}
		else{
			tab = nextSibling(obj.parentNode.parentNode.parentNode.firstChild);			
			actived=getElementbyClass(obj.parentNode.parentNode.parentNode.parentNode,"actived");			
			if(actived){
				actived.className = "inactive";
			}
		}
		var i=0;
		while(tab){
			if(ie && tab.firstChild && tab.firstChild.firstChild && tab.firstChild.firstChild.className){
				tab.firstChild.firstChild.className = "";							
			}
			else if( (tmp = nextSibling(tab.firstChild)) && (tmp = nextSibling(tmp.firstChild)) && tmp.className){
				//alert(tmp.className);
				tmp.className = "";
				
			}
			tab = nextSibling(tab.nextSibling);
		}
		
		if(obj)
			obj.className="selected";		
		
		newcontent=document.getElementById(tabcontentid);		
		if(newcontent){
			newcontent.className="actived";
		}
			
			
	}	
}

function nextSibling(obj){
		var orgobj = obj;		
		while(obj && obj.nodeType != 1){
			obj = nextSibling(obj.nextSibling);
		}
		if(obj && obj.nodeType != 1)
			obj = null;
		return obj;
	}
	

function getElementbyClass(obj, class_name){
	var objs=null;
	var alltags=obj.getElementsByTagName("*");
	
	for (i=0; i<alltags.length; i++){			
		if (alltags[i].className==class_name){						
			objs=alltags[i];			
			break;
		}	
	}
	return objs;
}



function get_random(numbers, max_number)
{
		
    var ranNum = new Array (numbers);
    
    for (i=0; i < numbers; i++){
    	do{
    		ranNum[i] = Math.floor(Math.random()*max_number);
    	}while (isDuplicated(ranNum,i,ranNum[i]));
    }
    return ranNum;
}

function isDuplicated(ranNum, len, val){
	
	for(i=0; i < len; i++){
		if(ranNum[i] == val){
			return true;
		}
	}
	return false;
}
function genHTML (priors, ranNum)
{
	var genhtml="";
	
	for(i=0;i<ranNum.length;i++){
			genhtml += priors[ranNum[i]];
	}
	return genhtml;
}
function getPriorities(strid)
{
	
	var priorities = new Array (10);
	priorities[0] = "<p><a href='http://www.hhs.gov/everyamericaninsured/'>Every American Insured</a></p>";
	priorities[1] = "<p><a title='' href='http://www.hhs.gov/everyamericaninsured/schip/index.html'>Insurance for Children in Need</a></p>";
	priorities[2] = "<p><a title='' href='http://www.hhs.gov/valuedriven/'>Value-Driven Health Care</a></p>";
	priorities[3] = "<p><a title='' href='http://www.hhs.gov/healthit'>Information Technology</a></p>";
	priorities[4] = "<p><a title='' href='http://www.hhs.gov/myhealthcare'>Personalized Health Care</a></p>";
	priorities[5] = "<p><a href='http://www.globalhealth.gov/'>Health Diplomacy</a></p>";
	priorities[6] = "<p><a title='' href='http://www.healthierus.gov/'>Prevention</a></p>";
	priorities[7] = "<p><a title='' href='http://www.hhs.gov/louisianahealth'>Louisiana Health Care System</a></p>";
	priorities[8] = "<p><a title='' href='http://www.pandemicflu.gov'>Pandemic Preparedness</a></p>";
	priorities[9] = "<p><a href='http://www.hhs.gov/disasters/'>Emergency Response</a></p>";
	
	
  ranNum = get_random(5,priorities.length);
  
  var prior_obj = nextSibling(document.getElementById(strid).firstChild);  
  
  i=0;
  while (nextSibling(prior_obj.nextSibling)){  	
  	prior_obj.innerHTML = priorities[ranNum[i]];
  	prior_obj = nextSibling(prior_obj.nextSibling);
  	i++;
  	
  }
	
}

function show (oId){
	
	var obj = document.getElementById(oId);
	
	
	if (obj){	
		if(obj.style.display != "block")
			obj.style.display='block';
		else
			obj.style.display="none";
	}
}


 