// Lee dialog 1.0 http://www.xij.cn/blog/?p=68

var dialogFirst=true;
var dialogHeight=0;
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><div class=close><a href=\"javascript:void(0);\" onclick=\"closrdialog();\"><img src=\"/images/close.jpg\" border=\"0\" /></a></div></div>";//"<div class=\"title\"><h4></h4><span>鍏抽棴</span></div>";
  temp_float+="<div class=\"content\"></div>";  
  temp_float+="</div>";
  $("body").append(temp_float);
  dialogHeight=height;
  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 .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"); 
}


function jump_code()    
{ 
 $.ajax({                                 //调用jquery的ajax方法    
     type: "POST",                          //设置ajax方法提交数据的形式    
     url: "/MemberShow/ajax/AddFriend.aspx",                                          
     data: "t_mid="+$("#t_mid").val()+"&t_tid="+$("#t_tid").val()+"&t_mname="+$("#t_mname").val()+"&t_tname="+$("#t_tname").val()+"&t_content="+$("#t_content").val(), //输入框fund_code中的值作为提交的数据;如有多个数据，则可拼接成字符串，#fund_code为输入框ID    
     success: function(msg){                 //提交成功后的回调，msg变量是输出的内容。    

        $("#floatBox .content").html(msg);   
        setInterval("closrdialog()",2000);   
    }    
   });     
} 

function closrdialog(){
    $("#floatBoxBg").animate({opacity:"-2"},"normal",function(){$(this).hide();});
    $("#floatBox").animate({top:($(document).scrollTop()-(dialogHeight=="auto"?300:parseInt(dialogHeight)))+"px"},"normal",function(){$(this).hide();}); 
    dialogFirst=false;

}
