jQuery.noConflict()

var jquerypopupmenu={
	arrowpath: 'arrow.gif', //full URL or path to arrow image
	popupmenuoffsets: [-10, 0], //additional x and y offset from mouse cursor for popup menus
	animspeed: 200, //reveal animation speed (in milliseconds)
	showhidedelay: [150, 150], //delay before menu appears and disappears when mouse rolls over it, in milliseconds

	//***** NO NEED TO EDIT BEYOND HERE
	startzindex:1000,
	builtpopupmenuids: [], //ids of popup menus already built (to prevent repeated building of same popup menu)

	positionul:function($, $ul, e){
		var istoplevel=$ul.hasClass('jqpopupmenu') //Bool indicating whether $ul is top level popup menu DIV
		var docrightedge=$(document).scrollLeft()+$(window).width()-40 //40 is to account for shadows in FF
		var docbottomedge=$(document).scrollTop()+$(window).height()-40
		if (istoplevel){ //if main popup menu DIV
			var x=e.pageX+this.popupmenuoffsets[0] //x pos of main popup menu UL
			var y=e.pageY+this.popupmenuoffsets[1]
			x=(x+$ul.data('dimensions').w > docrightedge)? docrightedge-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge of the cursor
			y=(y+$ul.data('dimensions').h > docbottomedge)? docbottomedge-$ul.data('dimensions').h : y
		}
		else{ //if sub level popup menu UL
			var $parentli=$ul.data('$parentliref')
			var parentlioffset=$parentli.offset()
			var x=$ul.data('dimensions').parentliw //x pos of sub UL
			var y=0

			x=(parentlioffset.left+x+$ul.data('dimensions').w > docrightedge)? x-$ul.data('dimensions').parentliw-$ul.data('dimensions').w : x //if not enough horizontal room to the ridge parent LI
			y=(parentlioffset.top+$ul.data('dimensions').h > docbottomedge)? y-$ul.data('dimensions').h+$ul.data('dimensions').parentlih : y
		}
		$ul.css({left:x, top:y})
	},
	
	showbox:function($, $popupmenu, e){
		clearTimeout($popupmenu.data('timers').hidetimer)
		$popupmenu.data('timers').showtimer=setTimeout(function(){$popupmenu.show(jquerypopupmenu.animspeed)}, this.showhidedelay[0])
	},

	hidebox:function($, $popupmenu){
		clearTimeout($popupmenu.data('timers').showtimer)
		$popupmenu.data('timers').hidetimer=setTimeout(function(){$popupmenu.hide(100)}, this.showhidedelay[1]) //hide popup menu plus all of its sub ULs
	},


	buildpopupmenu:function($, $menu, $target){
		$menu.css({display:'block', visibility:'hidden', zIndex:this.startzindex}).addClass('jqpopupmenu').appendTo(document.body)
		$menu.bind('mouseenter', function(){
			clearTimeout($menu.data('timers').hidetimer)
		})		
		$menu.bind('mouseleave', function(){ //hide menu when mouse moves out of it
			jquerypopupmenu.hidebox($, $menu)
		})
		$menu.data('dimensions', {w:$menu.outerWidth(), h:$menu.outerHeight()}) //remember main menu's dimensions
		$menu.data('timers', {})
		var $lis=$menu.find("ul").parent() //find all LIs within menu with a sub UL
		$lis.each(function(i){
			var $li=$(this).css({zIndex: 1000+i})
			var $subul=$li.find('ul:eq(0)').css({display:'block'}) //set sub UL to "block" so we can get dimensions
			$subul.data('dimensions', {w:$subul.outerWidth(), h:$subul.outerHeight(), parentliw:this.offsetWidth, parentlih:this.offsetHeight})
			$subul.data('$parentliref', $li) //cache parent LI of each sub UL
			$subul.data('timers', {})
			$li.data('$subulref', $subul) //cache sub UL of each parent LI
			$li.children("a:eq(0)").append( //add arrow images
				'<img src="'+jquerypopupmenu.arrowpath+'" class="rightarrowclass" style="border:0;" height="7" width="9" />'
			)
			$li.bind('mouseenter', function(e){ //show sub UL when mouse moves over parent LI
				var $targetul=$(this).css('zIndex', ++jquerypopupmenu.startzindex).addClass("selected").data('$subulref')
				if ($targetul.queue().length<=1){ //if 1 or less queued animations
					clearTimeout($targetul.data('timers').hidetimer)
					$targetul.data('timers').showtimer=setTimeout(function(){
						jquerypopupmenu.positionul($, $targetul, e)
						$targetul.show(jquerypopupmenu.animspeed)
					}, jquerypopupmenu.showhidedelay[0])
				}
			})
			$li.bind('mouseleave', function(e){ //hide sub UL when mouse moves out of parent LI
				var $targetul=$(this).data('$subulref')
				clearTimeout($targetul.data('timers').showtimer)
				$targetul.data('timers').hidetimer=setTimeout(function(){$targetul.hide(100).data('$parentliref').removeClass('selected')}, jquerypopupmenu.showhidedelay[1])
			})
		})
		$menu.find('ul').andSelf().css({display:'none', visibility:'visible'}) //collapse all ULs again
		$menu.data('$targetref', $target)
		this.builtpopupmenuids.push($menu.get(0).id) //remember id of popup menu that was just built
	},

	

	init:function($, $target, $popupmenu){
		if (this.builtpopupmenuids.length==0){ //only bind click event to document once
			$(document).bind("click", function(e){
				if (e.button==0){ //hide all popup menus (and their sub ULs) when left mouse button is clicked
					$('.jqpopupmenu').find('ul').andSelf().hide()
				}
			})
		}
		if (jQuery.inArray($popupmenu.get(0).id, this.builtpopupmenuids)==-1) //if this popup menu hasn't been built yet
			this.buildpopupmenu($, $popupmenu, $target)
		if ($target.parents().filter('ul.jqpopupmenu').length>0) //if $target matches an element within the popup menu markup, don't bind onpopupmenu to that element
			return
		$target.bind("mouseenter", function(e){
			$popupmenu.css('zIndex', ++jquerypopupmenu.startzindex)
			jquerypopupmenu.positionul($, $popupmenu, e)
			jquerypopupmenu.showbox($, $popupmenu, e)
		})
		$target.bind("mouseleave", function(e){
			jquerypopupmenu.hidebox($, $popupmenu)
		})
	}
}

