
var dialogFirst=true;
function dialog(title, cid, act, e){

var width = 300;
var height = 'auto';
var 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;
}

$("#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();}); 
	$("#floatBoxBg").hide();
	$("#floatBox").hide();
});

$("#floatBox .title h4").html(title);


switch(act){
  case 'addtag':
  var lable = "标签";
  break;

  case 'editutitle':
  var lable = "网站名称";  
  break;  
  
  default:
  var lable = "默认标签";
  break;
  
}

var form = "<form action=\"index.php?controller=url&action=" + act + "\" method=\"POST\" >";
form += lable + " :<input type = \"text\" name = \"col\" value = \"\" />";
form += "<input type = \"hidden\" name = \"cid\" value = \"" + cid + "\" />";
form += "<input type = \"hidden\" name = \"sub\" value = \"true\" /><br/>";
form += "<input type = \"submit\" value = \"提 交\" />";
form += "</form>";

$("#floatBox .content").html(form);


/*
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>");
}
*/



var posx = e.pageX;
var posy = e.pageY;

$("#floatBoxBg").show();
$("#floatBoxBg").animate({opacity:"0.5"},0);
$("#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").css({display:"block",left:posx+"px",top:posy+"px",width:width,height:height,"z-index":9999});
//$("#floatBox").animate({top:($(document).scrollTop()+posy)+"px"},0); 
$("#floatBox").animate({top:posy+"px"},0);
}
