﻿/*
**************************************************************************************************************************
* MODIFICATION HISTORY
* CODE		DATE		GROUP	LAST MODIFIED BY	REMEDY CASE ID	DESCRIPTION
* ADD-001	03/26/2008	ACN		Mark Batac			HD04489641		Added GA Tag
***************************************************************************************************************************
*/
// Font EnLarger / Shrinker

//
// Config Variables
//
var baseSize = 11;
var maxSize = 14;
var minSize = 11;

//
// Call on Page Load            
//window.onload = function()
function toggleFont()
{ 
	//alert( "Entered OnLoad Event ====  "    );
    var cookieSize = readCookie("fontSize");
    
    
      //alert( " FINALLY Cookie size ==== " + cookieSize   );
   
    var newFontSize = (cookieSize != null)? cookieSize : baseSize ; 
    // alert( " Current Fontsize is " + newFontSize   );
    
    $("contentDrill").style.fontSize = newFontSize + "px"; 
    
                
/******START ADD-001******/
	//var displayHTML = "Adjust text size: <a id=\"small\" onclick=\"shrink(); return false;\" href=\"#\"><img src=\"\/hcp/new/images/minus.gif\" alt=\"-\" /></a>";
    //displayHTML += "<a id=\"large\" onclick=\"grow(); return false;\" href=\"#\"><img src=\"\/hcp/new/images/plus.gif\" alt=\"+\" /></a>";
	


	var displayHTML = "Adjust text size: <a id=\"small\" onclick=\"pageTracker._trackPageview(\'/hcp/Event/Text-Size-Down\'); shrink();\" href=\"#\"><img src=\"\/images/minus.gif\" alt=\"-\" /></a>"; 
	displayHTML += "<a id=\"large\" onclick=\"pageTracker._trackPageview(\'/hcp/Event/Text-Size-Up\'); grow();\" href=\"#\"><img src=\"\/images/plus.gif\" alt=\"+\" /></a>";





/******END ADD-001******/	
    
    Element.hide("fontChange");
    Element.update("fontChange",displayHTML);
    checkFontSize(newFontSize);
    new Effect.Appear("fontChange");
    
    	// alert( " Exiting OnLoad Event ==== "    );
}
            
function grow()
{
    var fontSize = $("contentDrill").style.fontSize.replace(/px/,"");
    fontSize++;
    if( checkFontSize(fontSize) ) $("contentDrill").style.fontSize = fontSize + "px";
}
function shrink()
{
    var fontSize = $("contentDrill").style.fontSize.replace(/px/,"");
    fontSize--;
    if( checkFontSize(fontSize) ) $("contentDrill").style.fontSize = fontSize + "px";
}
function normal()
{
    if( checkFontSize(baseSize) ) $("contentDrill").style.fontSize = baseSize + "px";
}
            
function checkFontSize(fontSize)
{
  //alert( " Inside checkFontSize FN, the fontsize being passed === " + fontSize  );
   
    var returnVal = true;

    if( fontSize > maxSize )
    {
        Element.hide("large");
        returnVal = false;
    }
    else if( fontSize == maxSize )
    {
        Element.hide("large");
        returnVal = true;
    }
    else
        Element.show("large");
            
    if( fontSize < minSize )
    {
        Element.hide("small");
        returnVal = false;
    }
    else if( fontSize == minSize )
    {
        Element.hide("small");
        returnVal = true;
    }
    else
        Element.show("small");
                
    if( returnVal )
        createCookie("fontSize",fontSize,10);
    
     //alert( " Exiting checkFontSize FN, the fontsize being returned === " + returnVal  );
 
    return returnVal;
}
            
function createCookie(name,value,days) 
{
    if (days) 
	{
	    var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
		
		var expires = "; expires="+date.toGMTString();
    }
	else 
	    var expires = "";
	            
    document.cookie = name + "=" + value + expires + "; path=/";
   
   //alert( " Exiting createCookie Function, with cookie === " + document.cookie + " === "  );
  
    
}
function readCookie(name) 
{
	
	//alert( " Inside Function with Cookie === " + document.cookie + " ----- " );
 
	
    var nameEQ = name + "=";
	  var ca = document.cookie.split(';');
	
	  
	
	for(var i=0;i < ca.length;i++) 
	{
		
		//alert( " ca @ " + i + " == "  + ca );
 
	    var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
		            
		if (c.indexOf(nameEQ) == 0) {
			
				//alert( " ca is == "  + ca );
				//alert( " nameEQ.length == " + nameEQ.length );
				//alert( " c.length == " + c.length );
				//alert( " value returned is == " + c.substring(nameEQ.length,c.length) );
			
			if ((c.substring(nameEQ.length,c.length)) < baseSize){
				return baseSize;
				}else{
		  	return c.substring(nameEQ.length,c.length);
			}
			
			}
    }
    return null;
}