// Lee dialog 1.0 http://www.xij.cn/blog/?p=68

var dialogFirst_ma=true;
var dialogFirst_st=true;
var dialogFirst_si=true;

function dialog(title,content,width,height,cssName)
{
	if(dialogFirst_ma==true){
	  var temp_float=new String;
	  temp_float="<div id=\"floatBoxBg_Ma\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
	  temp_float+="<div id=\"floatBox_Ma\" class=\"floatBox_Ma\">";
	  temp_float+="<div class=\"content\"></div>";
	  temp_float+="</div>";
	  $("body").append(temp_float);
	}

	$("#floatBox_Ma .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_Ma .content").ajaxStart(function(){
				$(this).html("loading...");
  			});
		  $.ajax({
			type:content_array[0],
			url:content_array[1],
			data:content_array[2],
			error:function(){
			  $("#floatBox_Ma .content").html("error...");
			},
			success:function(html){
			  $("#floatBox_Ma .content").html(html);
			}
		  });
  		break;
		case "text":
  			$("#floatBox_Ma .content").html(content);
		break;
		case "id":
			if(dialogFirst_ma)
			{
				$("#floatBox_Ma .content").html($("#"+content+"").html());
			}
			else
			{
				$("#floatBox_Ma .content").html(ss);
			}
		break;
		case "iframe":
			$("#floatBox_Ma .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
		break;
		default:
		break;
	}

	$("#floatBoxBg_Ma").show();
	$("#floatBoxBg_Ma").animate({opacity:"0.5"},"normal");
	$("#floatBox_Ma").attr("class","floatBox_Ma "+cssName);
	$("#floatBox_Ma").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_Ma").animate({top:($(document).scrollTop()+120)+"px"},"normal"); 
	
	dialogFirst_ma=false;
}

function dialog_trial(title,content,width,height,cssName)
{
	if(dialogFirst_st==true){
	  var temp_float=new String;
	  temp_float="<div id=\"floatBoxBg_St\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
	  temp_float+="<div id=\"floatBox_St\" class=\"floatBox_St\">";
	  temp_float+="<div class=\"content\"></div>";
	  temp_float+="</div>";
	  $("body").append(temp_float);
	}

	$("#floatBox_St .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_St .content").ajaxStart(function(){
				$(this).html("loading...");
  			});
		  $.ajax({
			type:content_array[0],
			url:content_array[1],
			data:content_array[2],
			error:function(){
			  $("#floatBox_St .content").html("error...");
			},
			success:function(html){
			  $("#floatBox_St .content").html(html);
			}
		  });
  		break;
		case "text":
  			$("#floatBox_St .content").html(content);
		break;
		case "id":
			if(dialogFirst_st)
			{
				$("#floatBox_St .content").html($("#"+content+"").html());
			}
			else
			{
				$("#floatBox_St .content").html(st);
			}
		break;
		case "iframe":
			$("#floatBox_St .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
		break;
		default:
		break;
	}

	$("#floatBoxBg_St").show();
	$("#floatBoxBg_St").animate({opacity:"0.5"},"normal");
	$("#floatBox_St").attr("class","floatBox_St "+cssName);
	$("#floatBox_St").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_St").animate({top:($(document).scrollTop()+120)+"px"},"normal"); 
	
	dialogFirst_st=false;
}

function dialog_intro(title,content,width,height,cssName)
{
	if(dialogFirst_si==true){
	  var temp_float=new String;
	  temp_float="<div id=\"floatBoxBg_Si\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";
	  temp_float+="<div id=\"floatBox_Si\" class=\"floatBox_Si\">";
	  temp_float+="<div class=\"content\"></div>";
	  temp_float+="</div>";
	  $("body").append(temp_float);
	}

	$("#floatBox_Si .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_Si .content").ajaxStart(function(){
				$(this).html("loading...");
  			});
		  $.ajax({
			type:content_array[0],
			url:content_array[1],
			data:content_array[2],
			error:function(){
			  $("#floatBox_Si .content").html("error...");
			},
			success:function(html){
			  $("#floatBox_Si .content").html(html);
			}
		  });
  		break;
		case "text":
  			$("#floatBox_Si .content").html(content);
		break;
		case "id":
			if(dialogFirst_si)
			{
				$("#floatBox_Si .content").html($("#"+content+"").html());
			}
			else
			{
				$("#floatBox_Si .content").html(si);
			}
		break;
		case "iframe":
			$("#floatBox_Si .content").html("<iframe src=\""+content+"\" width=\"100%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"auto\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\"></iframe>");
		break;
		default:
		break;
	}

	$("#floatBoxBg_Si").show();
	$("#floatBoxBg_Si").animate({opacity:"0.5"},"normal");
	$("#floatBox_Si").attr("class","floatBox_Si "+cssName);
	$("#floatBox_Si").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_Si").animate({top:($(document).scrollTop()+120)+"px"},"normal"); 
	
	dialogFirst_si=false;
}

function close_login_form()
{
  $("#floatBoxBg_Ma").animate({opacity:"0"},"normal",function(){$(this).hide();});
  $("#floatBox_Ma").animate({top:($(document).scrollTop()-168)+"px"},"normal",function(){$(this).hide();}); 
};

function close_trial()
{
  $("#floatBoxBg_St").animate({opacity:"0"},"normal",function(){$(this).hide();});
  $("#floatBox_St").animate({top:($(document).scrollTop()-168)+"px"},"normal",function(){$(this).hide();}); 
};

function close_intro()
{
  $("#floatBoxBg_Si").animate({opacity:"0"},"normal",function(){$(this).hide();});
  $("#floatBox_Si").animate({top:($(document).scrollTop()-168)+"px"},"normal",function(){$(this).hide();}); 
};
