// JavaScript Document


(function($){
		$.fn.jnice = function( options ) {
			
			return $(this).each(function(){				
										 
				var $f = $(this);				
				var settings = $.extend({
					
					jselect:true
				},options||{});
				
				/*selects*/
				if(settings.jselect) {
					($.browser.msie&&parseInt($.browser.version)<8)?ea=true:ea=false;
					$('select', $f).each(function(index){
					var $select = $(this);		
					var $class = $select.attr('class');
					$select.addClass('hide').wrap('<span class="jselect '+$class+'" style="'+$select.attr('style')+'"><div class="jNiceSelectWrapper"></div></span>');
					var $wrapper = $select.parent().css({zIndex: 100-index});
				
					$wrapper.prepend('<a class="selectedItem" href="#"></a><ul class="spec"></ul>');
					var $ul = $('ul.spec', $wrapper);
				
					$('option', $select).each(function(i){
						$ul.append('<li><a href="#" index="'+ i +'">'+ this.text +'</a></li>');
					});
					$ul.height()>150?$ul.height('150px'):'';					
					$ul.hide().find('a').click(function(){
						var $obj = $(this);
						$('a.selected', $wrapper).removeClass('selected');
						$obj.addClass('selected');	
						if($select.attr('selectedIndex')!=$obj.attr('index')&&$select.change) {$select.attr('selectedIndex',$obj.attr('index')); $select.change(); }
						$select.attr('selectedIndex',$obj.attr('index'));						
						$('a.selectedItem', $wrapper).html($obj.html());
						$ul.hide();
						return false;
					});			
					$('a:eq('+ $select.attr('selectedIndex') +')', $ul).click();
				});
				$('a.selectedItem', this).click(function(){
					var $ul = $(this).siblings('ul');
					if ($ul.css('display')=='none'){ hideSelect(); } 
    				$ul.slideToggle('fast',function(){
						var offSet = parseInt(((ea ? $('a.selected', $ul).parent().attr('offsetTop') : $('a.selected', $ul).attr('offsetTop')) - $ul.attr('offsetTop')));					
						$ul.animate({scrollTop: offSet});					
					});					
					return false;
				});
		
				var hideSelect = function(){
					$('.jNiceSelectWrapper ul:visible').hide();
				};		
		
				var checkExternalClick = function(event) {
					if ($(event.target).parents('.jselect').length === 0) { hideSelect(); }
				};

				$(document).mousedown(checkExternalClick);
		
			
		
				var jReset = function(f){
					var sel;
					
					
					$('div.jNiceSelectWrapper select', f).each(function(){
																	
						sel = ( this.selectedIndex < 0 ) ? 0 : this.selectedIndex;
						
						$('ul', $(this).parent()).each(function(){
																
 							$('a:eq('+ sel +')', this ).click();																																																	 						});
					});
					
					
			
				};
				
				$f.bind('reset', function(){ var f = this;  var action = function(){ jReset(f); }; setTimeout(action, 10);});
		
				};
			});
		};	
	})(jQuery);
$(function(){
	$('#t-bar li,#cat li').hover(function(){$(this).addClass('hover')},function(){$(this).removeClass('hover')})
	$('.jnice').jnice();	
	
	$('.placeholder').focus(function(){this.value==this.defaultValue?this.value='':''}).blur(function(){this.value==''?this.value=this.defaultValue:''})
	
	
	$('body').click(function(event){ var e = event || window.event;  if($(e.target).parents('div.cat-prod').length==0) { $('#cat-sub').addClass('hide'); $('#cat-sub-up').addClass('hide'); $('#cat-sub-down').removeClass('hide');/*$('a.targ').toggleClass('hide')*/ } if($(e.target).parents('div.pod-prod').length==0) { $('#pod-sub').addClass('hide'); $('#pod-sub-up').addClass('hide'); $('#pod-sub-down').removeClass('hide'); /*$('a.targ2').toggleClass('hide')*/ } })
})
