﻿var dialogFirst=true;
//打开弹出层
function dialog(title,content,width,height){
    //初始化模板HTML代码
    if(dialogFirst==true){       
        var temp_float=new String;
        //css代码
        temp_float="<style type=\"text/css\">";
        temp_float+="#floatBoxBg";
        temp_float+="{";
        temp_float+="    display: none;";
        temp_float+="    width: 100%;";
        temp_float+="    height: 100%;";
        temp_float+="    background: #000;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 0;";
        temp_float+="    left: 0;";
        temp_float+="    z-index: 3;";
        temp_float+="}";
        temp_float+=".floatBox";
        temp_float+="{";
        temp_float+="    width: 217px;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 50px;";
        temp_float+="    left: 40%;";
         temp_float+="    z-index: 4;";
        temp_float+="}";
        temp_float+="</style>";
        
        //遮罩层HTML
        temp_float+="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";        
        //弹出层HTML
        temp_float+="<div id=\"floatBox\" style=\"width:100%; height:auto; float:left; background-color:#FFFFFF; padding-bottom:10px;\">";
        temp_float+="  <div class=\"level2_1\" style=\"width:100%; height:34px; float:left; background-color:#494949\">";
   	    temp_float+="    <div class=\"level3_1\" style=\"width:17px; height:17px; float:left; margin-top:8px; margin-left:4px;\"><img src=\"/Content/newhapa/images/shangchuan002.gif\" border=\"0\" /></div>";
        temp_float+="    <div class=\"level3_2\" style=\"width:80%; height:auto; float:left; padding-left:5px;line-height:34px; color:#FFFFFF; font-size:14px; font-weight:bold\">提示信息</div>";
        temp_float+="    <div class=\"level3_3\" style=\"width:12px; height:12px; float:right; margin-right:6px; margin-top:10px;\"><img src=\"/Content/newhapa/images/GuanB_003.gif\" style=\"cursor:pointer;\" alt=\"关闭\" border=\"0\" /></div>";
        temp_float+="  </div>";
        temp_float+="  <div class=\"level2_2\" style=\"width:80%; height:auto; float:left; padding:10px;\">";
        temp_float+="      <div class=\"ClientSideLogin_Nr_all_01\">";        
        temp_float+="      </div>";
        temp_float+="  </div>";
        temp_float+="</div>";
      
        $("body").append(temp_float);
        dialogFirst=false;
    }
    
    //初始化关闭按钮
    $("#floatBox .level2_1 .level3_3 img").click(function(){
         dialogClose(); 
    });

    //初始化title数据
    if(title!=null&&title!='')
        $("#floatBox .level3_2").html(title);
        
    //分隔内容类型及内容数据
    contentType=content.substring(0,content.indexOf(":"));
    content=content.substring(content.indexOf(":")+1,content.length);
    
    //根据类型选择相应的内容数据填充
    switch(contentType){
      case "url"://通过url获取显示内容
          var content_array=content.split("?");
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").ajaxStart(function(){
            $(this).html("loading...");
          });
          $.ajax({
            type:content_array[0],
            url:content_array[1],
            data:content_array[2],
	        error:function(){
	          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html("error...");
	        },
            success:function(html){
              $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html(html);
            }
          });
          break;
      case "text": //通过传入的文字显示内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html(content);
          break;
      case "id"://通过页面中的某个DIV获取显示内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html($("#"+content+"").html());
          break;
      case "iframe"://显示Iframe中的内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html("<iframe id=\"iframeID\" width=\"99%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"yes\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\ style=\"overflow-x:hidden\"></iframe>" );
          $("#iframeID").attr("src",content);
    }
    
    
    $("#floatBoxBg").show();//显示遮罩
    $("select").each(function(i){$(this).css('visibility','hidden')});//过滤页面中的select控件
    //显示弹出层
     $("#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({top:($(document).scrollTop()+50)+"px"},"normal"); 
    $("#floatBoxBg").css({opacity:"0.5"},"normal");
    $("#floatBox").attr("class","floatBox ");   
}
//关闭弹出层
function dialogClose(){
  $("select").each(function(i){$(this).css('visibility','visible')});
  $("#floatBoxBg").css('display','none');  
  $("#floatBox").css({top:"-1000px"},"normal",function(){$(this).hide();});
}



