(function($){
	$.fn.extend({
	        Scroll:function(opt,callback){
	                //参数初始化
	                if(!opt) var opt={};
	                var _btnUp = $("#"+ opt.up);//Shawphy:向上按钮
	                var _btnDown = $("#"+ opt.down);//Shawphy:向下按钮
	                var timerID;
	                var _this=this.eq(0).find("ul:first");
	                var     lineH=_this.find("li:first").height(), //获取行高
	                        line=opt.line?parseInt(opt.line,10):parseInt(this.height()/lineH,10), //每次滚动的行数，默认为一屏，即父容器高度
	                        speed=opt.speed?parseInt(opt.speed,10):500; //卷动速度，数值越大，速度越慢（毫秒）
	                        timer=opt.timer; //?parseInt(opt.timer,10):3000; //滚动的时间间隔（毫秒）
	                if(line==0) line=1;
	                var upHeight=0-line*lineH;
	                //滚动函数
	                var scrollUp=function(){
	                        _btnUp.unbind("click",scrollUp); //Shawphy:取消向上按钮的函数绑定
	                        _this.animate({
	                                marginTop:upHeight
	                        },speed,function(){
	                                for(i=1;i<=line;i++){
	                                        _this.find("li:first").appendTo(_this);
	                                }
	                                _this.css({marginTop:0});
	                                _btnUp.bind("click",scrollUp); //Shawphy:绑定向上按钮的点击事件
	                        });
	                }
	                //Shawphy:向下翻页函数
	                var scrollDown=function(){
	                        _btnDown.unbind("click",scrollDown);
	                        for(i=1;i<=line;i++){
	                                _this.find("li:last").show().prependTo(_this);
	                        }
	                        _this.css({marginTop:upHeight});
	                        _this.animate({
	                                marginTop:0
	                        },speed,function(){
	                                _btnDown.bind("click",scrollDown);
	                        });
	                }
	               //Shawphy:自动播放
	                var autoPlay = function(){
	                        if(timer)timerID = window.setInterval(scrollUp,timer);
	                };
	                var autoStop = function(){
	                        if(timer)window.clearInterval(timerID);
	                };
	                 //鼠标事件绑定
	                _this.hover(autoStop,autoPlay).mouseout();
	                _btnUp.css("cursor","pointer").click( scrollUp ).hover(autoStop,autoPlay);//Shawphy:向上向下鼠标事件绑定
	                _btnDown.css("cursor","pointer").click( scrollDown ).hover(autoStop,autoPlay);

	        }       
	});
})(jQuery);


function resizeimg(ImgD,iwidth,iheight) { 
	var image=new Image(); 
	image.src=ImgD.src; 
	if(image.width>0 && image.height>0){ 
		if(image.width/image.height>= iwidth/iheight){ 
			if(image.width>iwidth){
			ImgD.width=iwidth; 
			ImgD.height=(image.height*iwidth)/image.width; 
			}else{
			ImgD.width=image.width; 
			ImgD.height=image.height; 
			} 
			ImgD.alt=image.width+"×"+image.height; 
		} 
		else{ 
			if(image.height>iheight){ 
				ImgD.height=iheight; 
				ImgD.width=(image.width*iheight)/image.height; 
			}else{ 
				ImgD.width=image.width; 
				ImgD.height=image.height;
			}
			ImgD.alt=image.width+"×"+image.height; 
		}
		ImgD.style.marginTop=(iheight-ImgD.height)/2 + 'px';
		ImgD.style.marginLeft=(iwidth-ImgD.width)/2 + 'px';
		//ImgD.style.cursor= "pointer"; //改变鼠标指针 
		//ImgD.onclick = function() { window.open(this.src);}//点击打开大图片 
//		if (navigator.userAgent.toLowerCase().indexOf("ie") > -1) { //判断浏览器，如果是IE 
//			ImgD.title = "请使用鼠标滚轮缩放图片，点击图片可在新窗口打开"; 
//			ImgD.onmousewheel = function img_zoom() //滚轮缩放 
//			{
//				var zoom = parseInt(this.style.zoom, 10) || 100; 
//				zoom += event.wheelDelta / 12; 
//				if (zoom> 0)this.style.zoom = zoom + "%"; 
//					return false; 
//			 }
//		 } else { //如果不是IE 
//			ImgD.title = "点击图片可在新窗口打开"; 
//		} 
	}
}

