
////////////////////////////////////////////////////////
// Lee dialog 1.0 http://www.xij.cn/blog/?p=68

var dialogFirst=true;
function dialog(title,content,width,height,cssName){

if(dialogFirst==true){
  var temp_float=new String;
  temp_float="<div id=\"floatBoxBg\"  name=\"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 id=\"floatBoxBg_action\" > X </span></div>";
  temp_float+="<div class=\"content\"></div>";
  temp_float+="</div>";
  $("body").append(temp_float);
  dialogFirst=false;
}
$("#floatBoxBg_action").click(function(){
	//alert('ccc');
  //$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
  $("#floatBoxBg").hide();
  $("#floatBox").css({top:"-4460px"},"normal",function(){$(this).hide();});
  if(isFirefox=navigator.userAgent.indexOf("MSIE 6.0") > 0){
      $("#selectOS").show();
      $("#PartSelectCL").show();
   } 
  //$("#floatBox").animate({top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){$(this).hide();}); 
  //$("#floatBox").hide();
});
$("#floatBox .title span").click(function(){
	//alert('ccc');
  //$("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
  $("#floatBoxBg").hide();
  $("#floatBox").css({top:"-4460px"},"normal",function(){$(this).hide();});
  if(isFirefox=navigator.userAgent.indexOf("MSIE 6.0") > 0){
      $("#selectOS").show();
      $("#PartSelectCL").show();
   } 
  //$("#floatBox").animate({top:($(document).scrollTop()-(height=="auto"?300:parseInt(height)))+"px"},"normal",function(){$(this).hide();}); 
  //$("#floatBox").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>");
}
$("#floatBox").attr("class", "floatBox " + cssName);
//$("#floatBox").css("top", document.documentElement.scrollTop  + "px");
if(isFirefox=navigator.userAgent.indexOf("MSIE 6.0") > 0){ 
	$("#floatBox").css({left:(($(document).width())/2-(parseInt(width)/2))+"px",top:230,width:width,height:height});
}
else
{
	$("#floatBox").css({left:(($(document).width())/2-(parseInt(width)/2))+"px",top:230,width:width,height:height});
}

var _top = (document.documentElement.clientHeight) / 2;
//$("#floatBox").css("top", (_top < 0 ? 0 : _top) + document.documentElement.scrollTop/2 + "px");
$("#floatBoxBg").show();
$("#floatBoxBg").animate({opacity:"0.3"},"normal");
//$("#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"); 
}
