var defID="0";
var defaultNavID="0";
function navHover(id){
	if(id != defID)
	{
		$("#nav_"+defID).removeClass("hovera");
		$("#nav_"+id).addClass("hovera");
		defID=id;
	}
}
function setDefaultNav(id)
{
	defaultNavID=id;
	navHover(id);
}
//调整字体大小
function ChangeFontSize(id,size)
{
    $('#' + id+" p,td").css("font-size", size + 'px');
}

function GetSearch(id)
{
	var key=$("#"+id).val();
	if(key =="" || key=="Search" || key=="search")
	{
		alert("请输入搜索关键字！");
		$("#"+id).focus();
		return false;
	}
	else
	{
		window.location.href='/Search.aspx?key='+escape(key);
		return false;
	}
}
//刷新验证码
function ChangeValidateCode()
{
	$('#validatecode').attr( 'src','/images/common/validatecode.aspx?rnd=' + Math.random());
}

function ImgPreview() {
	$('.ulProductList li p img').imgPreview({
		containerID: 'imgPreviewWithStyles',
		imgCSS: {
			// Limit preview size:
			height: 200
		},
		// When container is shown:
		onShow: function(link){
			// Animate link:
			$(link).stop().animate({opacity:0.4});
			// Reset image:
			$('img', this).stop().css({opacity:0});
		},
		// When image has loaded:
		onLoad: function(){
			// Animate image
			$(this).animate({opacity:1}, 300);
		},
		// When container hides: 
		onHide: function(link){
			// Animate link:
			$(link).stop().animate({opacity:1});
		}
	});
}
	function Imgvalign(panel,h) {
	    $(panel + " li img").each(function (i) {
	        var imgw = $(this).width();
	        var imgh = $(this).height();
	        if (imgw < imgh) {
	            $(this).css("height", h + "px");
	            $(this).css("width", imgw * imgw / imgh + "px");

	        } else {
	            var margintop = (h - $(this).height()) / 2;
	            if (margintop < 0) {
	                margintop = 0;
	            }
	            $(this).css("margin-top", margintop + "px");
	        }
	    });
	}

	function slideSwitch() {
	    var $current = $("#slideshow div.current");

	    // 判断div.current个数为0的时候 $current的取值
	    if ($current.length == 0) $current = $("#slideshow div:last");

	    // 判断div.current存在时则匹配$current.next(),否则转到第一个div
	    var $next = $current.next().length ? $current.next() : $("#slideshow div:first");
	    $current.addClass('prev');

	    $next.css({ opacity: 0.0 }).addClass("current").animate({ opacity: 1.0 }, 1000, function () {
	        //因为原理是层叠,删除类,让z-index的值只放在轮转到的div.current,从而最前端显示
	        $current.removeClass("current prev");
	    });
	}