/*
计算时间差
*/

Date.prototype.diff=function (date)
{

	var y=date-this,x=Math.abs(y),d,h,m,s;

	d=parseInt(x/86400000);
	x%=86400000;
	h=parseInt(x/3600000)
	x%=3600000;
	m=parseInt(x/60000);
	x%=60000;
	s=parseInt(x/1000);

	return {
		text:(d+'天0'+h+'小时0'+m+'分0'+s+'秒').replace(/0(\d\d)/g,'$1')
		,value:y
	};

}

/*
计时器类
*/

timer=function (from,shower)
{

	var T=document.getElementById(from).value;
	T=new Date(T.replace(/-/g,'/'));
	var P=document.getElementById(shower);
	(function ()
	{
		var diff=new Date().diff(T);
		if(diff.value<0){
			P.innerHTML="<span class=\"dkblueText tb\">已经结束</span>";
			//return //alert('end!')
		}
		else{
			P.innerHTML=diff.text;
		}
		setTimeout(arguments.callee,1000);
	})();
};
function showInfo(infostr,nexturl){
	/*
	//document.write('<div id="sysInfoDialog" class="dialogCtn" title="系统提示">'+infostr+'</div>');
	var d=document.createElement("div") ; // 创建对象，下面就是设置属性了
	d.id="sysInfoDialog";
	d.title="系统提示";
	document.body.appendChild(d);
	$("#sysInfoDialog").html(infostr);
		
	$("#sysInfoDialog").dialog({
		height: 200,
		width:400,
		bgiframe: true,
		modal: true,
		autoOpen: false,
		resizable: false,
		buttons:{
			'确认':function(){
				$(this).dialog('close');
				if (nexturl!='')
					window.location.href=nexturl;
			}
		}
	});
	$("#sysInfoDialog").dialog('open');
	*/
	var d=document.createElement("div") ; // 创建对象，下面就是设置属性了
	d.id="sysInfoDialog";
	d.title="系统提示";
	document.body.appendChild(d);
	$("#sysInfoDialog").html(infostr);
	var p={
		content_id:"sysInfoDialog",
		title:'系统提示',
		width:400,
		height:200,
		buttons:{
			button1:{
				name:'确定',
				action:function(){
					sysInfoDialog.close_dialog();
					if (typeof(nexturl)!="undefined"&&nexturl!='')
						window.location.href=nexturl;
				}
			}
		}
	};
	var sysInfoDialog=new YY_dialog(p);
	sysInfoDialog.show_dialog();
}

