/*
调用方 法dialog(title,content,width,height,cssName);
1 	    title 	弹出层的标题 	必填，纯文本
2 	    content 弹出层的内容 	:url get或post某一页面里的html，该页面要求只包含body的子标签:text 	直接写入内容:id 	显示页面里某id的子标签:iframe 	层内内容以框架显示
3 	    width 	弹出层的宽 	必填，css值，比如"200px"
4 	    height 	弹出层的高 	如上，但是可用"auto"
5 	    cssName 	弹出层的css 	给id floatBox加入的样式名，层内样式可以通过这个样式名来定制
*/
var dialogIndexFirst=true;
var contentIndexFrom = "";
function dialogIndex(title,content,width,height,cssName){

	if(dialogIndexFirst==true){
	  var temp_float=new String;
	//  temp_float="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
	  temp_float="<div id=\"floatBoxBg\"></div>";
	  temp_float+="<div id=\"floatBox\" style=\"width:546px; background:url(/images/gonghui/gonghui_tck5.gif) no-repeat top left; text-align:center;\" id=\"createUnionFloat\" name=\"createUnionFloat\">";
	  temp_float+="<div class=\"content\"></div>";
	  temp_float+="</div>";
	  $("body").append(temp_float);
	  dialogIndexFirst=false;
	}

	$("#floatBoxBg").click(function(){

		if(contentType == "id")
		{
			$("#"+content+"").html(contentIndexFrom);
		}
	    hideIndexDialog();

	});


	$("#floatBox .title span.left").html(title);
	contentType=content.substring(0,content.indexOf(":"));
	content=content.substring(content.indexOf(":")+1,content.length);
	
	switch(contentType){
	  case "url":
		  var content_array=content.split("?");
/*
		  $("#floatBox .content").ajaxStart(function(){
			//$(this).html("<img src='./images/loading.gif' /><br><br>");
		  });*/
		  $.ajax({
			type:content_array[0],
			url:content_array[1],
			data:content_array[2],
			error:function(){
			  $("#floatBox .content").html("<img src='./images/loading.gif' /><br><br>");
			},
			success:function(html){
			  $("#floatBox .content").html(html);
			}
		  });
	  break;
	  case "text":
	   //var strHtml = "<table class='pop_info2'><tbody><tr><td colspan='2' align='left'>"+content+"</td></tr></tbody></table>";
		$("#floatBox .content").html(content);
	  break;
	  case "id":
		  $("#floatBox .content").html($("#"+content+"").html());
		  contentIndexFrom = $("#"+content+"").html();
		  $("#"+content+"").html("");
	  break;
	  case "iframe":
		$("#floatBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
	   break;
	}

	$("#floatBoxBg").show();
	$("#floatBoxBg").css({display:"block",height:$(document).height()});
	$("#floatBox").removeClass();
	$("#floatBox").attr("class","floatBox "+cssName);
	$("#floatBox").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:($(document).scrollTop()+150)+"px",width:width,height:height});
}


function hideIndexDialog(){
	 $("#floatBoxBg").hide();
	 $("#floatBox").hide();

}
