// Lee dialog 1.0 http://www.xij.cn/blog/?p=68

var innerDialogFirst=true;
function ShowSpiritMessage(title,msg,width)
{
	if(innerDialogFirst==true){
  var temp_innerDialog=new String;

	temp_innerDialog="<div  style=\"display:None\" id=\"InnerDialog\">";
	temp_innerDialog=temp_innerDialog+"<div id=\"Title\" style=\"height:20px;padding:2px;font-size:16px;text-align:center;\"><span style=\"float:right;font-size:12px;\"><a style=\"color:#ffffff;\"  href=\"javascript:CloseInnerDialog();\">[关闭]</a></span>提&nbsp;示</div>";
	temp_innerDialog=temp_innerDialog+"<div id=\"MessageContent\" style=\"height:100px;font-size:18px;padding:10px;text-align:center;\">sadsadsad</div>";
	temp_innerDialog=temp_innerDialog+"<div  style=\"padding:5px;padding-bottom:20px;text-align:center;\"><a class=\"button3\" href=\"javascript:CloseInnerDialog();\">[关闭]</a></div>";
	temp_innerDialog=temp_innerDialog+"</div>";
  $("body").prepend(temp_innerDialog);
  temp_innerDialog=false;
}

	width=300;
	$("#MessageContent").html(msg);
	$("#InnerDialog").fadeIn();
	$("#InnerDialog").css({display:"block",left:(($(document).width())/2-(parseInt(width)/2))+"px",top:50+($(document).scrollTop())+"px",width:width});
	setTimeout("CloseInnerDialog()", 1000);
}

function CloseInnerDialog()
{
	$("#InnerDialog").fadeOut("slow");
}


var innerwindowFirst=true;
function openinnerwindowex(url, width, height,feature) 
{
	if(innerwindowFirst==true)
	{
	var temp_window=new String;


	temp_window="<div  style=\"display:None;\" id=\"InnerWindow\">";
	temp_window=temp_window+"<div id=\"Title\" ><div style=\"float:right;width:100px;\" align=right ><a href=\"javascript:CloseInnerWindow();\" style=\"color:#ffffff;\">[关闭]</a></div><div  style=\"color:#ffffff;\" id=\"InnerWindowTitle\"></div></div>";
	temp_window=temp_window+"<div>";		
	temp_window=temp_window+"<iframe id=\"InnerFrame\" scrolling=\"auto\" width=\"100%\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>";
	temp_window=temp_window+"</div>";
	temp_window=temp_window+"</div>";
	 $("body").append(temp_window);
	innerwindowFirst=false;
	}

	
	if(feature.indexOf("scrollbars=no",0)>-1)
		$("#InnerFrame").attr("scrolling","no");
	
	$("#InnerWindow").fadeIn("slow");
	//$("#InnerWindow").attr("width",width);
	//$("#InnerWindow").attr("height",height);
	$("#InnerWindow").css({display:"block",left:(($(window).width())/2-(parseInt(width)/2))+($(document).scrollLeft())+"px",top:5+($(document).scrollTop())+"px",width:width,height:height});

	
	$("#InnerFrame").attr("src",url);
	$("#InnerFrame").attr("height",height);
	$("#InnerWindow").draggable();	
}

function CloseInnerWindow()
{
	$("#InnerFrame").attr("src","");
	$("#InnerWindow").fadeOut("slow");
}

function SetInnerWindowTitle(title)
{
	if(title==null)
		title="&nbsp;";
		
	if(title=="")
		title="&nbsp;";
		
	$("#InnerWindowTitle").html(title);
}


var dialogFirst=true;
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;filter:alpha(opacity=0);opacity:0;\"></div>";
  temp_float+="<div id=\"floatBox\" class=\"floatBox\">";
  temp_float+="<div class=\"title\"><h4></h4><span>关闭</span></div>";
  temp_float+="<div class=\"content\"></div>";
  temp_float+="<div class=\"footer\" style=\"text-align:center;\"><span class=\"button3\">关闭</span></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 .footer 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"); 
}