function dialoghapame(title,content,width,height){
    //初始化模板HTML代码
    if(dialogFirst==true){       
        var temp_float=new String;
        //css代码
        temp_float="<style type=\"text/css\">";
        temp_float+="#floatBoxBg";
        temp_float+="{";
        temp_float+="    display: none;";
        temp_float+="    width: 100%;";
        temp_float+="    height: 100%;";
        temp_float+="    background: #000;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 0;";
        temp_float+="    left: 0;";
        temp_float+="}";
        temp_float+=".floatBox";
        temp_float+="{";
        temp_float+="    width: 217px;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 50px;";
        temp_float+="    left: 40%;";
        temp_float+="}";
        temp_float+="</style>";
        
        //遮罩层HTML
        temp_float+="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";        
        //弹出层HTML
        temp_float+="<div id=\"floatBox\" style=\"width:100%; height:auto; float:left; background-color:#FFFFFF; padding-bottom:10px;\">";
        temp_float+="  <div class=\"level2_1\" style=\"width:100%; height:34px; float:left; background-color:#494949\">";
   	    temp_float+="    <div class=\"level3_1\" style=\"width:17px; height:17px; float:left; margin-top:8px; margin-left:4px;\"><img src=\"/Content/newhapa/images/shangchuan002.gif\" border=\"0\" /></div>";
        temp_float+="    <div class=\"level3_2\" style=\"width:80%; height:auto; float:left; padding-left:5px;line-height:34px; color:#FFFFFF; font-size:14px; font-weight:bold\">提示信息</div>";
        temp_float+="    <div class=\"level3_3\" style=\"width:12px; height:12px; float:right; margin-right:6px; margin-top:10px;\"><img src=\"/Content/newhapa/images/GuanB_003.gif\" style=\"cursor:pointer;\" alt=\"关闭\" border=\"0\" /></div>";
        temp_float+="  </div>";
        temp_float+="  <div class=\"level2_2\" style=\"width:90%; height:auto; float:left; padding:10px;\">";
        temp_float+="      <div class=\"ClientSideLogin_Nr_all_01\" style=\"width:300px\">";        
        temp_float+="      </div>";
        temp_float+="  </div>";
        temp_float+="</div>";
      
        $("body").append(temp_float);
        dialogFirst=false;
    }
    
    //初始化关闭按钮
    $("#floatBox .level2_1 .level3_3 img").click(function(){
         dialogClose(); 
    });

    //初始化title数据
    if(title!=null&&title!='')
        $("#floatBox .level3_2").html(title);
        
    //分隔内容类型及内容数据
    contentType=content.substring(0,content.indexOf(":"));
    content=content.substring(content.indexOf(":")+1,content.length);
    
    //根据类型选择相应的内容数据填充
    switch(contentType){
      case "url"://通过url获取显示内容
          var content_array=content.split("?");
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").ajaxStart(function(){
            $(this).html("loading...");
          });
          $.ajax({
            type:content_array[0],
            url:content_array[1],
            data:content_array[2],
	        error:function(){
	          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html("error...");
	        },
            success:function(html){
              $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html(html);
            }
          });
          break;
      case "text": //通过传入的文字显示内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html(content);
          break;
      case "id"://通过页面中的某个DIV获取显示内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html($("#"+content+"").html());
          break;
      case "iframe"://显示Iframe中的内容
          $("#floatBox .level2_2 .ClientSideLogin_Nr_all_01").html("<iframe id=\"iframeID\" width=\"99%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"yes\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\ style=\"overflow-x:hidden\"></iframe>" );
          $("#iframeID").attr("src",content);
    }
    
    
    $("#floatBoxBg").show();//显示遮罩
    $("select").each(function(i){$(this).css('visibility','hidden')});//过滤页面中的select控件
    //显示弹出层
     $("#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({top:($(document).scrollTop()+10)+"px"},"normal"); 
    $("#floatBoxBg").css({opacity:"0.5"},"normal");
    $("#floatBox").attr("class","floatBox ");   
}
//关闭弹出层








