    function findHomePage(homepagename) { 
        var pageName = "";  
        if(homepagename != "") {
            pagName = homepagename;           
        }
      return pagName;
    }    
    
    function GetWindowWith() {
    var myHeight = 0;
    var myWith = 0;   
    if( typeof( window.innerWidth ) == 'number' ){ 
        //Non-IE
        //myHeight = window.innerHeight;
        myWith = document.documentElement.clientWidth;
    }
    else {
        if ( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ){ 
            //IE 6+ in 'standards compliant mode'
           // myHeight = document.documentElement.clientHeight;
           myWith = document.documentElement.clientWidth;
        }
        else {
            if ( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) { 
                //IE 4 compatible
               // myHeight = document.body.clientHeight;
               myWith = document.body.clientWidth;
            }
        }
    }
    //return myHeight;     }
    return myWith;  }
    
 function SetStyleSheet(stemplateName) 
 { 
    var _clientWidth = GetWindowWith(); //the height of the lower edge of the browser window
    var i, a, main;      
    
    for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
    {             
        if( a.getAttribute("id") != ""
            && a.getAttribute("id") != null
            && a.getAttribute("id").indexOf("css") != -1 )
        {
            a.disabled = true;                                              
            if(_clientWidth > 950 )
            {
                if(stemplateName == "HomePage")
                {
                    if(a.getAttribute("id").indexOf("common1024") != -1)
                    {
                         a.disabled = false;                                                          
                    }
                    if(a.getAttribute("id").indexOf("home1024") != -1)
                    {
                        a.disabled = false;                                                          
                    }            
                }
                else
                {
                    if(a.getAttribute("id").indexOf("common1024") != -1
                        || a.getAttribute("title").indexOf("common1024") != -1)
                    {
                        a.disabled = false;
                    }
                }                                
            }                                    
            if(_clientWidth <= 950)
            {
                if(stemplateName == "HomePage")
                {
                    if(a.getAttribute("id").indexOf("home800") != -1)                        
                    {
                         a.disabled = false;
                         //alert(a.getAttribute("title") + ", " + a.getAttribute("title").indexOf("home800") + ", " + a.disabled);                                                                                   
                    }
                    if(a.getAttribute("id").indexOf("common800") != -1)                                         
                    {
                        a.disabled = false;                                            
                    } 
                }
                else
                {                    
                    var onlyid = false;
                    if(stemplateName != "StaffSearch"
                        && stemplateName != "CalendarForm")
                    {
                        if(a.getAttribute("title").indexOf("common800") != -1                                        
                            || a.getAttribute("id").indexOf("common800") != -1)                    
                        {
                           onlyid = true;
                           a.disabled = false;                     
                        } 
                    }
                    else
                    {
                        if(a.getAttribute("id").indexOf("common800") != -1
                            && !onlyid)
                        {
                            //alert(a.getAttribute("id") + ", " + a.getAttribute("title").indexOf("home800") + ", " + a.disabled);
                            a.disabled = false;
                        }
                    }
                }                                           
             }                                
        } //end title       
    } //for     
} 
window.onload = function() { SetStyleSheet(stemplateName); } 
window.onresize = function() { SetStyleSheet(stemplateName); }


function setActiveStyleSheet(Title) 
{
	var i, a, main;
	var _clientWidth = GetWindowWith();
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
	{
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) 
		{ 
			a.disabled = true;			
			if(a.getAttribute("title") == Title)
			{ 
			   a.disabled = false;		   			   		
			}				
		}
	}
}

function getActiveStyleSheet() 
{
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
	{
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
	}
	return "";
}

function getPreferredStyleSheet()
{
	var i, a;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++)
	{
		if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("rel").indexOf("alt") == -1 && a.getAttribute("title"))
		return a.getAttribute("title");
	}
	//if return null it will return an error: no object be found 
	//when loading the site or any page of the site at first time with a newly opened browser
	//so it must be 'return "";' 
	return "";
}

