// Lee dialog 1.0 http://www.xij.cn/blog/?p=68

var dialogFirst=true;

function test1(){
	__$$("#floatBoxBg").hide();
	__$$("#floatBox").hide();
}

function dialog(title,content,width,height,cssName){

if(dialogFirst==true){
  var temp_float=new String;
  temp_float="<div id=\"floatBoxBg\"  style=\"height:"+__$$(document).height()+"px;Z-index:99998;filter:alpha(opacity=0);opacity:0;\"></div>";
  temp_float+="<div id=\"floatBox\" class=\"floatBox\"  style=\"Z-index:99999;\">";
  temp_float+="<div class=\"title\"><h4></h4><span style='font-size:14px; font-weight:bold; font-family:arial'>&nbsp;&nbsp;X&nbsp;&nbsp;</span></div>";
  temp_float+="<div class=\"content\"></div>";
  temp_float+="</div>";
  __$$("body").append(temp_float);
  dialogFirst=false;
}

__$$("#floatBox .title span").click(function(){
  __$$("#floatBoxBg").animate({opacity:"0"},"normal",function(){__$$(this).hide();});
  __$$("#floatBox").animate({top:(__$$(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){__$$(this).hide();}); 
});

__$$("#floatBox .title h4").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("loading...");
  });
  __$$.ajax({
    type:content_array[0],
    url:content_array[1],
    data:content_array[2],
	error:function(){
	  __$$("#floatBox .content").html("error...");
	},
    success:function(html){
      __$$("#floatBox .content").html(html);
    }
  });
  break;
  case "text":
  __$$("#floatBox .content").html(content);
  break;
  case "id":
  __$$("#floatBox .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>");
}

__$$("#floatBoxBg").show();
__$$("#floatBoxBg").animate({opacity:"0.5"},"normal");
__$$("#floatBox").attr("class","floatBox "+cssName);
__$$("#floatBox").css({display:"block",left:((__$$(document).width())/2-(parseInt(width)/2))+"px",top:(__$$(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px",width:width,height:height});
__$$("#floatBox").animate({top:(__$$(document).scrollTop()+50)+"px"},"normal"); 

}