function dialoghapameV3(title,content,width,height){
    //初始化模板HTML代码
    if(dialogFirst==true){       
        var temp_float=new String;
        //css代码
        temp_float="<style type=\"text/css\">";
        temp_float+="#floatBoxBg";
        temp_float+="{";
        temp_float+="    display: none;";
        temp_float+="    width: 100%;";
        temp_float+="    height: 100%;";
        temp_float+="    background: #000;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 0;";
        temp_float+="    left: 0;";
        temp_float+="}";
        temp_float+=".floatBox";
        temp_float+="{";
        temp_float+="    width: 217px;";
        temp_float+="    position: absolute;";
        temp_float+="    top: 50px;";
        temp_float+="    left: 40%;";
        temp_float+="}";
        temp_float+="</style>";
        
        //遮罩层HTML
        temp_float+="<div id=\"floatBoxBg\" style=\"height:"+$(document).height()+"px;filter:alpha(opacity=0);opacity:0;\"></div>";        
        //弹出层HTML
        temp_float+="<div id=\"floatBox\" style=\"width:100%; height:auto; float:left; padding-bottom:10px;\">";
//        temp_float+="  <div class=\"level2_1\" style=\"width:100%; height:34px; float:left; background-color:#494949\">";
//   	    temp_float+="    <div class=\"level3_1\" style=\"width:17px; height:17px; float:left; margin-top:8px; margin-left:4px;\"><img src=\"/Content/newhapa/images/shangchuan002.gif\" border=\"0\" /></div>";
//        temp_float+="    <div class=\"level3_2\" style=\"width:80%; height:auto; float:left; padding-left:5px;line-height:34px; color:#FFFFFF; font-size:14px; font-weight:bold\">提示信息</div>";
//        temp_float+="    <div class=\"level3_3\" style=\"width:12px; height:12px; float:right; margin-right:6px; margin-top:10px;\"><img src=\"/Content/newhapa/images/GuanB_003.gif\" style=\"cursor:pointer;\" alt=\"关闭\" border=\"0\" /></div>";
//        temp_float+="  </div>";
//        temp_float+="  <div class=\"level2_2\" style=\"width:90%; height:auto; float:left; padding:10px;\">";
//        temp_float+="      <div class=\"ClientSideLogin_Nr_all_01\" style=\"width:300px\">";        
//        temp_float+="      </div>";
//        temp_float+="  </div>";
        temp_float+="</div>";
      
        $("body").append(temp_float);
        dialogFirst=false;
    }
    
//    //初始化关闭按钮
//    $("#floatBox .level2_1 .level3_3 img").click(function(){
//         dialogClose(); 
//    });

//    //初始化title数据
//    if(title!=null&&title!='')
//        $("#floatBox .level3_2").html(title);
        
    //分隔内容类型及内容数据
    contentType=content.substring(0,content.indexOf(":"));
    content=content.substring(content.indexOf(":")+1,content.length);
    
    //根据类型选择相应的内容数据填充
    switch(contentType){
      case "url"://通过url获取显示内容
          var content_array=content.split("?");
          $("#floatBox").ajaxStart(function(){
            $(this).html("loading...");
          });
          $.ajax({
            type:content_array[0],
            url:content_array[1],
            data:content_array[2],
	        error:function(){
	          $("#floatBox").html("error...");
	        },
            success:function(html){
              $("#floatBox").html(html);
            }
          });
          break;
      case "text": //通过传入的文字显示内容
          $("#floatBox").html(content);
          break;
      case "id"://通过页面中的某个DIV获取显示内容
          $("#floatBox").html($("#"+content+"").html());
          break;
      case "iframe"://显示Iframe中的内容
          $("#floatBox").html("<iframe id=\"iframeID\" width=\"99%\" height=\""+(parseInt(height)-30)+"px"+"\" scrolling=\"yes\" frameborder=\"0\" marginheight=\"0\" marginwidth=\"0\ style=\"overflow-x:hidden\"></iframe>" );
          $("#iframeID").attr("src",content);
    }
    
    
    $("#floatBoxBg").show();//显示遮罩
    $("select").each(function(i){$(this).css('visibility','hidden')});//过滤页面中的select控件
    //显示弹出层
     $("#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({top:"400px"},"normal"); 
    $("#floatBoxBg").css({opacity:"0.5"},"normal");
    $("#floatBox").attr("class","floatBox ");   
}
//关闭弹出层