function changeStylesheet(activeTitle) {
  switch (activeTitle) {
    case 'medium' : 
    
      setActiveStyleSheet('medium');
      createCookie('style', 'medium', 1);

      var obj = document.getElementById('imgMedium');
      if(obj != null)
      {
        if(obj.src.indexOf("font_medium_active") < 0){ obj.src = obj.src.replace("font_medium","font_medium_active"); }        
      }
      obj = document.getElementById("imgSmall");
      if(obj != null) { obj.src = obj.src.replace("font_small_active","font_small"); }
      
      obj = document.getElementById("imgLarge");
      if(obj != null) { obj.src = obj.src.replace("font_large_active","font_large");}

      break;         

    case 'large' :
    
      setActiveStyleSheet('large');
      createCookie('style', 'large', 1);

      var obj = document.getElementById('imgLarge');
      if(obj != null)
      {
        if(obj.src.indexOf("font_large_active") < 0){ obj.src = obj.src.replace("font_large","font_large_active"); }        
      }
      obj = document.getElementById("imgMedium");
      if(obj != null) { obj.src = obj.src.replace("font_medium_active","font_medium"); }
      
      obj = document.getElementById("imgSmall");
      if(obj != null) { obj.src = obj.src.replace("font_small_active","font_small");}

      break;
      
    default :
    
      setActiveStyleSheet('small');
      createCookie('style', 'small', 1);
    
      var obj = document.getElementById('imgSmall');
      if(obj != null)
      {
        if(obj.src.indexOf("font_small_active") < 0){ obj.src = obj.src.replace("font_small","font_small_active"); }        
      }
      obj = document.getElementById("imgMedium");
      if(obj != null) { obj.src = obj.src.replace("font_medium_active","font_medium"); }
      
      obj = document.getElementById("imgLarge");
      if(obj != null) { obj.src = obj.src.replace("font_large_active","font_large");}

      break;
  }
}

//Set Stylesheet - by finding style with specified title and enable it
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) 
    {
      var strTitle = a.getAttribute("title");
      if(strTitle == "large" || strTitle == "medium" || strTitle == "small")
      {
        a.disabled = true;
      }
      if(a.getAttribute("title") == title)
      {
          a.disabled = false;
      }
    }
  }
}

//Get Stylesheet
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 null;
}

function getPreferredStyleSheet() {
  return ('small');
}

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 expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function removeCookie(name)
{
    var date = new Date();
    date.setTime(date.getTime() + (4 * 24 * 1000 * 60 * 60 * -1));
    var expires = "; expires=" + date.toGMTString();
    
    document.cookie = name + "=false" + 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 null;
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
this.setActiveStyleSheet(title);

var cookieHC = readCookie("high_contrast");
var blnShow = false;

if(cookieHC != null)
{
    switchToHighContrast(0);
}

/**************************/

// This function toggle the high contrast stylesheet and the regular on
function switchToHighContrast(intSiteId)
{
    if(intSiteId > 0 && cookieHC != null)
    {
        removeCookie("high_contrast");
    }
    
    // Disable the regular stylesheet and enable 
    // the high contrast stylesheet for the selected site
        var i, a, main;
        for(i=0; (a = document.getElementsByTagName("link")[i]); i++) 
        {
            //find the regular style sheet and disable it
            //Enable the high contrast style sheet           
            if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {              

                if(a.getAttribute("title") == "high_contrast")
                {
                    if(cookieHC != null && a.disabled == true || a.disabled == true)
                    {
                        a.disabled = false;
                        createCookie('high_contrast', 'true', 1);
                    }
                    else
                    {
                        a.disabled = true;
                    }

                    break;
                }
            }
        }
    
    
}