var dialogFirst=true;
function draw(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>";
  $("body").append(temp_float);
  dialogFirst=false;
}
var tops = (window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100)>0?(window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100):0;
//alert($(document).scrollTop());

  

tops=tops-115;
$("#floatBox .title span").click(function(){
  $("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
 $("#floatBox").animate({top:tops+"px"},"normal",function(){$(this).hide();}); 
});

$("#floatBox .title h4").html(title);
//contentType=content.substring(0,content.indexOf(":"));
//content=content.substring(content.indexOf(":")+1,content.length);
contentType="iframe";

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("<div class=text>"+html+"</div>");
    }
  });
  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)-35)+"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:"350"+"px",width:width,height:height});
$("#floatBox").animate({top:tops+"px"},"normal"); 
}


function drawa(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>";
  $("body").append(temp_float);
  dialogFirst=false;
}
var tops = (window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100)>0?(window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100):0;
tops=tops+150;
//alert($(document).scrollTop());
$("#floatBox .title span").click(function(){
  $("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
 $("#floatBox").animate({top:tops+"px"},"normal",function(){$(this).hide();}); 
});

$("#floatBox .title h4").html(title);
//contentType=content.substring(0,content.indexOf(":"));
//content=content.substring(content.indexOf(":")+1,content.length);
contentType="iframe";

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("<div class=text>"+html+"</div>");
    }
  });
  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)-35)+"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:"350"+"px",width:width,height:height});
$("#floatBox").animate({top:tops+"px"},"normal"); 
}





function draw2(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>";
  $("body").append(temp_float);
  dialogFirst=false;
}
var tops = (window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100)>0?(window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100):0;
//var tops=0;
//var yy=$("#yyy").val();
//if(Number(yy)<Number(window.screen.height)) tops=(window.screen.availHeight)/2-Math.round(height/2);
//else tops=Number(yy)-(window.screen.height/2)
//alert(tops);
//return false;

//alert(parent.document.body.scrollTop);

$("#floatBox .title span").click(function(){
  $("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
 $("#floatBox").animate({top:tops+"px"},"normal",function(){$(this).hide();}); 
});

$("#floatBox .title h4").html(title);
//contentType=content.substring(0,content.indexOf(":"));
//content=content.substring(content.indexOf(":")+1,content.length);
contentType="text";

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("<div class=text>"+html+"</div>");
    }
  });
  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)-35)+"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:"350"+"px",width:width,height:height});
$("#floatBox").animate({top:tops+"px"},"normal"); 
}


function draw3(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>";
  $("body").append(temp_float);
  dialogFirst=false;
}
var tops = (window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100)>0?(window.screen.height/2 + (document.body.scrollTop>document.documentElement.scrollTop ? document.body.scrollTop:document.documentElement.scrollTop) - height/2 - 100):0;
tops=tops+130;
//var offset = p.offset();
//tops=offset.top;
//alert(tops);
//var tops=0;
//var yy=$("#yyy").val();
//if(Number(yy)<Number(window.screen.height)) tops=(window.screen.availHeight)/2-Math.round(height/2);
//else tops=Number(yy)-(window.screen.height/2)
//alert(tops);
//return false;

//alert(parent.document.body.scrollTop);

$("#floatBox .title span").click(function(){
  $("#floatBoxBg").animate({opacity:"0"},"normal",function(){$(this).hide();});
 $("#floatBox").animate({top:tops+"px"},"normal",function(){$(this).hide();}); 
});

$("#floatBox .title h4").html(title);
//contentType=content.substring(0,content.indexOf(":"));
//content=content.substring(content.indexOf(":")+1,content.length);
contentType="text";

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("<div class=text>"+html+"</div>");
    }
  });
  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)-35)+"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:"350"+"px",width:width,height:height});
$("#floatBox").animate({top:tops+"px"},"normal"); 
}