//return text disable value 03/26/08
//so it will keep selected font-size
function getActiveStyleSheet() 
{
	var i, a;
	var findtitletext = false;
	for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
	{		
		var agt=navigator.userAgent.toLowerCase();
        //var mac = (agt.indexOf("mac")!=-1);
		
		if(navigator.userAgent.indexOf('MSIE') != -1)		   		    	    
		{
		    if((navigator.userAgent.indexOf('Win') != -1)
                && navigator.userAgent.indexOf("Windows 2000") != -1)
            {
                findtitletext = false;
            }
            else
            {
                findtitletext = true;                
            }		    
	    }
	       
	    if(findtitletext)
	    {
	        //only return title with 'Small Text','Larger Text', and etc.
	        // to prevent returning common1027 or common800
	        if( !a.disabled 
	            && a.getAttribute("title").indexOf("Text") != -1)	            
            {                
               return a.getAttribute("title");
            }
	    }
	    else
	    {
	        if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled)
            {  
                return a.getAttribute("title");
            } 
	    }	   
	}//close foreach
	return "";
}

// create a session cookie
function createCookie(name,value,days) 
{
	expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) 
{
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) 
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return "";
}
/* original by CIT. Modified below to printCurrentPage()
function PrintThisPage() 
{
	if("" == 'print')
	{ 
		var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
			sOption+="scrollbars=yes,width=750,height=600,left=100,top=25"; 

		var sWinHTMLHeading = document.getElementById('ContentHeading').innerHTML;
		var sWinHTMLBody = document.getElementById('ContentBody').innerHTML; 
		   
		document.open(); 
		document.write('<html><link href=css/pfriendly.css rel=stylesheet><body>'); 
		document.write(sWinHTMLHeading);
		document.write('<br>');
		document.write(sWinHTMLBody);
		document.write('</body></html>'); 
		document.close();
	} 
}
*/
function printCurrentPage() 
{ 
	var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes"; 
	var sWinHTMLSendToPrinter = "<a href='javascript:window.print()'><img src='/nidcr2.nih.gov/Images/printer_icon.gif' alt='Send to Printer' width='16' height='13' border='0'></a>&nbsp;";
		sWinHTMLSendToPrinter += "<font class=fontSmall><a href='javascript:window.print()'>Send To Printer</a></font>";
		sWinHTMLSendToPrinter += "&nbsp;|&nbsp;<font class=fontSmall><a href='javascript:window.close()'>Close</a></font><br>";	
	var sWinHTMLHeading = document.getElementById('ContentHeading').innerHTML;	
	var sWinHTMLBody = document.getElementById('ContentBody').innerHTML; 	   
	var printCurrent = window.open("","",sOption); 
	
	printCurrent.document.write('<html><link href=\"/nidcr2.nih.gov/Styles/print.css\" rel=\"stylesheet\" type=\"text/css\" media=\"all\" /><body>'); 
	printCurrent.document.write(sWinHTMLSendToPrinter);
	if(sWinHTMLHeading == "")
	{
	    printCurrent.document.write('<p style=\"margin-top: 1em;\">');
	}
	else
	{	
	    printCurrent.document.write(sWinHTMLHeading);
	}
	printCurrent.document.write(sWinHTMLBody);
	printCurrent.document.write('</body></html>'); 
	printCurrent.document.close();
}


window.onload = function(e) 
{
	var cookie = readCookie("TextSizeSelection");
	var title = cookie ? cookie : getPreferredStyleSheet();
	setActiveStyleSheet(title);	
}

window.onunload = function(e) 
{
	var title = getActiveStyleSheet();
	createCookie("TextSizeSelection", title, 30);
}

var cookie = readCookie("TextSizeSelection");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);

function emailpage(curpostingname) {	
	var strEmailTo = "";
	var strEmailSubject	
	if(curpostingname != "") 
	{               
      for (var i = 0; i < curpostingname.length; i++) 
      {         
        if(curpostingname.charCodeAt(i) == 8216)
        {
            curpostingname = curpostingname.replace(curpostingname.charAt(i), "\'");	
            //return curpostingname;  //testing code that dilsplay return to browser          
        }
      } //close for                  
	  strEmailSubject = curpostingname;
	}
	else 
	{
		strEmailSubject = document.title;
	}
	var strEmailLink = document.location.href;
	strEmailBody = "Please see the following Web document...\n\n" + "Source: National Institute of Dental and Craniofacial Research (NIDCR)" + "\n\n" + "Title:      " + strEmailSubject + "\n\n" + "Link:      " + strEmailLink + "\n\n";
	var docMessage = "mailto:" + strEmailTo + "?subject=" + strEmailSubject + "&body=" + escape(strEmailBody);
	window.location = docMessage;
	window.focus();
}