jQuery.fn.addpopupmenu=function(popupmenuid){
	var $=jQuery
	return this.each(function(){ //return jQuery obj
		var $target=$(this)
			jquerypopupmenu.init($, $target, $('#'+popupmenuid))
	})
};

//By default, add popup menu to anchor links with attribute "data-popupmenu"
jQuery(document).ready(function($){
	var $anchors=$('*[data-popupmenu]')
	$anchors.each(function(){
		$(this).addpopupmenu(this.getAttribute('data-popupmenu'))
	})
})


jQuery.noConflict();var flexdropdownmenu={arrowpath:"arrow.gif",animspeed:200,showhidedelay:[150,150],startzindex:1000,builtflexmenuids:[],positionul:function(b,c,g,n){var l=c.hasClass("jqflexmenu");var f=b(document).scrollLeft()+b(window).width()-40;var k=b(document).scrollTop()+b(window).height()-40;if(l){var a=n.offset();var m=n.data("setting");var j=a.left+m.useroffsets[0]+(m.dir=="h"?n.outerWidth():0);var i=a.top+m.useroffsets[1]+(m.dir=="h"?0:n.outerHeight());j=(j+c.data("dimensions").w>f)?j-(m.useroffsets[0]*2)-c.data("dimensions").w+n.outerWidth()+(m.dir=="h"?-(n.outerWidth()*2):0):j;i=(i+c.data("dimensions").h>k)?i-(m.useroffsets[1]*2)-c.data("dimensions").h-n.outerHeight()+(m.dir=="h"?(n.outerHeight()*2):0):i}else{var h=c.data("$parentliref");var d=h.offset();var j=c.data("dimensions").parentliw;var i=0;j=(d.left+j+c.data("dimensions").w>f)?j-c.data("dimensions").parentliw-c.data("dimensions").w:j;i=(d.top+c.data("dimensions").h>k)?i-c.data("dimensions").h+c.data("dimensions").parentlih:i}c.css({left:j,top:i})},showbox:function(b,a,c){clearTimeout(a.data("timers").hidetimer);a.data("timers").showtimer=setTimeout(function(){a.show(flexdropdownmenu.animspeed)},this.showhidedelay[0])},hidebox:function(b,a){clearTimeout(a.data("timers").showtimer);a.data("timers").hidetimer=setTimeout(function(){a.hide(100)},this.showhidedelay[1])},buildflexmenu:function(d,c,a){c.css({display:"block",visibility:"hidden",zIndex:this.startzindex}).addClass("jqflexmenu").appendTo(document.body);c.bind("mouseenter",function(){clearTimeout(c.data("timers").hidetimer)});c.bind("mouseleave",function(){flexdropdownmenu.hidebox(d,c)});c.data("dimensions",{w:c.outerWidth(),h:c.outerHeight()});c.data("timers",{});var b=c.find("ul").parent();b.each(function(f){var g=d(this).css({zIndex:1000+f});var e=g.find("ul:eq(0)").css({display:"block"});e.data("dimensions",{w:e.outerWidth(),h:e.outerHeight(),parentliw:this.offsetWidth,parentlih:this.offsetHeight});e.data("$parentliref",g);e.data("timers",{});g.data("$subulref",e);g.children("a:eq(0)").append('<img src="'+flexdropdownmenu.arrowpath+'" class="rightarrowclass" style="border:0;" />');g.bind("mouseenter",function(i){var h=d(this).css("zIndex",++flexdropdownmenu.startzindex).addClass("selected").data("$subulref");if(h.queue().length<=1){clearTimeout(h.data("timers").hidetimer);h.data("timers").showtimer=setTimeout(function(){flexdropdownmenu.positionul(d,h,i);h.show(flexdropdownmenu.animspeed)},flexdropdownmenu.showhidedelay[0])}});g.bind("mouseleave",function(i){var h=d(this).data("$subulref");clearTimeout(h.data("timers").showtimer);h.data("timers").hidetimer=setTimeout(function(){h.hide(100).data("$parentliref").removeClass("selected")},flexdropdownmenu.showhidedelay[1])})});c.find("ul").andSelf().css({display:"none",visibility:"visible"});this.builtflexmenuids.push(c.get(0).id)},init:function(d,a,c){if(this.builtflexmenuids.length==0){d(document).bind("click",function(f){if(f.button==0){d(".jqflexmenu").find("ul").andSelf().hide()}})}if(jQuery.inArray(c.get(0).id,this.builtflexmenuids)==-1){this.buildflexmenu(d,c,a)}if(a.parents().filter("ul.jqflexmenu").length>0){return}var b=a.attr("data-offsets")?a.attr("data-offsets").split(","):[0,0];b=[parseInt(b[0]),parseInt(b[1])];a.data("setting",{dir:a.attr("data-dir"),useroffsets:b});a.bind("mouseenter",function(f){c.css("zIndex",++flexdropdownmenu.startzindex);flexdropdownmenu.positionul(d,c,f,a);flexdropdownmenu.showbox(d,c,f)});a.bind("mouseleave",function(f){flexdropdownmenu.hidebox(d,c)})}};jQuery.fn.addflexmenu=function(c,a){var b=jQuery;return this.each(function(){var d=b(this);if(typeof a=="object"){if(a.dir){d.attr("data-dir",a.dir)}if(a.offsets){d.attr("data-offsets",a.offsets)}}if(b("#"+c).length==1){flexdropdownmenu.init(b,d,b("#"+c))}})};jQuery(document).ready(function(b){var a=b("*[data-flexmenu]");a.each(function(){b(this).addflexmenu(this.getAttribute("data-flexmenu"))})});function ddlistmenu(c,a){var b=document.createElement("ul");if(c){b.id=c}if(a){b.className=a}this.menu=b}ddlistmenu.prototype={addItem:function(b,d,c){var a=document.createElement("li");a.innerHTML='<a href="'+b+'" target="'+c+'">'+d+"</a>";this.menu.appendChild(a);this.li=a;return this},addSubMenu:function(){var a=new ddlistmenu(null,null);this.li.appendChild(a.menu);return a}};

