
  var fndr = 'Product finder';  
  var msw = true;
  var mto = false;
  var drag = false;

  function imgLock()
  {
		$("img").mousedown(function(e){
  		if(e.button==2) {
  			/*alert("This content is copyrighted and may not be reproduced or used in any way without the express written permission of American DJ.");*/
  			return false;
  		}
		});
		$("img.normal,#fancy_img").mousedown(function(e){
  		if(e.button==1) {
  		  drag = true;
  			return true;
  		}
		}).mousemove(function(e){
  		if (drag) {
        /*alert("This content is copyrighted and may not be reproduced or used in any way without the express written permission of American DJ.");*/
    		drag = false;
      }
		});
		$(document).mouseup(function(e){
  	  drag = false;
  		return true;
		});
		$("img").each( function() {
			$(this)[0].oncontextmenu = function() {
				return false;
			}
		});
  }

  function hideProdList()
  {
    $("#search_results").hide();
    $("#product_search").val(fndr);
  }

  $(document).ready(function(){

    imgLock();
 
    $('img, li, input, div, a, span, h1').ifixpng();
    var flashvars = {
    };
    var params = {
      wmode: "transparent"
    };        
    $.swfobject.embedSWF("flash/default.swf", "flash", "940", "338", "8.0.0", "flash/expressInstall.swf", flashvars, params);
    
    $("#product_search").keyup(function(){
      var q = $("#product_search").val().toUpperCase();
      $("#search_results a:contains('"+q+"')").show();
      $("#search_results a:not(:contains('"+q+"'))").hide();
    });
  
    $("#product_search").focus(function(){
      if ($(this).val()==fndr) $(this).val(""); 
      msw = false;
      if (mto) clearTimeout(mto);
      $(this).select();
      $("#search_results").show();
    });
    
    $("#product_search").click(function(){
      msw = false;
      if (mto) clearTimeout(mto);
      $(this).select();
      $("#search_results").show();
    });
  
    $("#product_search").blur(function(){
      if ($(this).val()=="") $(this).val(fndr); 
      if (msw) {
        mto = setTimeout("hideProdList()",1000);
      }
    });
    
    $("#product_search").mouseover(function(){
      msw = false;
      if (mto) clearTimeout(mto);
    });
  
    $("#search_results").mouseover(function(){
      msw = false;
      if (mto) clearTimeout(mto);
    });
    
    $("#search_results a").mouseover(function(){
      msw = false;
      if (mto) clearTimeout(mto);
    });
    
    $("#search_results").mouseout(function(){
      msw = true;
      mto = setTimeout("hideProdList()",1000);
    });
  
    //Event Calendar
    $("a[id^='d']").click(function(event){
      $('#calendar >li').attr("class","");
      $(this).parent().attr("class","selected");
      $(this).blur();
      if ($('#showevents').size()>0) $('#showevents').empty();
      date=$(this).attr("id");
      req=date.substring(1,8);
      
      $.getJSON("/ajax/sendform.php?date="+req,function(data){
              if (data.success==true){
                $.each(data.event, function() {
                    $('#showevents').append("" + this );
                });
              }  
      });
      
    });
    
    //Zoom button 
    $(".zoom").click(function(event){ 
      event.preventDefault();
      $(this).blur();
      $("a[rel='zoom']:visible").click();
    });
    
    //Downloads 
    $("li[id^='dl_'] > ul").hide();
    $("li[id^='dl_']").click(function(event){
      $(this).find('ul').toggle();
    });
 
  });
