$(function(){
    $.fn.wait=function(time, type){time = time || 1000;type = type || "fx";return this.queue(type, function(){var self = this;setTimeout(function(){$(self).dequeue();}, time);});};
	document.h_state=0;
	document.nh_state=0;
	document.qs_dd_state=0;
	document.dd_cid='';
	$("#help").bind('mouseenter',function(){if(document.h_state==0){$("#helpbox").fadeIn("fast");document.h_state=1;}});
	$("#helpbox").bind('mouseleave',function(){if(document.h_state==1){$("#helpbox").fadeOut("fast",function(){document.h_state=0;});}});
	$("#enh2010msg").dialog({autoOpen: false, modal: true, width:500, height:500, draggable:false,buttons:{Close:function(){$(this).dialog('close');}}});
	$("#enh2010").click(function(){$("#enh2010msg").dialog('open');});
	$(".menu-link").bind('mouseenter',function(){var id=$(this).attr('id').split('-')[2];if(document.dd_cid!=id){$('.menu-dd-container').hide();$('.menu-link').css({backgroundColor:''});document.nh_state=0;}if(document.nh_state==0){var t=$(this).offset().top+$(this).height();var l=$(this).offset().left;document.dd_cid=id;$('#dd-'+id).css({left:l+'px',top:t+'px'});$(this).css({backgroundColor:'#602B4A'});$('#dd-'+id).slideDown('fast',function(){document.nh_state=1;});}else if(document.nh_state==2)document.nh_state=1;});
	$(".menu-link").bind('mouseleave',function(){var id=$(this).attr('id').split('-')[2];setTimeout(function(){if(document.nh_state==1){$('#menu-link-'+id).css({backgroundColor:''});$('#dd-'+id).slideUp('fast',function(){document.nh_state=0;});}},100);});
	$('.menu-dd-container').bind('mousemove',function(){document.nh_state=2;});
	$('.menu-dd-container').bind('mouseleave',function(){var id=$(this).attr('id').split('-')[1];setTimeout(function(){if(document.nh_state==2){$('#menu-link-'+id).css({backgroundColor:''});$('#dd-'+id).slideUp('fast',function(){document.nh_state=0;});}},100);});
	//$(".snav").click(function(){snaveff($(this));});
	$('#qs-dd-arrow').mousedown(function(){document.qs_dd_state=1;});
	$('#qs-dd-arrow').click(function(){var t=$(this).offset().top;var l=$(this).offset().left;$('#qs-dd').css({top:(t+22)+'px',left:(l-105)+'px'});$('#qs-dd').slideDown('fast',function(){document.qs_dd_state=0;});});
	$(document).click(function(){if(document.qs_dd_state==0){$('#qs-dd').slideUp('fast');}});
	$('#qs-dd li').click(function(){if($(this).hasClass('checked')==false && $(this).attr('id')!='sep-item'){$('#qs-dd li').each(function(){$(this).removeClass('checked');});$(this).addClass('checked');var id=$(this).attr('id');/*$('#_nq').val($('#_'+id).val());*/}});
	$('.prod-cell-img').bind('mouseenter',function(){$('#quick-zoom .holder').css({backgroundImage:''});$('#quick-zoom .loader').show();var t=$(window).scrollTop()+(($(window).height()-$('#quick-zoom').height())/2);$('#quick-zoom').css({top:t+'px'});$('#quick-zoom').show();var bg=$(this).css('background-image').replace(/url/,'').replace(/"/g,'').replace('(','').replace(')','').replace('th','med');var bgimg=new Image();bgimg.onload=function(){$('#quick-zoom .holder').css({backgroundImage:'url("'+this.src+'")'});$('#quick-zoom .loader').hide();};bgimg.src=bg;});
	$('.prod-cell-img').bind('mouseleave',function(){$('#quick-zoom').hide();});
	$('.prod-image-thumb').bind('mouseenter',function(){var bg=$(this).css('background-image');$('.prod-main-image').css({backgroundImage:bg});});
	$('.prod-main-image img').click(function(){$('#zoom-img-holder').css({width:'570px',height:'580px'});$('#zoom-image').css({width:'570px',height:'580px'});var bg=$('.prod-main-image').css('background-image').replace('med','big');var img=new Image();img.onload=function(){var w=this.width;var h=this.height;$('#zoom-image').css({width:w+'px',height:h+'px'});$('#zoom-img-holder').css({width:w+'px',height:h+'px'});};img.src=bg.replace(/url/,'').replace(/"/g,'').replace('(','').replace(')','');$('#zoom-img-holder').css({backgroundImage:bg});$('#zoom-img').dialog('open');});
	if($('#q').val()=='')$('#q').val('search noblivity');
	$('#q').focus(function(){if($(this).val()=='search noblivity')$(this).val('');$(this).css({color:'#000000'});});
	$('#q').blur(function(){if($(this).val()=='search noblivity' || $(this).val()=='')$(this).val('search noblivity').css({color:'#999999'});});
});

function snaveff(obj)
{
	var id=obj.attr('id');
	$('#_nq').val($('#_'+id).val());
	$('#search-nav li').removeClass("current");
	$('#'+id).addClass("current");
	var p = 10;
	switch (id) {
		case "_sk0": p = 10; break;
		case "_sk1": p = 55; break;
		case "_sk2": p = 130; break;
	}
	$("#search-pointer").animate({left:p+"px"},'200');
}
function redirect(url)
{
	if (typeof(url) == 'string' && url.length > 0) {
		window.location.href = url;
	}
}
function filterDigits(event)
{
	if ((event.keyCode>27 && event.keyCode<35) || 
		(event.keyCode>40 && event.keyCode<45) ||
		(event.keyCode>57 && event.keyCode<96) ||
		 event.keyCode>105) {
		event.preventDefault();
	}
}
function helpPopup(url,width,height)
{
	var w,h;
	if (typeof(width) == 'undefiend' || isNaN(parseInt(width)) || width < 0) {
		w = 600;
	} else {
		w = parseInt(width);
	}
	if (typeof(height) == 'undefiend' || isNaN(parseInt(height)) || height < 0) {
		h = 400;
	} else {
		h = parseInt(height);
	}
	var t=parseInt((screen.height-h)/2);
	var l=parseInt((screen.width-w)/2);
	var win = window.open(url,'helpPopup','width='+w+',height='+h+',top='+t+',left='+l+',toolbar=no,location=yes,status=no,menubar=no,scrollbars=yes,resizable=yes'); 
}
function printWin(url)
{
	var h=600;
	var w=800;
	var t=parseInt((screen.height-h)/2);
	var l=parseInt((screen.width-w)/2);
	var win = window.open(url,'helpPopup','width='+w+',height='+h+',top='+t+',left='+l+',toolbar=no,location=yes,status=no,menubar=yes,scrollbars=yes,resizable=yes'); 
}
function setStates(country,state,region,label)
{
	if (country=='' || country==usci) {
		if(country == '') $('#'+state).val('');
		$('#'+state).show();
		$('#'+region).hide();
		$('#'+label).html('State:');
	} else {
		$('#'+state).hide();
		$('#'+region).show();
		$('#'+label).html('State/Province/Region:');
	}
}
function cleanInput(input)
{
	return(input.replace(/[<>\\\\{\}]/g, ''));
}
