//刷新验证码
function ChangeValidateCode()
{
	$('#validatecode').attr( 'src','/images/common/validatecode.aspx?rnd=' + Math.random());
}
var ishover=false;
function showNav(){
	$('#navUL >li').hover(function(){
		$(this).find(">a").addClass("nav_hover");
		$(this).addClass('hover');
		$(this).find('ul').show();
},function(){
	    $(this).find(">a").removeClass("nav_hover");
		$(this).removeClass('hover');
		$(this).find('ul').hide();
	});
}

//图片自动缩放，居中
function imgAutoCenter(panel, imgMaxWidth, imgMaxHeight) {
	
    $(panel + " img").each(function (i) {
        var imgw = $(this).width();
        var imgh = $(this).height();
		
        //如果比例大于设置的，说明图片比较"长"imgMaxWidth/imgMaxHeight)>(imgw/imgh)
        if ((imgMaxWidth/imgMaxHeight)>(imgw/imgh)) {
            if (imgMaxHeight > imgh) {
                //图片比例小于最大设定，则居中即可
                var margintop = (imgMaxHeight - $(this).height()) / 2;
                if (margintop < 0) {
                    margintop = 0;
                }
                $(this).css("margin-top", margintop + "px");
				$(panel).css("text-align","center");
            } else {
                $(this).css("height", imgMaxHeight + "px");
                $(panel).css("text-align","center");
            }
        } else {
            //图片比较窄,需要缩放到最大宽度
            if (imgMaxWidth > imgw) {
                var margintop = (imgMaxHeight - $(this).height()) / 2;
                if (margintop < 0) {
                    margintop = 0;
                }
                $(this).css("margin-top", margintop + "px");
				$(panel).css("text-align","center");
			   } else {
               
                $(this).css("width", imgMaxWidth + "px");
				$(this).css("margin-top", (imgMaxHeight - $(this).height()) / 2 + "px");
            }
        }
    });
}
var flag=false;
function downShow(){
	if(!flag){
	$('.downTitle').addClass('downTitleClose');
	$('#downshow').show('fast');   
	flag=true;
	}
	else
	{
	$('.downTitle').removeClass('downTitleClose');
	$('#downshow').hide('fast');   
	flag=false;
    } 
}
/**
* 时间对象的格式化;
*/
Date.prototype.format = function(format){
 /*
  * eg:format="YYYY-MM-dd hh:mm:ss";
  */
 var o = {
  "M+" :  this.getMonth()+1,  //month
  "d+" :  this.getDate(),     //day
  "h+" :  this.getHours(),    //hour
  "m+" :  this.getMinutes(),  //minute
  "s+" :  this.getSeconds(), //second
  "q+" :  Math.floor((this.getMonth()+3)/3),  //quarter
  "S"  :  this.getMilliseconds() //millisecond
}
 
   if(/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear()+"").substr(4 - RegExp.$1.length));
   }
 
   for(var k in o) {
    if(new RegExp("("+ k +")").test(format)) {
      format = format.replace(RegExp.$1, RegExp.$1.length==1 ? o[k] : ("00"+ o[k]).substr((""+ o[k]).length));
    }
   }
 return format;
}

