var $j = jQuery.noConflict();
function showitems() {  
	var item  =$j(this).attr("href");
	//alert (item.substring(1));
	item = item.substring(1);
	if (item=='fonts'){
		$j.post("/_scripts/search.php", {queryString: "retail", no_headers:"yes"}, function(data) { // Do an AJAX call
		$j('#suggestions').css("opacity","0.95").fadeIn(200); // Show the suggestions box
		$j('#suggestions').html(data); // Fill the suggestions box  
		$j('#suggestions').css('left','7px');
		DoToTop();
		})
	}
	if (item=='publications'){
		$j.post("/_scripts/search.php", {queryString: ""+item+"", no_headers:"yes"}, function(data) { // Do an AJAX call
		$j('#suggestions').css("opacity","0.95").fadeIn(200); // Show the suggestions box
		DoToTop();
		$j('#suggestions').html(data); // Fill the suggestions box  
		$j('#suggestions').css('left','7px');
		DoToTop();
		})
	}
	if (item=='fonts_in_use'){
		$j.post("/_scripts/rollover_fiu.php", {queryString: ""+item+""}, function(data) { // Do an AJAX call
		$j('#suggestions').css("opacity","0.95").fadeIn(200); // Show the suggestions box
		$j('#suggestions').html(data); // Fill the suggestions box  
		$j('#suggestions').css('left','7px');
		DoToTop();
		})
	}
	if (item=='order/fonts'){
		hideit();
	}
	
 }
 var config2 = {    
	 sensitivity: 1, // number = sensitivity threshold (must be 1 or higher)    
	 interval: 10, // number = milliseconds for onMouseOver polling interval    
	 over: nothing,
	 timeout: 10, // number = milliseconds delay before onMouseOut    
	 out:  nothing // was hideit
 };
 var config = {    
	 sensitivity: 4, // number = sensitivity threshold (must be 1 or higher)    
	 interval: 300, // number = milliseconds for onMouseOver polling interval    
	 over: showitems,
	 timeout: 0, // number = milliseconds delay before onMouseOut    
	 out:  nothing //hideitems
 };
 $j(document).ready(function(){
	$j(".menu").hoverIntent( config );
	$j("#suggestions").hoverIntent( config2);
	$j("body").hoverIntent( config2);
	// hide suggestions if you click somewhere outside the suggestions!
	$j('body').click(function() {
		hideit();
	});
	$j('#suggestions').click(function(event){
		event.stopPropagation();
	});
	// hide the suggestions also when you rollover these elements
	$j('#home_banner').hover(function() {
		//hideit();
	});
	$j('.menu_hide').hover(function() {
		//hideit();
	});
 });
 
 function showit() {  
 	 $j('#suggestions').css('left','307px'); 
	 $j('#suggestions').fadeIn(0); 
 }
 function hideit() {  
	 $j('#suggestions').fadeOut(200); 
	 $j('#jsddm').show();
	 $j('#handle2').show();
	 $j('#slideshow_fade').show();
	 $j('#fade').show();
	 $j('#slider-code').show();
	 
 }
 function nothing() {  
 }




// this is the function to put the suggestion box ALWAYS on top
$j.maxZIndex = $j.fn.maxZIndex = function(opt) {
   /// <summary>
   /// Returns the max zOrder in the document (no parameter)
   /// Sets max zOrder by passing a non-zero number
   /// which gets added to the highest zOrder.
   /// </summary>    
   /// <param name="opt" type="object">
   /// inc: increment value, 
   /// group: selector for zIndex elements to find max for
   /// </param>
   /// <returns type="jQuery" />
   var def = { inc: 10, group: "*" };
   $j.extend(def, opt);    
   var zmax = 0;
   $j(def.group).each(function() {
	   var cur = parseInt($j(this).css('z-index'));
	   zmax = cur > zmax ? cur : zmax;
   });
   if (!this.jquery)
	   return zmax;

   return this.each(function() {
	   zmax += def.inc;
	   $j(this).css("z-index", zmax);
   });
}
function DoToTop() {
   // Set the zIndex to max + 5
   $j("#suggestions").maxZIndex({ inc: 1 });
   //$j('#jsddm').hide();
   //$j('#handle2').hide();
   //$j('#slideshow_fade').hide();
   //$j('#fade').hide();
   //$j('#slider-code').hide();
   // Get the zIndex as a number
}
   

