var special = false;
var basePath = '/images/special.gif';
var rolloverPath = '/images/special2.png';

$(document).ready(function() {
  
  if(!sux()) {
    jQuery("<img>").attr("src", basePath);
    jQuery("<img>").attr("src", rolloverPath);
  
	$("#special").hover(
	  function() {
	    
	    $("#special").css("background-image", "url(" + rolloverPath + ")");
	    jiggleInner(false);   
	 
	  },
	  function() {
	
	    if(!special) {
	      $("#special").css("background-image", "url("+ basePath +")");
	    }
	  }
	);
	    
	$("#special").click(function() {
	    
	  if(special) {
	      
	    $(this).animate({
	      top: "-411px"
	    }, 200, 
	    "linear", 
	    function(){
	      special = false;
	      $("#special").css("background-image", "url(" + basePath + ")");
	    });       
	     
	  } else {
	     
	    $("#special").css("background-image", "url(" + rolloverPath + ")");
	    $(this).animate({ 
	      top: "-3px"
	    }, 500, "swing", function() { 
	      special = true; 
	    });     
	      
	  }
	});
    
    jiggleSpecialId = window.setTimeout(function() { jiggleSpecial(); }, 3000);
  } else {
  
    // special behavior for IE6 only
    $("#special").click(function() {
    
      if(special) {

        // scroll up and clear special
        $("#special").css("top", "-411px");
        special = false;
       
      } else {
        
        // scroll down and set special
        $("#special").css("top", "-3px");
        special = true; 
      }
    });
  }

});

var count = 0;
function jiggleSpecial() {
  if (++count <= 3 && !special) {
    jiggleInner(true);
  } 
}

function jiggleInner(recurse){
  if(!special) {
    $("#special").animate({
      top: "-406px"
    }, 
    100, 
    "linear", 
    function(){
      $("#special").animate({
        top: "-411px"
      }, 100);
      if (recurse) {
        jiggleSpecial();
      }
    });
  }
}

// is te browser te sux?
function sux() { 
  var do_i_sux = (jQuery.browser.msie) && (parseInt(jQuery.browser.version) < 7); 
  return do_i_sux;
}