// Pull Down Menu

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

jQuery.noConflict();
	var timeout = null;
	var prev = "";
	var active = -1;
	var cache = {};
	var keyb = false;
	var hasFocus = false;
	var lastKeyPressCode = null;
	var lis = [];
	
function lookup(inputString) {
   if(inputString.length == 0) {
		jQuery('#suggestions').fadeOut(); // Hide the suggestions box
   } else {
		jQuery.post("skins/OMGSkin/scripts/ajaxsearch.php", {queryString: ""+inputString+""}, function(data) { // Do an AJAX call
		jQuery('#suggestions').fadeIn(); // Show the suggestions box
		jQuery('#suggestions').html(data); // Fill the suggestions box
	
	jQuery('#suggestions a').each(function() {
		 lis.push(this);
	});	
		jQuery(window).keydown(function(e) {
				// track last key pressed
				lastKeyPressCode = e.keyCode;
				switch(e.keyCode) {
					case 38: // up
						e.preventDefault();
						moveSelect(-1);
						break;
					case 40: // down
						e.preventDefault();
						moveSelect(1);
						break;

					case 9:  // tab
					case 13: // return
						if( selectCurrent() ){
							// make sure to blur off the current field
							$input.get(0).blur();
							e.preventDefault();
						}
						break;
					default:
						active = -1;
						if (timeout) clearTimeout(timeout);
						//timeout = setTimeout(function(){onChange();}, options.delay);
						break;
				}
			});		
      });
   }
}



 	function moveSelect(step) {

		active += step;

		if (active < 0) {
			active = 0;
		} else if (active >= lis.length) {
			active = lis.length - 1;
		}

		if (active < 0) {
			active = 0;
		} else if (active >= lis.length) {
			active = lis.length - 1;
		}
		//jQuery("#mani_debug").html(active);
	//jQuery('#suggestions a').removeClass("myhover");
		jQuery(lis[active]).focus();
//jQuery(lis[active]).addClass("myhover");		

		// Weird behaviour in IE
		// if (lis[active] && lis[active].scrollIntoView) {
		// 	lis[active].scrollIntoView(false);
		// }

	};


jQuery(document).ready(function(){

	jQuery("#suggestions").mouseleave(function(){
		omg = setTimeout("jQuery('#suggestions').fadeOut()",1500);
	});
	
	jQuery("#suggestions").mouseenter(function(){
		omg = setTimeout("jQuery('#suggestions').fadeOut()",1500);
		clearTimeout(omg);
	});
	
	jQuery('.hover_prodlistmsg').hover(function(){
		jQuery(this).next('.prodlist_ship_msg_holder').show();
	}, function(){
		jQuery(this).next('.prodlist_ship_msg_holder').hide();
	});
	
	var tdImg;
	
	jQuery('.seeBelow a').click(function(e){
		e.preventDefault();
		$('.pltable_name').each(function(){
			tdImg = $('.pltable_img', this).attr('img');
			$('.pltable_img', this).insertBefore('<img src="media/ecom/prodsm/'+tdImg+'" width="100" />');
		});
	});

});