function pageWidth() 
{
    return window.innerWidth != null? 
        window.innerWidth : document.documentElement 
        && document.documentElement.clientWidth ? 
        document.documentElement.clientWidth : 
        document.body != null ? document.body.clientWidth : null;
} 
        
function pageHeight() 
{
    return  window.innerHeight != null? 
    window.innerHeight : document.documentElement 
    && document.documentElement.clientHeight ?  
    document.documentElement.clientHeight : document.body != null? 
    document.body.clientHeight : null;} 
    
function posLeft() 
{
    return typeof window.pageXOffset != 'undefined' ? 
    window.pageXOffset :document.documentElement && 
    document.documentElement.scrollLeft ? 
    document.documentElement.scrollLeft : document.body.scrollLeft ? 
    document.body.scrollLeft : 0;} 
    
function posTop() 
{
    return typeof window.pageYOffset != 'undefined' ?  
    window.pageYOffset : document.documentElement && 
    document.documentElement.scrollTop ? 
    document.documentElement.scrollTop : document.body.scrollTop ? 
    document.body.scrollTop : 0;} 
    
function posRight() 
{
    return posLeft()+pageWidth();} 
    
function posBottom() 
{
    return posTop()+pageHeight();}
//To use this function just uncommend it out 08/07/07    
// clr=new Array('00','20','40','60','80','a0','c0','ff');
//for (i=0;i<8;i++) { 
//document.write("<table border=1 cellpadding=8>");
//for (j=0;j<8;j++) {
//document.write("<tr>");
//for (k=0;k<8;k++) {
//document.write('<td bgcolor="#'+clr[i]+clr[j]+clr[k]+'">');
//document.write('<tt><font color="#'+clr[7-i]+clr[7-j]+clr[7-k]+'"> ');
//document.write(clr[i]+clr[j]+clr[k]+' </font></tt></td>'); }
//document.write("</tr>"); }
//document.write("</table><br>"); }   
    
//    clr=new Array('00','20','40','60','80','a0','c0','ff');
//for (i=0;i<8;i++) { 
//document.write("<table border=1 cellpadding=8>");
//for (j=0;j<8;j++) {
//document.write("<tr>");
//for (k=0;k<8;k++) {
//document.write('<td bgcolor="#'+clr[i]+clr[j]+clr[k]+'">');
//document.write('<tt><font color="#'+clr[7-i]+clr[7-j]+clr[7-k]+'"> ');
//document.write(clr[i]+clr[j]+clr[k]+' </font></tt></td>'); }
//document.write("</tr>"); }
//document.write("</table><br>"); }



function browserright() {
if(navigator.appVersion.indexOf('Mac') != -1) {
   // It's a Macintosh
   document.write('Option+Click the link.');
   return;
   }
if(navigator.appVersion.indexOf('Win') != -1) {  
   // It's Windows   
   if(pageWidth() < 1003 && pageHeight() < 566)
   {
       document.write("Browser with " + pageWidth()
        + "<br /> Browser Height " + pageHeight() 
        + '<br />');
    }
   //document.write('Right click the link and select ');
   if(navigator.userAgent.indexOf('Firefox') != -1) {
      // It's Firefox
      document.write('"Save Link As..."');
      return;
      }
   if(navigator.userAgent.indexOf('Opera') != -1) {
      // It's Opera
      document.write('"Save target as..."');
      return;
      }
   if(navigator.userAgent.indexOf('Gecko') != -1) {
      // It's Netscape 6+
      document.write('"Save Target As..."');
      return;
      }
   if(navigator.userAgent.indexOf('IE') != -1) {
   if(pageWidth() < 0 && pageHeight() < 0)
   {
      // It's IE       
      //document.write('"Save Target As..."');
       document.write(document.documentElement.clientWidth);
       document.write(pageHeight());   
       return;                          
      }
      }
   }
  // Default 
  document.write(document.documentElement.clientWidth);
  document.write(pageHeight());  
//  document.write('Right click the link and select ');
//  document.write('"Save Target As...1"');       
}

function showDefinition(url){
	
	var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,scrollbars=yes";
	var showDefinition;
	if(url != "")
	{
		showDefinition = window.open(url, 'dd');
		//showDefinition = window.open(url,'null',sOption);
	}	
} 