$(document).ready(function(){
	//数量输入框基础校验
	$(".numericInput").keydown(function(e){
		var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
		if(!(keyCode==46)&&!(keyCode==8)&&!(keyCode==9)&&!(keyCode==37)&&!(keyCode==39))
			if(!((keyCode>=48&&keyCode<=57)||(keyCode>=96&&keyCode<=105)))
			 return false;
	});
	//金额输入框基础校验
	$(".moneyInput").keydown(function(e){
		var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
		if(!((keyCode>=   48&&keyCode   <=   57)||(keyCode==9)||(keyCode>=96&&keyCode<=105)||(keyCode==8)||(keyCode   ==   110)||(keyCode   ==   190)||(keyCode   ==   0xD)))
			return false;
		string=this.value;
		var strlength = string.length;
		var dotindex = string.indexOf('.');
		if(dotindex!=-1)
		{
			var afterdotstring = string.substring(dotindex+1,strlength);
			if (afterdotstring.length>=2){
				this.value=string.substring(0,dotindex+3);
			}
		}
		if(dotindex==0){
			this.value='';
		}
	}).blur(function(event){
		string=this.value;
		var strlength = string.length;
		var dotindex = string.indexOf('.');
		if(dotindex!=-1)
		{
			var afterdotstring = string.substring(dotindex+1,strlength);
			if (afterdotstring.length>=2){
				this.value=string.substring(0,dotindex+3);
			}
		}
		if(dotindex==0){
			this.value='';
		}
	});
	$(".titleInput").keydown(function(e){
//		var keyCode = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
//		if(keyCode==32)
//			return false;
	});
//	$('#searchValue').click(function(){
//		if ($('#searchValue').attr('value')=='请输入查询关键字'){
//			$('#searchValue').attr('value','');
//		}
//	});
//	$('#searchValue').blur(function(){
//		if ($('#searchValue').attr('value')==''){
//			$('#searchValue').attr('value','请输入查询关键字');
//		}
//	});
	$(".QQTalk").each(function(key, val) {
		$(this).html('<img class=\"QQImg\" border=\"0\" src=\"http://wpa.qq.com/pa?p=1:'+$(this).attr('qqid')+':1\" alt=\"请先添加好友\">');
		$(this).click(function(){window.location.href='tencent://message/?Menu=yes&uin='+$(this).attr('qqid')+'&Site=汉正街电子商务平台&Service=200&sigT=2a0e37386280486ada2b5d5e69ee49186ccae1257fd9e1c9598af1f0b9c916067002a57aaaec8c8d';});
	});
	$(".flashWord").each(function(key, val) {
		id=$(this).attr("id");
		setInterval("flashWord('"+id+"')",500);
	});
	$(".hotProductListCtn .saleProduct").each(function(key, val) {
		$(this).attr("width",'173');
		$(this).attr("height",'173');
	});
	$(".page").mouseover(function() {
		$(this).addClass("pageBg");
	});
	$(".page").mouseout(function() {
		$(this).removeClass("pageBg");
	});
	rowcount=0;
	$(".hzjTableSorterCtn table tbody tr").each(function(key, val) {
		if (rowcount%2==1)$(this).addClass('rowGap');
		rowcount++;
	});
	$(".hzjTableSorterCtn table thead tr th").click(function(){
		if($(this).children().attr('href')!=undefined)
			window.location.href=$(this).children().attr('href');
	});
	$("#searchTypeCtn .searchTypeTab").click(function(){
		$("#searchTypeCtn .searchTypeTab").each(function(key, val) {
			$(this).removeClass("cuteBg");
			$(this).removeClass("tb");
		});
		$("#searchTypeCtn").attr('class','');
		$("#searchTypeCtn").addClass('searchTypeTab'+$(this).attr('tabId'));
		$("#searchType").val($(this).attr('searchType'));
		$(this).addClass('cuteBg');
		$(this).addClass('tb');
	});
	$("#stepHelpTabCtn .tab").mouseover(function(){
		$("#stepHelpTabCtn").attr('class','cuteBg');
		$("#stepHelpTabCtn").addClass('stepHelpTabCtn'+$(this).attr('tabId'));
		$("#stepHelpContentCtn .tabContent").each(function(key, val) {
			$(this).hide();
		});
		$("#tabContent"+$(this).attr('tabId')).show();
	});
	var HZJCookies=document.cookie.split("; ");
	showAd1=true;
	for (var i=0;i<HZJCookies.length;i++){
		if (HZJCookies[i].indexOf("HZJad1=true")!=-1)showAd1=false;
	}
	if (showAd1){
		slideShow("ad1",'show');
		var when=new Date();
		when.setTime(when.getTime()+15*60*1000);
		document.cookie="HZJad1=true"+";expires="+when.toGMTString();
	}
	setTimeout('slideShow("ad1")',5000);
	//setTimeout("$('#ad1').hide();",10000);
});
function flashWord(obj){
	if($("#"+obj).hasClass("goldText"))
		$("#"+obj).removeClass("goldText");
	else
		$("#"+obj).addClass("goldText");
}
/**
 * 配置前台推荐品牌
 * @return
 */
