$(document).ready(function(){
  var theme = $.cookie("theme");

  if(theme){
    $("link#skin").attr("href", PublicDir + "/css/themes/"+ theme +".css");
    $.cookie("theme",theme,{path: cookiepath});
  }
//Add theme CSS

  $(".themebtn").click(function() {
    theme = this.id;
    //highlight on/off button is inappropriate for highcontrast mode and so is hidden
    if(theme=="contrast"){
      $(".highlightbtn").addClass("hidden");
    } else {
      $(".highlightbtn").removeClass("hidden");
    }
    if(theme=='default'){
      if(defaultTheme!='silver'&&defaultTheme!='olive'&&defaultTheme!='blue'&&defaultTheme!='contrast'){
        theme=defaultTheme;
      }
    }	
    $("link#skin").attr("href", PublicDir + "/css/themes/"+ theme +".css");
    $.cookie("theme",theme,{path: cookiepath});
  });


  $('.themebtn').hover(function() {
    $(this).css("cursor","pointer");
  }, function() {
    $(this).css("cursor","auto");
  });
		
  $('.txthover').hover(function() {
    $(this).css("cursor","pointer");
  }, function() {
    $(this).css("cursor","auto");
  });
		
  $('.advancedSelect').hover(function() {
    $(this).addClass("hover");
  }, function() {
    $(this).removeClass("hover");
  });
				
  $('table tr.circRowDefault').hover(function() {
    $(this).addClass("hover");
  }, function() {
    $(this).removeClass("hover");
  });
		
  $('.circRowDefault td:not(:has(a))').click(function(){
    if (!($(this).children('input.checkbox').attr('class') == 'checkbox')) {
      $(this).parent().removeClass("hover").find('input.checkbox').click();
    }
  });
	
  //hide highlight on/off button for high contrast mode and remove
  if(theme=="contrast"){
    $(".highlightbtn").addClass("hidden");
  } else {
    $(".highlightbtn").removeClass("hidden");
  }
	
});