var isOpen = false;
 
function getSignInStatus(me){
 var signInLink = document.getElementById(me); // get a handle to the signin link
 
 if(signInLink){ // make sure the link exists
  if (typeof(euid)== "undefined" || euid == null || euid == '') { // if the user isn't signed in...
   signInLink.href = generateLoginUrl(); // get/set the link url
   signInLink.innerHTML = "Sign in"; // update the link text
   signInLink.title = "Sign into MSN"; // update the link title
  
  }else{ // if the user IS signed in...
   signInLink.href = "/logout"; // set the signout url
   signInLink.innerHTML = "Sign out"; // update the link text
   signInLink.title = "Sign out of MSN"; // update the link title
  }
 }
}  
function moreOnMSN(me){
 var linkHolder = me.parentNode;  // get a handle to the link holder
 var msnMore = document.getElementById("msn-more");
 
 if(linkHolder.className != "down"){ // if the more on isn't open...
  linkHolder.className = "down"; // change the class of the button to reflect "open"
  msnMore.className = "open";  // open the msn more div
 }else{ // if the "more on" link is open...
  linkHolder.className = ''; // change the class of the button to reflect "closed"
  msnMore.className = "";  // close the msn more div
 }
}

//Function for sending search string tracking data to hitbox.
  function sendToHitboxTracker(whatPage, whatDir) { 
    _hbSet('hb', 'DM520329OJCS95EN3'); 
    _hbSet('n', whatPage);
    _hbSet('vcon', whatDir);
    _hbSend();
  }
 
//Function for the search box form.
function fsSearch(stype){
 var searchboxEl = document.getElementById("searchbox");
 var searchString = searchboxEl.value;
 
 if (searchString.length > 0) {
  if(stype.id == "site") {
   sendToHitboxTracker(searchString.toUpperCase(), "/jumboTronFoxSportsSearch");
   location.href=("http://msn.foxsports.com/search?sp_q=" + escape(searchString));
  } else if (stype.id == "web") {
   sendToHitboxTracker(searchString.toUpperCase(), "/jumboTronMSNSearch");
   location.href="http://search.msn.com/results.aspx?q=" + escape(searchString) + "&cp=1252&FORM=FOXSP";
  }
 }
}

//Function for the search box form.
  function doSearch(stype) {
    var searchboxEl = document.getElementById("searchbox");
    var searchString = searchboxEl.value;
    //alert(searchString.length);
    if (searchString.length > 0) {
      if(stype == "fs") {
        sendToHitboxTracker(searchString.toUpperCase(), "/jumboTronFoxSportsSearch");
        location.href=("http://msn.foxsports.com/search?sp_q=" + escape(searchString));
      } else if (stype == "web") {
        sendToHitboxTracker(searchString.toUpperCase(), "/jumboTronMSNSearch");
        location.href="http://search.msn.com/results.aspx?q=" + escape(searchString) + "&cp=1252&FORM=FOXSP";
      }
    }
  } 

  function generateLoginUrl() {
    var path = location.pathname;
    var query = location.search ;
    if (query == '') {
      query = "?need=prefs";
    } else {
      query += "&need=prefs";
    }
    if (window.location.href.indexOf('blogs') != -1) {
      var cfu = escape(secureDomain+"/pp/response?blogs=true&cfu=" + path + query);
    } else {
      var cfu = escape(secureDomain+"/pp/response?cfu=" + path + query);
    }
    var doubleEscapeCfu = escape (cfu);
    var queryParams = "&seclog=10&wa=wsignin1.0&wreply=" + cfu + "&cb=" + escape("&wa=wsignin1.0&wreply=") + doubleEscapeCfu;
    return (passportURL + queryParams);
  }
 
 function getLoginUrl(){
   if (typeof(euid)== "undefined" || euid == null || euid == '') {     
    window.location.href = generateLoginUrl();
   }else{     
    window.location.href = logoutURL;
   }
 } 
 
 function getSignStr(){
  if (typeof(euid)== "undefined" || euid == null || euid == '') {
   return "Sign&nbsp;in";
  }else{
   return "Sign&nbsp;out";
  } 
 }