// location cookie


function checkLocation() {
  var myCookie;
  //var iHazCookies = navigator.cookieEnabled;
  var iHazCookies = false;
  if (!iHazCookies) {
     myCookie = 'Global';
     // we're doing this right here because of cookieless clients
     // they will just go right to the global side.
     window.location = context + myCookie + "/" + myCookie + "index.asp";
     return;
  }

   myCookie = $.cookie("UniLoc");

  if (myCookie == 'NA' || myCookie == 'Global')  {
    window.location = context + myCookie + "/" + myCookie + "index.asp";
  }
}


function goHome() {
  var myCookie;
  var testURL;
  var iHazCookies = navigator.cookieEnabled;

  myCookie = $.cookie("UniLoc");

  if (myCookie == null || !iHazCookies) {
    myCookie = 'Global';
  }

  if (myCookie == 'NA' || myCookie == 'Global')  {
    // testURL = "../../" + myCookie + "/" + myCookie + "index.asp";
    // alert(testURL);
    window.location = "../../" + myCookie + "/" + myCookie + "index.asp";
  }
}


function autoURL(myHref) {
  var myCookie;
  var testURL;
  var iHazCookies = navigator.cookieEnabled;

  myCookie = $.cookie("UniLoc");

  if (myCookie == null || !iHazCookies) {
    myCookie = 'Global';
  }

  if (myCookie == 'NA' || myCookie == 'Global')  {
     // testURL = "../../" + myCookie + "/"  + myHref + "";
     // alert(testURL);
    window.location = "../../" + myCookie + "/"  + myHref + "";
  }
}

function autoURLShort(myHref) {
  var myCookie;
  var testURL;
  var iHazCookies = navigator.cookieEnabled;

  myCookie = $.cookie("UniLoc");

  if (myCookie == null || !iHazCookies) {
    myCookie = 'Global';
  }

  if (myCookie == 'NA' || myCookie == 'Global')  {
     // testURL = "../" + myCookie + "/"  + myHref + "";
     // alert(testURL);
    window.location = "../" + myCookie + "/"  + myHref + "";
  }
}



function passURLValue() {
  var passURL = document.sellocation.mylocation.options[document.sellocation.mylocation.selectedIndex].value
  var strippedURL = passURL.split('/')
  var iHazCookies = navigator.cookieEnabled;

  window.location = context + passURL + "";

  if ($.cookie("UniLoc") == null && iHazCookies) {
    $.cookie("UniLoc", strippedURL[1], { expires: 90, path: '/' })
  }
}

function passURLimg(myLoc) {
  var strippedURL = myLoc.split('/')
  var iHazCookies = navigator.cookieEnabled;

  window.location = context + myLoc + "";

  if ($.cookie("UniLoc") == null && iHazCookies) {
    $.cookie("UniLoc", strippedURL[1], { expires: 90, path: '/' })
  }
}

function reWriteCookie() {
  var myCookie;
  var iHazCookies = navigator.cookieEnabled;

  myCookie = $.cookie("UniLoc");

  if(!iHazCookies || myCookie == null) {
    return;
  }

  if(myCookie == 'NA') {
    $.cookie("UniLoc", "Global", { expires: 90, path: '/' })
  }

  if(myCookie == 'Global') {
    $.cookie("UniLoc", "NA", { expires: 90, path: '/' })
  }
}

function oppositeSite() {
  var myCookie;
  var iHazCookies = navigator.cookieEnabled;

  myCookie = $.cookie("UniLoc");

  if(!iHazCookies || myCookie == null) {
    return;
  }

  if(myCookie == 'NA') {
    //document.write('<a href="../../Global/Globalindex.asp" onClick=reWriteCookie();>Global Site</a>');
  }

  if(myCookie == 'Global') {
    //document.write('<a href="../../NA/NAindex.asp" onClick=reWriteCookie();>US Site</a>');
  }
}