function concatmanufId(c){var d=[];jQuery("#sel_manufacturers_id :selected").each(function(e,f){d[e]=jQuery(f).val()});var b=[];var a=0;for(j=0;j<d.length;j++){if(d[j]!=""){b[a]=d[j];a++}}jQuery("#manufacturers_id").val(b)}function checkSelection(){if(document.getElementById("manufacturers_id").value==""){alert("Please Select Brand Name!");return false;}else{document.manufacturers_form.submit()}}; 
function getManufactureList(obj)
{ 
		jQuery.get('index.php?main_page=ajax',{type:'manufacture',filter_by:obj.value},function(JsonManufacture)
		{  
			var jsArray = new Array();
			document.getElementById("sel_manufacturers_id").options.length = 0 ;
			jsArray = eval('('+JsonManufacture+')');
			if(jsArray.length>0){
			for(var i=1;i<jsArray.length;i++)
			{
				opt=document.createElement("option");
				document.getElementById("sel_manufacturers_id").options.add(opt);
				opt.text=jsArray[i].text;
				opt.value=jsArray[i].id;
			}
		}
	});
} 
function clear_textbox(a){if(a.value=='Keyword or Item Number')a.value=""}function fill_textbox(a){if(a.value=="")a.value='Keyword or Item Number'}function SelectTab(a){var e=a.parentNode;var c=e.childNodes;var d;for(var b=0;b<c.length;b++){if(!c[b].id){continue}d=document.getElementById(c[b].id+"contents");if(c[b]==a){c[b].className="selectedTab";d.style.display="block"}else{c[b].className="tab";d.style.display="none"}}}

