var dialogFirst=true;
var content_array=new Array;
var jq = jQuery.noConflict(); 
var closebox=function(){
  jq("#floatBoxBg").hide();
  jq("#floatBox .content").empty();
  jq("#floatBox").hide();
}

function dialog(title,content,width,height,cssName){

if(dialogFirst==true){
  var temp_float=new String;
  temp_float="<div id=\"floatBoxBg\" style=\"height:"+jq(document).height()+"px;\"></div>";
  temp_float+="<div id=\"floatBox\" class=\"floatBox\">";
  temp_float+="<div class=\"title\"><h4></h4><span onclick=\"closebox();\">关闭</span></div>";
  temp_float+="<div class=\"content\"></div>";
  temp_float+="</div>";
  jq("body").append(temp_float);
  dialogFirst=false;
}

jq("#floatBox .title h4").html(title);
contentType=content.substring(0,content.indexOf(":"));
content=content.substring(content.indexOf(":")+1,content.length);
switch(contentType){
  case "url":
  content_array=content.split("?");
  jq.ajax({
    type:content_array[0],
    url:content_array[1],
    data:content_array[2],
	error:function(){
	  jq("#floatBox .content").html("error...");
	},
    success:function(html){
      jq("#floatBox .content").html(html);
    }
  });
  break;
  case "text":
  jq("#floatBox .content").html("<p>"+content+"</p><div><button onclick=\"closebox();\">关闭</button></div>");
  break;
  case "id":
  jq("#floatBox .content").html(jq("#"+content+"").html());
  break;
  case "iframe":
  jq("#floatBox .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
}

jq("#floatBoxBg").show();
jq("#floatBox").attr("class","floatBox "+cssName);
jq("#floatBox").css({display:"block",left:((jq(document).width())/2-(parseInt(width)/2))+"px",top:(jq(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px",width:width,height:height});
jq("#floatBox").animate({top:(jq(document).scrollTop()+50)+"px"},"normal"); 
}

