var $j = jQuery.noConflict();
var size=1;

$j(document).ready(function() {

$j('div#text_size').html('<ul><li><a id="size_up" href="#">A+</a></li><li><a id="size_down" href="#">A-</a></li></ul>');          /* adds Text size menu */

readTextSize();

$j("a#size_down").click(function() { 

    if (size==1)
    {
	$j(this).addClass("current");
	size=0;
	resizeTxt('small');
    }
    
    if (size==2)
    {
	size=1;
	resizeTxt('medium');
    } 
}); 


$j("a#size_up").click(function() { 

    if (size==1)
    {
	$j(this).addClass("current");
	size=2;
	resizeTxt('large');
    }
    
    if (size==0)
    {
	size=1;
	resizeTxt('medium');
    } 
}); 


});




/* *************************** FUNCTIONS ******************************************* */


/* resizing function */

function resizeTxt(id) {            
    if(id=='small') { small_size();  setTextSize("small")}

    if(id=='medium') { medium_size();  setTextSize("medium")}

    if(id=='large') { large_size();  setTextSize("large")}
    };

/* this 3 functions changes letter colors and changes body font size */

function small_size(){
   $j('body').css('font-size','x-small'); 
 };


function medium_size(){
   $j('body').css('font-size','small'); 
 };


function large_size(){   
   $j('body').css('font-size','medium');
 };


/* ************************************* Cookies text size scripts ******************** */
/* saveCookie */

 function saveCookie(name,value,days) {
 	 if (days) {
		 var date = new Date();
		 date.setTime(date.getTime()+(days*24*60*60*1000))
		 var expires = "; expires="+date.toGMTString()
	 }
	 else expires = ""
	 document.cookie = name+"="+value+expires+"; path=/"
 }

/* readCookie */

 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 null
 }

/* deleteCookie */

 function deleteCookie(name) {
	 saveCookie(name,"",-1)
 }


/* ********** Text size stuff ******* */

/* saving text size to cookie */
 function setTextSize(TextID) {
     saveCookie("TextSize", TextID, "10");
 };


/* reading text size form cookie */
  function readTextSize() {
     var CookieTextSize = readCookie("TextSize");
     

     if (CookieTextSize == 'small')  { resizeTxt('small'); size=0; } 

     if (CookieTextSize == 'medium')  { resizeTxt('medium'); size=1; }

     if (CookieTextSize == 'large')   { resizeTxt('large'); size=2; }

  };