function showbrand(){
	$.ajax( {
		type : 'post',
		url : '/brand/brand',
		dataType : 'json',
		data : "id=" + '' + "&order=" + '',
//		error : function() {
//			alert('系统错误，请稍后重试或与管理员联系！');
//		},
		success : function(json) {
			var html = '';
			var count = 0;
			$.each(json.resultdata,function(entryIndex, entry) {
					if(count == 4 || count == 7){
						html +='<div class="photoBoxbrand" style="float: left;"><a href="/brand/showdetail/brandid/'+entry['id']+'"><img src="'+ entry['logopath'] +'"/></a></div>';
					}else{
						html +='<div class="photoBoxbrand" style="float: left;"><a href="/brand/showdetail/brandid/'+entry['id']+'"><img src="'+ entry['logopath'] +'"/></a></div>';
					}
				count++;
			});	
			$("#brands").html(html);
			photobrand();
		}
	});
}

function photobrand(){
	$(".photoBoxbrand img").each(function(){
		resizeimg(this,98,40);
	});
}
function slideShow(id,work){
	if (id==undefined||!$('#'+id))return ;
	if (work==undefined||work=='hide'){
		ad1HideInterval=setInterval('this.hide()',10);
	}else{
		adHeight=$('#'+id).height();
		$('#'+id).height(0);
		$('#'+id).show();
		ad1ShowInterval=setInterval('this.show()',10);
	}
	this.show=function (){
		if ($('#'+id).height()<=adHeight){
			$('#'+id).height($('#'+id).height()+15);
		}else{
			$('#'+id).height(adHeight);
			clearInterval(ad1ShowInterval);
		}
	};
	this.hide=function (){
		if ($('#'+id).height()>=15){
			$('#'+id).height($('#'+id).height()-15);
		}else{
			$('#'+id).hide();
			clearInterval(ad1HideInterval);
		}
	};
}

