$(document).ready(function(){

var closetimer = 0;
var obj = 0;
// timeout for the menu to close automatically if there is no mouseover
var timeout    = 300;

function openmenu()
{ 
jmenucanceltimer();
// get the rel value of the link and show the relavent div
if ( obj == 0 || (obj.attr('rel')!=$('div[rel="menu-'+$(this).find("a").attr("rel")+'"]').attr('rel') )){
	jmenuclose()

		obj = $('div[rel="menu-'+$(this).find("a").attr("rel")+'"]');
		// ensure we're only showing divs with subcategories
		if( obj.find("a.sublink").length >0  ){
		 if( $(this).find("a").attr("rel")!= ''){			
		 obj.css({
			position : 'absolute',
			display : 'none',
			top : $(this).offset().top + $(this).height() ,
			left : $(this).offset().left ,
			'z-index' : 200
			});
		
	  }
	  // show menu
	  obj.slideDown('fast');
	   }
}
  
}

function jmenuclose()
{   
	// hide the menu
	if(obj) obj.slideUp('fast');
	obj =0;
}

function jmenutimer()
{  

closetimer = window.setTimeout(jmenuclose, timeout);}

function jmenucanceltimer()
{  
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function(){  
	// actions
	// mouseover action and mouse out of menu
	$('#category ul li').bind('mouseover', openmenu)
	// start the timer
	$('#category ul li').bind('mouseout', jmenutimer)
	$('.dropmenu').bind('mouseout', jmenutimer)
	// reset the timer if the cursor is rolled from the link to the dropdown div
	$('.dropmenu').bind('mouseover', jmenucanceltimer)
	});

// flash banner rotator
 if ($(".banner-rotator").length>0){
	 $(".welcome").css({"background" : "none"});
	
	var so = new SWFObject("catalog/view/theme/colormod/preview.swf", "tt", "950", "222", "9");
	so.addParam("wmode","transparent");
	so.addVariable("FlashVars",$(".banner-rotator").attr("rel"));
	so.write("welcome");
	 }

});
