/*
var browserName=navigator.appName;

function setCSSRoot(path) {
	document.write('<link rel="stylesheet" href="'+path+'/masterstyle.css" type="text/css" />');
}
*/

function gocategory()
{
	box = document.getElementById("category");	
	destination = box.options[box.selectedIndex].value;
	if (destination) location.href = destination;
}

  function WWTCvalidate()
  {
  first = document.regform.first.value
  last = document.regform.last.value
  div = document.regform.div.value
  email = document.regform.email.value
  phone = document.regform.phone.value
  
  error = '';
  if(first.length == 0)
    error += '\nPlease enter the First Name.';
  
  if(last.length == 0)
    error += '\nPlease enter the Last Name.';

  if(div.length == 0)
    error += '\nPlease enter the Op-Div/Staff-Div.';

  if(email.length == 0)
    error += '\nPlease enter the Email Address.';
  else if (email.length > 0 && (email.indexOf('@')==-1 || email.indexOf('.')==-1 || (email.charAt(email.length - 4)) != '.'))
     error += '\nPlease enter a valid email address.';

  if(phone.length == 0)
    error += '\nPlease enter the Phone Number.';

  if (error.length >0)
    alert('This form has errors and cannot be submitted:' + error);
 else
   document.regform.submit();
  }
  
function ismaxlength(obj){
var mlength=obj.getAttribute? parseInt(obj.getAttribute("maxlength")) : ""
if (obj.getAttribute && obj.value.length>mlength)
obj.value=obj.value.substring(0,mlength)
}  


function workgroupeval_validate()
{	
	var msg="The evaluation form has not been completed.\nPlease make sure you answered all the questions.";
		
	if(!workgroupeval_ischecked("organized")){		
		alert(msg);		
		return false;		
	}
		
	
	if(!workgroupeval_ischecked("job")){
		alert(msg);
		return false;
	}
	if(!workgroupeval_ischecked("peers")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("keynote")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("standards")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("avatars")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("big")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("laws")){
		alert(msg);
		return false;
	}
	
	
	if(!workgroupeval_ischecked("comp508")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("portal")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("translation")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("aids")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("corps")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("homepage")){
		alert(msg);
		return false;
	}
	
	if(!workgroupeval_ischecked("conference")){
		alert(msg);
		return false;
	}
	
	
	return true;
}

function workgroupeval_ischecked(id)
{
	var check=false;
	var cmd = "var obj = evaluate." + id;		
	eval(cmd);			
	for (var i=obj.length-1; i > -1; i--) {								
		if (obj[i].checked){
			check=true;					
			break;
		}			
	}		
	return check;
}

function FAQsearch_options()
{		
	if (!document.search.site[0].checked){						
		document.search.getfields.value = null;	
		document.search.client.value = document.search.proxystylesheet.value = "HHS";    		
	}
	else{
		document.search.getfields.value = "*";
		document.search.client.value = "HHS_FAQ";
		document.search.proxystylesheet.value = "HHS_FAQ";
	}
}


function HIPAA_FAQsearch_options()
{		
	if (!document.search.site[0].checked){						
		document.search.getfields.value = null;	
		document.search.client.value = document.search.proxystylesheet.value = "HHS";    		
	}
	else{
		document.search.getfields.value = "*";
		document.search.client.value = "HIPAA_FAQ";
		document.search.proxystylesheet.value = "HIPAA_FAQ";
	}
}

//***************************************************//
//         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 buildfields(form , dummyform) //Used by www.hhs.gov/grantsforecasting Google Advanced Search page.
{

  //Do not submit the form if all search fields are blank!
  if (form.q.value == "" && (dummyform.keywordsselect.selectedIndex == 0 ||dummyform.keywordsselect.selectedIndex == -1) && (dummyform.dateselect.selectedIndex == 0 || dummyform.dateselect.selectedIndex == -1) && (dummyform.opdivselect.selectedIndex == 0 || dummyform.opdivselect.selectedIndex == -1))
  {alert('The search form is blank.  Please enter search text or select at least one keyword, agency or posting month.');}

  else

  {
  var requiredfields = "";

  for (i=1; i<dummyform.opdivselect.options.length; i++) {
    if (dummyform.opdivselect.options[i].selected) {
      if (requiredfields.length != 0) {requiredfields = requiredfields + "|"; }
      requiredfields = requiredfields + 'DC%2Ecreator:' + dummyform.opdivselect.options[i].value;
    }
  }

  form.requiredfields.value = requiredfields;

  var partialfields = "";   

  if (dummyform.keywordsselect.selectedIndex != -1 && dummyform.keywordsselect.selectedIndex != 0)
     { partialfields = "keywords:" + dummyform.keywordsselect.value;}

  var datefound = 0;   

  for (i=1; i<dummyform.dateselect.options.length; i++) {
    if (dummyform.dateselect.options[i].selected) {
	if ( datefound == 0  && partialfields.length != 0) {partialfields = partialfields + "."; }
      else if ( datefound == 1  ) {partialfields = partialfields + "|"; }
      partialfields = partialfields + 'keywords:' + dummyform.dateselect.options[i].value;
      datefound = 1;
   }
  }

  form.partialfields.value = partialfields;

  form.submit();
  }
}



function isBlank(obj, message){
	if (obj.value == ''){
		alert(message);
		obj.focus();
		return false;
	}
	return true;
}

function isEmail(obj, message){
	if(!( /[^@]+@[^@]+\.[^@]+/.test(obj.value))){
		alert(message);
		obj.focus();
		return false;
	}
	return true;
		
}
  
function fbci_validate(objForm){	
	if ( (!isBlank(objForm.Organization, 'Name of organization is required.')) || (!isBlank(objForm.Grant, 'Name of grant is required.')) ||
		   (!isBlank(objForm.Year, 'Year grant was awarded is required.')) || (!isBlank(objForm.agency, 'Agency that awarded the grant is required.')) || 
		   (!isBlank(objForm.City, 'City is required.')) ||
		   (!isBlank(objForm.State, 'State is required')) || (!isBlank(objForm.Zip, 'Zip code is reqired')) ||
		   (!isBlank(objForm.PointContact, 'Organization\'s point of contact is required')) || (!isBlank(objForm.PrimaryTelephone, 'Business telephone number is required.')) ||
			 (!isBlank(objForm.PointContactEmail, 'Email is required.')) || 
			 (!isEmail(objForm.PointContactEmail, 'A valid email is required.'))
	){
		return false;
	}	
	

	return true;
}  

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='Close' 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;
}

/***********************************************************************************************************
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;			
	document.write("<p><a href='" + linkURL + "' onclick='linkClick();'>En espa&ntilde;ol</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 
************************************************************************************************************/
