/*Document By JodJin 2010/05/15*/
var re_mattewindow = false;
var matteTrig = {
  loadMatte:function(){
   $("#mattecont").show();
   $("#loading").hide();
  },
  closeMatte:function(){
   $("#mattebox").html("").hide();
   if(re_mattewindow==true){
    $(function(){mattewindow(Mtit,Mwidth,Mheight,Trigname,Msrc,false);});
   }
  },
  scroolMatte:function(){
   mheight = $("#mattecont").height();
   var distance = (document.documentElement.clientHeight-mheight)/2-10;
   if(document.documentElement && document.documentElement.scrollTop){MatteTop = document.documentElement.scrollTop + distance + "px";}
   else if(document.body){MatteTop = document.body.scrollTop + distance + "px";}
   $("#mattecont").css("top",MatteTop);
  },
  recallMatte:function(){
    $(function(){mattewindow(Mtit,Mwidth,Mheight,Trigname,Msrc,true);});
  },
  reValue:function(thisValue){
	var getValue='';
 	getValue = $("input[name='photo']").attr("value",thisValue);  
  }
};
function mattewindow(mtit,mwidth,mheight,trigname,msrc,m_auto){
  var m_str;
  var dom_id = function(o){return document.getElementById(o)}
  var theWidth = Math.max(document.documentElement.scrollWidth, document.body.scrollWidth);
  var theHeight = Math.max(document.documentElement.clientHeight, document.body.offsetHeight);
  var topPx = (document.documentElement.clientHeight-mheight)/2-10;
  var leftPx = (theWidth-mwidth)/2-10;
  $("<div id=\"mattebox\" style=\"display:none\"><\/div>").appendTo("body");
  m_str = "<style type=\"text/css\">#loading{background:#fff;padding:10px;position:absolute;z-index:222;top:"+topPx+"px;left:"+leftPx+"px;border:10px solid #666;font-size:14px;color:#296ea0;width:"+mwidth+"px;height:30px;overflow:hidden;text-align:center;}#mattecont{border:10px solid #666;position:absolute;z-index:5555;top:"+topPx+"px;left:"+leftPx+"px;display:none;width:"+mwidth+"px;height:"+mheight+"px;}#mattetit{font-size:14px;font-weight:bold;background:#f87024;color:white;padding:10px;height:15px;border:1px solid #838485;overflow:hidden;border-bottom:0}#matteclose{color:white;font-size:14px;float:right;text-decoration:none;}#m_iframe{background:#fff;}#blackbg{background:#000;position:absolute;top:0;left:0;filter:alpha(opacity=40);opacity:0.4;z-index:22}<\/style>";
  m_str += "<div id=\"loading\"><img src=\"loading.gif\" align=\"absmiddle\" /> 页面加载中,请稍侯...<\/div>";
  m_str += "<div id=\"mattecont\">";
  m_str += "<div id=\"mattetit\"><a href=\"javascript:;\" onclick=\"matteTrig.closeMatte()\" title=\"关闭\" id=\"matteclose\">×<\/a>"+mtit+"<\/div>";
  m_str += "<iframe id=\"m_iframe\" name=\"m_iframe\" onload=\"matteTrig.loadMatte()\" src=\""+msrc+"\" frameborder=\"0\" width=\""+mwidth+"\" height=\""+(mheight-35)+"\" scrolling=\"no\"><\/iframe>";
  m_str += "<\/div>";
  m_str += "<div id=\"blackbg\" style=\"width:"+theWidth+"px;height:"+theHeight+"px;\"><\/div>";
  Mtit = mtit;
  Mwidth = mwidth;
  Mheight = mheight;
  Trigname = trigname;
  Msrc = msrc;
  if(m_auto==true && trigname != null){ 
	$("#mattebox").html(m_str).show();
	re_mattewindow = true ;
  }
  else if(trigname==null && m_auto==true){
	$("#mattebox").html(m_str).show();
	re_mattewindow = true ;
	document.all.m_iframe.contentWindow.location=msrc;
  }
  else{
	  $(trigname).click(function(){
		$("#mattebox").html(m_str).show();
	  	document.all.m_iframe.contentWindow.location=msrc;					 
	  });
  }
  window.setInterval("matteTrig.scroolMatte()",10);
}