function YY_dialog(params){
	this.dialog_width=400;
	this.dialog_height=300;
	this.draggable=true;
	this.content_id=null;
	this.random_char=function(l)  {
		var  x="0123456789qwertyuioplkjhgfdsazxcvbnm";
		var  tmp="";
		for(var  i=0;i<  l;i++)  {
			tmp  +=  x.charAt(Math.ceil(Math.random()*100000000)%x.length);
		}
		return  tmp;
	};
	get_width=function (){
		var scrollLeft = document.documentElement.scrollLeft + document.body.scrollLeft; 
		return (document.documentElement.clientWidth+scrollLeft);
	};
	get_height=function (){
		var scrollTop = document.documentElement.scrollTop + document.body.scrollTop; 
	   return (document.documentElement.clientHeight+scrollTop);
	};
	this.config=function(params){
		if (typeof(params)=="object"){
			if (typeof(params.content_id)!='undefined'&&params.content_id!=''){
				this.content_id=params.content_id;
				this.dialog_id="YY_dialog_ctn_"+params.content_id;
				this.dialog_bg_id="YY_dialog_bg_"+params.content_id;
			}else{
				random_content_id=this.random_char(5);
				this.content_id=random_content_id;
				this.dialog_id="YY_dialog_ctn_"+random_content_id;
				this.dialog_bg_id="YY_dialog_bg_"+random_content_id;
			}
			if (typeof(params.width)!='undefined'&&params.width!='')this.dialog_width=params.width;
			if (typeof(params.height)!='undefined'&&params.height!='')this.dialog_height=params.height;
			if (typeof(params.buttons)!='undefined'&&params.buttons!='')this.YY_dialog_buttons=params.buttons;
			if (typeof(params.draggable)!='undefined'&&params.draggable==false)this.draggable=false;
			if (typeof(params.close)!='undefined'&&params.close!='')this.close=params.close;
		}
	};
	this.create_dialog=function (){
		var YY_dialog_layer = document.createElement("div");//对话框
		YY_dialog_layer.id = "YY_dialog_ctn_"+this.content_id;
		YY_dialog_layer.style.position = "absolute";
		YY_dialog_layer.style.background = "#fff";
		YY_dialog_layer.style.width = this.dialog_width+"px";
		YY_dialog_layer.style.height = this.dialog_height+"px";
		YY_dialog_layer.style.zIndex = 102;
		YY_dialog_layer.style.display = 'none';
		YY_dialog_layer.style.top = Math.floor((get_height()-this.dialog_height)/2)<5?5:Math.floor((get_height()-this.dialog_height)/2)+'px';
		YY_dialog_layer.style.left = Math.floor((get_width()-this.dialog_width)/2)<5?5:Math.floor((get_width()-this.dialog_width)/2)+'px';
		var YY_dialog_title_ctn_layer = document.createElement("div");//标题栏
		YY_dialog_title_ctn_layer.id = "YY_dialog_title_ctn_"+this.content_id;
		YY_dialog_title_ctn_layer.style.width=this.dialog_width+"px";
		YY_dialog_title_ctn_layer.style.height =25+"px";
		YY_dialog_title_ctn_layer.style.background = "#ffa32f";
		if (this.draggable){
			YY_dialog_title_ctn_layer.style.cursor="move";
			YY_dialog_title_ctn_layer.onmousedown = down;
		}
		YY_dialog_title_ctn_layer.dialog_id = this.content_id;
		YY_dialog_title_ctn_layer.onselectstart=new Function("return false");
		var YY_dialog_title_layer = document.createElement("div");//标题
		YY_dialog_title_layer.id = "YY_dialog_title_"+this.content_id;
		if (typeof(params.title)!='undefined'&&params.title!='')YY_dialog_title_layer.innerHTML=params.title;
		YY_dialog_title_layer.style.lineHeight=25+"px";
		YY_dialog_title_layer.style.fontSize=14+"px";
		YY_dialog_title_layer.style.fontWeight=700;
		YY_dialog_title_layer.style.color="#fff";
		YY_dialog_title_layer.style.paddingLeft=10+"px";
		YY_dialog_title_layer.style.styleFloat="left";
		YY_dialog_title_layer.style.cssFloat="left";
		YY_dialog_title_layer.onselectstart=new Function("return false");
		YY_dialog_title_layer.style.height =25+"px";
		
		var YY_dialog_close_layer = document.createElement("div");//x按钮
		YY_dialog_close_layer.id = "YY_dialog_close_"+this.content_id;
		YY_dialog_close_layer.onclick = this.close_dialog;
		YY_dialog_close_layer.content_id=this.content_id;//关闭对话框时使用
		if (typeof(this.close)=='function')YY_dialog_close_layer.close=this.close;//关闭对话框时使用
		YY_dialog_close_layer.onmouseover=new Function('this.style.backgroundPosition="-25px -80px"');
		YY_dialog_close_layer.onmouseout=new Function('this.style.backgroundPosition="-25px -96px"');
		YY_dialog_close_layer.style.width=26+"px";
		YY_dialog_close_layer.style.height =15+"px";
		YY_dialog_close_layer.style.background='url("/images/pages/bgCuteSweet.gif")';
		YY_dialog_close_layer.style.styleFloat="right";
		YY_dialog_close_layer.style.cssFloat="right";
		YY_dialog_close_layer.style.margin="0 5px 0 0";
		YY_dialog_close_layer.style.cursor="pointer";
		YY_dialog_close_layer.style.backgroundPosition="-25px -80px";
		
		YY_dialog_title_ctn_layer.appendChild(YY_dialog_title_layer);
		YY_dialog_title_ctn_layer.appendChild(YY_dialog_close_layer);
		
		YY_dialog_layer.appendChild(YY_dialog_title_ctn_layer);
		
		var YY_dialog_content_layer = document.createElement("div");//对话框内容
		YY_dialog_content_layer.id = "YY_dialog_content_"+this.content_id;
		YY_dialog_content_layer.style.background = "#fff";
		YY_dialog_content_layer.style.overflow = "auto";
		YY_dialog_content_layer.style.padding = 5+"px";
		YY_dialog_content_layer.style.height = this.dialog_height-80+"px";
		if (typeof(params.buttons)=="object"){
			YY_dialog_content_layer.style.height = this.dialog_height-80+"px";
		}else{
			YY_dialog_content_layer.style.height = this.dialog_height-35+"px";
		}
		YY_dialog_layer.appendChild(YY_dialog_content_layer);

		if (typeof(params.buttons)=="object"){
			var YY_dialog_action_ctn_layer = document.createElement("div");//对话框操作区
			YY_dialog_action_ctn_layer.id = "YY_dialog_action_ctn_"+this.content_id;
			YY_dialog_action_ctn_layer.style.background = "#e8e8e8";
			YY_dialog_action_ctn_layer.style.width = this.dialog_width+"px";
			YY_dialog_action_ctn_layer.style.height = 45+"px";
			
			for (s in params.buttons){
 				if (params.buttons[s].name!=''&&params.buttons[s].action!=null){
					var YY_dialog_btn_layer = document.createElement("div");//对话框按钮
 					YY_dialog_btn_layer.id ="YY_dialog_button_"+this.content_id+'_'+s;
 					YY_dialog_btn_layer.innerHTML=params.buttons[s].name;
 					if (params.buttons[s].action=="close")
 	 					YY_dialog_btn_layer.onclick=this.close_dialog;
 					else
 	 					YY_dialog_btn_layer.onclick= params.buttons[s].action;
 					YY_dialog_btn_layer.style.background ='url("/images/pages/bgTab.gif")';
 					YY_dialog_btn_layer.content_id=this.content_id;//关闭对话框时使用
 					YY_dialog_btn_layer.onmouseover=new Function('this.style.backgroundPosition="0px -412px"');
 					YY_dialog_btn_layer.onmouseout=new Function('this.style.backgroundPosition="0px -412px"');
					YY_dialog_btn_layer.style.width = 80+"px";
 					YY_dialog_btn_layer.style.height = 23+"px";
 					YY_dialog_btn_layer.style.border = "1px solid #dc6b00";
 					YY_dialog_btn_layer.style.backgroundPosition="0px -412px";
 					YY_dialog_btn_layer.style.styleFloat="right";
 					YY_dialog_btn_layer.style.cssFloat="right";
 					YY_dialog_btn_layer.style.lineHeight=23+"px";
 					YY_dialog_btn_layer.style.fontSize=14+"px";
 					YY_dialog_btn_layer.style.fontWeight=700;
 					YY_dialog_btn_layer.style.textAlign="center";
 					YY_dialog_btn_layer.style.margin="10px 5px";
 					YY_dialog_btn_layer.style.color="#fff";
 					YY_dialog_btn_layer.style.cursor="pointer";
 	 				YY_dialog_action_ctn_layer.appendChild(YY_dialog_btn_layer);
				}
			}
			YY_dialog_layer.appendChild(YY_dialog_action_ctn_layer);
		}
		document.body.appendChild(YY_dialog_layer);//对话框

		
		if (document.getElementById(this.content_id)!=null){
			document.getElementById(this.content_id).style.display = 'block';
			document.getElementById("YY_dialog_content_"+this.content_id).appendChild(document.getElementById(this.content_id));
		}
		
		var YY_dialog_bg_layer = document.createElement("div");//对话框背景
		YY_dialog_bg_layer.id = "YY_dialog_bg_"+this.content_id;
		YY_dialog_bg_layer.style.border="5px solid #fff";
		YY_dialog_bg_layer.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=50)";//IE的不透明设置
		YY_dialog_bg_layer.style.opacity = 0.5;//Mozilla的不透明设置
		YY_dialog_bg_layer.style.position = "absolute";
		YY_dialog_bg_layer.style.background = "#000";
		YY_dialog_bg_layer.style.width = this.dialog_width+"px";
		YY_dialog_bg_layer.style.height = this.dialog_height+"px";
		YY_dialog_bg_layer.style.zIndex = 101;
		YY_dialog_bg_layer.style.display = 'none';
		YY_dialog_bg_layer.style.top = (Math.floor((get_height()-this.dialog_height)/2)-5)<0?0:(Math.floor((get_height()-this.dialog_height)/2)-5)+'px';
		YY_dialog_bg_layer.style.left = (Math.floor((get_width()-this.dialog_width)/2)-5)<0?0:(Math.floor((get_width()-this.dialog_width)/2)-5)+'px';
		document.body.appendChild(YY_dialog_bg_layer);
		
		if (document.getElementById('YY_mask')==null){
			var maskLayer = document.createElement("div");
			maskLayer.id = "YY_mask";
			maskLayer.style.position = "absolute";
			maskLayer.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=40)";//IE的不透明设置
			maskLayer.style.opacity = 0.4;//Mozilla的不透明设置
			maskLayer.style.background = "#000000";
			maskLayer.style.top = "0px";
			maskLayer.style.left = "0px";
			maskLayer.style.width = get_width()+"px";
			maskLayer.style.height = get_height()+"px";
			maskLayer.style.zIndex = 100;
			maskLayer.style.display = 'none';
			document.body.appendChild(maskLayer);
		}
	};
	this.show_mask=function () {//创建遮罩层的函数
		var YY_mask =  document.getElementById("YY_mask");
		if(YY_mask==null){
			//this.create_mask();
		}else{
			this.show('YY_mask');
		}
	};
	this.show_dialog=function (){
		this.show_mask();
		this.center_dialog();
		this.show("YY_dialog_ctn_"+this.content_id);
		this.show("YY_dialog_bg_"+this.content_id);
		hide_select();
	};
	this.center_dialog=function (){
		var YY_dialog_ctn = document.getElementById("YY_dialog_ctn_"+this.content_id);
		var YY_dialog_bg = document.getElementById("YY_dialog_bg_"+this.content_id);
		var width=get_width();
		var height=get_height();
		YY_dialog_ctn.style.top = Math.floor(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.dialog_height)/2)<5?5:Math.floor(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.dialog_height)/2)+'px';
		YY_dialog_ctn.style.left = Math.floor(document.documentElement.scrollLeft+(document.documentElement.clientWidth-this.dialog_width)/2)<5?5:Math.floor(document.documentElement.scrollLeft+(document.documentElement.clientWidth-this.dialog_width)/2)+'px';
		YY_dialog_bg.style.top = (Math.floor(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.dialog_height)/2)-5)<0?0:(Math.floor(document.documentElement.scrollTop+(document.documentElement.clientHeight-this.dialog_height)/2)-5)+'px';
		YY_dialog_bg.style.left = (Math.floor(document.documentElement.scrollLeft+(document.documentElement.clientWidth-this.dialog_width)/2)-5)<0?0:(Math.floor(document.documentElement.scrollLeft+(document.documentElement.clientWidth-this.dialog_width)/2)-5)+'px';
	};
	this.show=function (ele) {
		if (document.getElementById(ele)!=null)document.getElementById(ele).style.display = 'block';
	};
	this.close_dialog=function() {
		if (typeof(this.close)=='function')this.close();
		if (document.getElementById("YY_dialog_ctn_"+this.content_id)!=null)document.getElementById("YY_dialog_ctn_"+this.content_id).style.display = 'none';
		if (document.getElementById("YY_dialog_bg_"+this.content_id)!=null)document.getElementById("YY_dialog_bg_"+this.content_id).style.display = 'none';
		if (document.getElementById("YY_mask")!=null)document.getElementById("YY_mask").style.display = 'none';
		hide_select(false);
	};
	hide_select=function (action)
	{
		var selects = document.getElementsByTagName("SELECT");
		for(var i = 0 ; i<selects.length;i++)
		{
			if (action==false){
				selects[i].style.display = "inline";
			}else{
				selects[i].style.display = "none";
			}
		}
	};
	down=function (e) {//this=YY_dialog_title_ctn
		var content_id=this.id.slice(this.id.lastIndexOf("_")+1);
		var YY_dialog_ctn = document.getElementById("YY_dialog_ctn_"+content_id);
		var YY_dialog_title_width=parseInt(YY_dialog_ctn.style.width.replace(/px/, ""));
		var YY_dialog_title_height=parseInt(YY_dialog_ctn.style.height.replace(/px/, ""));
		var event = window.event || e;
		if (YY_dialog_ctn.style.top=='')YY_dialog_ctn.style.top=0;
		if (YY_dialog_ctn.style.left=='')YY_dialog_ctn.style.left=0;
		tHeight = event.clientY
				- parseInt(YY_dialog_ctn.style.top.replace(/px/, ""));
		lWidth = event.clientX
				- parseInt(YY_dialog_ctn.style.left.replace(/px/, ""));
		document.onmousemove =function (e) {
			var YY_mask =  document.getElementById("YY_mask");
			
			//更改遮罩层的大小,确保在滚动以及窗口大小改变时还可以覆盖所有的内容
			//if(null==YY_mask)return;
			var all_width=get_width();
			var all_height=get_height();
			YY_mask.style.width=all_width+"px";
			YY_mask.style.height=all_height+"px";
				
			var YY_dialog_ctn = document.getElementById("YY_dialog_ctn_"+content_id);
			var YY_dialog_bg =  document.getElementById("YY_dialog_bg_"+content_id);
			var event = window.event || e;
			var top = event.clientY - tHeight;
			var left = event.clientX - lWidth;
			//判断 top 和 left 是否超出边界
			top = top > all_height - YY_dialog_title_height-5 ? all_height - YY_dialog_title_height-5: top;
			top = top < 5 ? 5 : top;
			left = left > all_width - YY_dialog_title_width-5 ? all_width - YY_dialog_title_width-5: left;
			left = left < 5 ? 5 : left;
			YY_dialog_ctn.style.top = top + "px";
			YY_dialog_ctn.style.left = left + "px";
			YY_dialog_bg.style.top = top-5 + "px";
			YY_dialog_bg.style.left = left-5 + "px";
			//alert(top+'-'+left);
		};
		YY_dialog_ctn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=70)";//IE的不透明设置
		YY_dialog_ctn.style.opacity = 0.7;//Mozilla的不透明设置
		document.onmouseup = function () {
			document.onmousemove = null;
			YY_dialog_ctn.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=4,opacity=100)";//IE的不透明设置
			YY_dialog_ctn.style.opacity = 1;//Mozilla的不透明设置
		};
	};
	re_mask=function (e){
		//更改遮罩层的大小,确保在滚动以及窗口大小改变时还可以覆盖所有的内容//this=window
		var YY_mask =  document.getElementById("YY_mask");
		//if(undefined==YY_mask)return;
		YY_mask.style.width=get_width()+"px";
		YY_mask.style.height=get_height()+"px";
	};
	if (typeof(params)=="object")this.config(params);
	this.create_dialog();
	window.onresize=re_mask;
	window.onscroll=re_mask;
}

