﻿var _compareItemCount = 0;

$(function () {
 _menuSelected = 0;
 $('#MainMenu h1 a').each(function () {
  if (window.location.href.indexOf($(this).attr('href')) > 5) {
   _menuSelected = 1;
   $(this).attr('style', 'color:#cc0000');
  }
 });

 if (!_menuSelected) {
  $('#MainMenu h1 a:eq(0)').attr('style', 'color:#cc0000');
 }

 _cookieContent = getCookie('compareList') + '';

 if (_cookieContent != 'null') {
  if (_cookieContent == '') {
   _compareItemCount = 0;
  }
  else {
   _compareItemCount = _cookieContent.split(",,").length;
  }
 }
 $('a.CompareList').css('display', 'inline-block');
 $('a.CompareList span.ItemCount').html(_compareItemCount);

});

function setCookie(name, value, days) {
 if (days) {
  var date = new Date();
  date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
  var expires = "; expires=" + date.toGMTString();
 }
 else var expires = "";
 document.cookie = name + "=" + value + expires + "; path=/";
}

function getCookie(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;
}

function deleteCookie(name) {
 setCookie(name, "", -1);
}
