﻿var count = 0;
function Anthem_PreCallBack() { 
    count++;
    setTimeout("CallBackStarted()", 500); 
}
function Anthem_PostCallBack() { CallBackFinished(); }

function CallBackStarted() {
  if (count > 0){  
    var item = document.getElementById('wait');
    if ((!window.XMLHttpRequest) && (document.documentElement) && item){
      item.style.position = 'absolute';
      //code to make ie6 behave
      if (document.documentElement.scrollTop){
        item.style.top = document.documentElement.scrollTop + 15;
      }
      else{ item.style.top = 15; }      
      item.style.right = 15;
     }
     if (item) {
     	item.style.display = 'block';
     }
  }
}
 
function CallBackFinished(){
  count--;
  if (count == 0){
    var item = document.getElementById('wait');
    if (item != null){
        item.style.display = 'none';
    }
  }
}


$(function() {

	function doSearch(e) {
		if (e) e.preventDefault();
		window.location.href = '/search.aspx?keyword=' + encodeURIComponent($("#searchBox").val());
		return false;
	};

	$("#searchSubmit").click(doSearch);

	$("#searchBox").bind('keypress', function(e) {
		var code = e.keyCode || e.which;
		if (code == 13) doSearch();
	}).focus(function() {
		if ($(this).val() == "SEARCH") {
			$(this).val("");
		}
		$(this).addClass("focused");
	}).blur(function() {
		if ($(this).val() == "") {
			$(this).val("SEARCH");
			$(this).removeClass("focused");
		}
	});


	//shopping cart box
	$('#shopping_cart_box').hide();
	$('#add_to_cart').click(function() {
		$('#shopping_cart_box').show('slow')
	})
	$('#shopping_cart_box_closeWin').click(function() {
		$('#shopping_cart_box').hide('slow');
	});

	// Navigation Code
	$("#nav ul ul").hide();
	$('#nav ul:first-child').superfish({
		delay: 1000,
		dropShadows: false
	});





}); 
Shadowbox.init();
