var mydialog={
	alert_div:function(width,height,title,loadUrl,datamap,callback){
		this.shadow();
		var width_div = width;
		var x= $(window).width();
		var div_top_x = (x-width)/2;
		var scrolly ; 
		if (document.documentElement && document.documentElement.scrollTop) {
		
		scrolly = document.documentElement.scrollTop;
		}else{
		scrolly = document.body.scrollTop;
		} 
		var div_top_y = 200+scrolly;
		if($("#show").length>0){
		}else{
			var showDiv = document.createElement("div");
			$(showDiv).attr("id","show");
			$(showDiv).css({display:"none"});
			var barDiv = document.createElement("div");
			$(barDiv).attr("id","bar");
			var titleDiv = document.createElement("div");
			$(titleDiv).attr("id","title");
			titleDiv.appendChild(document.createTextNode(title));
			var closeDiv = document.createElement("div");
			$(closeDiv).attr("id","closeLink");
			var closeLink = document.createElement("a");
			$(closeLink).attr("href","javascript:void(0);");
			$(closeLink).click(mydialog.close_div);
			closeLink.appendChild(document.createTextNode("关闭X"));
			closeDiv.appendChild(closeLink);
			barDiv.appendChild(titleDiv);
			barDiv.appendChild(closeDiv);
			var cttDiv = document.createElement("div");
			$(cttDiv).attr("id","showContent");
			showDiv.appendChild(barDiv);
			showDiv.appendChild(cttDiv);
			document.body.appendChild(showDiv);
			//var str_div = "<div id=\"show\" style=\"display:none;\"><div id=\"bar\"><div id=\"title\">"+title+"</div><div id=\"closeLink\"><a href=\"javascript:void(0);\" onclick=\"javascript:mydialog.close_div();\">关闭x</a></div></div><div id=\"showContent\"></div></div>";
			//$("body").append(str_div);
		}
		$("#show").css(
			{top:div_top_y+"px",
			left:div_top_x+"px",
			width:width,
			height:height
			}
		);
		$("#show").show();
		$("#showContent").load(loadUrl,datamap,callback);
	},
	shadow:function(){
		if($("#shadow").length>0){
			
		}else{
			var str_shadow = "<div id=\"shadow\" ></div>";
			$("body").append(str_shadow);
		}
			$("#shadow").width($(document).width());
			$("#shadow").height($(document).height());
			$("#shadow").fadeTo("fast",0.2);
			$("#shadow").show();
	},
	close_div:function(){
		$("#shadow").hide();
		$("#showContent").empty();
		$("#show").hide();
	}
};

function prepareForm(formId,rules,messages,itarget){
	var v = $("#" + formId).validate({
		rules:rules,
		messages:messages,
        submitHandler:function() {
            $("#"+formId).ajaxSubmit({
                target:itarget
            });
        }
    });
}


