/*==========================================//
Enable active stylesheet, disable others
//==========================================*/
function setActiveStyleSheet(title) {
    var i, linkedStyle;

    for (i = 0; (linkedStyle = document.getElementsByTagName("link")[i]); i++) {

        if (linkedStyle.getAttribute("rel").indexOf("style") != -1
                && linkedStyle.getAttribute("title")
                && (linkedStyle.getAttribute("title") == title)) {

            //Is a stylesheet, has a title, title matches supplied title
            //Enable this stylesheet
              linkedStyle.disabled = true;
             linkedStyle.disabled = false;
            if(navigator.appName == 'Microsoft Internet Explorer')
            {
              linkedStyle.disabled = true;
              linkedStyle.disabled = false;
            }

        } else if (linkedStyle.getAttribute("rel").indexOf("style") != -1
                    && linkedStyle.getAttribute("title")
                    && linkedStyle.getAttribute("title").indexOf("Text") != -1) {

            //Is a stylesheet, has a title, title contains the string 'Text'
            //Disable this stylesheet
             linkedStyle.disabled = false;
            linkedStyle.disabled = true;
                        if(navigator.appName == 'Microsoft Internet Explorer')
                        {
                          linkedStyle.disabled = false;
                          linkedStyle.disabled = true;
                    }
        }
    }
}
      
$(document).ready(function() {
  $("#fontsize").click(function() {
        if(getCookieArray()[Cookie_ID_fontsize] == "0.8em")
        {
           $("body").css("font-size","1.2em");
           setCookie(Cookie_ID_fontsize,"1.2em");
           setActiveStyleSheet('largeText');
        }
        else
        {
           $("body").css("font-size","0.8em");
           setCookie(Cookie_ID_fontsize,"0.8em");
               setActiveStyleSheet('normalText');
        }
    });
  if(!getCookieArray()[Cookie_ID_fontsize])
    {
      $("body").css("font-size","0.8em");
      setCookie(Cookie_ID_fontsize,"0.8em");
      setActiveStyleSheet('normalText');
    }
  else
  {
    $("body").css("font-size",getCookieArray()[Cookie_ID_fontsize]);
    if(getCookieArray()[Cookie_ID_fontsize] == "0.8em")
        setActiveStyleSheet('normalText');
    else
      setActiveStyleSheet('largeText');
  }

  var hasVScroll = ($(document).height() > $(window).height());
  if(!hasVScroll ) {
    $(".link-top").hide();
  }

$(window).resize(function() {
  var hasVScroll = ($(document).height() > $(window).height());
  if(!hasVScroll ) {
    $(".link-top").hide();
  }
  else {
    $(".link-top").show();
  }
});

});

  function getCookieArray() {
    if(!cookieArray)
    {
      cookieArray = getCookie("seamlesscookie")
      if(!cookieArray)
        {
          cookieArray = new Array(0,true,"0.8em");
        }
        else
        {
          cookieArray = cookieArray.split("@#-+");
        }
      if(cookieArray[1] != "true")
      {
        cookieArray = new Array(0,true,"0.8em");
      }
    }
    return cookieArray;
  }
function setCookie(num, val) {
  getCookieArray()[num] = val;
  storeCookie();
}

function getCookie(c_name)
{
var i,x,y,ARRcookies=document.cookie.split(";");
for (i=0;i<ARRcookies.length;i++)
{
  x=ARRcookies[i].substr(0,ARRcookies[i].indexOf("="));
  y=ARRcookies[i].substr(ARRcookies[i].indexOf("=")+1);
  x=x.replace(/^\s+|\s+$/g,"");
  if (x==c_name)
    {
    return unescape(y);
    }
  }
}

function storeCookie() {
  var cookies = getCookieArray();
  var str = "";
  for(i=0;i<cookies.length;i++)
  {
    str+=cookies[i]+"@#-+";
  }
  var exdate=new Date();
exdate.setDate(exdate.getDate() + 3);
  var c_value=escape(str.slice(0,-4)) + "; expires="+exdate.toUTCString();
  document.cookie = "seamlesscookie="+c_value;
}

var cookieArray = null;
var Cookie_ID_fontsize = 2;
function addBookmark(title,url){
if(window.sidebar){
window.sidebar.addPanel(title, url, "");
} else if(document.all){
window.external.AddFavorite(url, title);
} else if(window.opera && window.print){
alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
} else if(window.chrome){
alert('Press ctrl+D to bookmark (Command+D for macs) after you click Ok');
}
}

function fbs_click() 
{
  u=location.href;
  t=document.title;
  window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
  return false;
}
  function openLinkedIn(link,title)
  {
      var linkedInURLPre = 'http://www.linkedin.com/shareArticle?mini=true';
      var linkStr = '&url='+encodeURI(link);
      var titleStr = '&title=' +encodeURI(title);
       window.open(linkedInURLPre +linkStr+titleStr);
  }


                               
