var DTREE_ICON_ROOT = '/tpl/images/dtree/';

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
	添加到收藏夹
 */
function add_bookmark(title,url) {
	if (window.sidebar) { 
		window.sidebar.addPanel(title, url,""); 
	} else if( document.all ) {
		window.external.AddFavorite( url, title);
	} else if( window.opera && window.print ) {
		return true;
	}
}//-- end of function `add_bookmark`

/*
	URL转向
*/
function go(url) {
	window.location	=	url	;
}//-- end of function `go`

/*
	重设图片长宽
*/
function reset_img_wh(obj,mw,mh) {
	mw	=	mw ? mw : 400	;
	mh	=	mh ? mh : 300	;

	if (obj.width>mw)
	{
		obj.height = parseFloat( obj.height*mw/obj.width )	;
		obj.width = mw;
	}

	if (obj.height>mh)
	{
		obj.width = parseFloat( obj.width*mh/obj.height );
		obj.height = mh;
	}

	obj.onclick=function(){
		window.open(obj.src);
	}

	obj.onmouseover=function(){
		obj.style.cursor = "hand";
		obj.title = '浏览原始图片';
	}
}//-- end of function `reset_img_wh`


function kill_errors() {
	return true	;
}//-- end of function 

String.prototype.replaceAll = function(search, replace){
 var regex = new RegExp(search, "g");
 return this.replace(regex, replace);
} 

function Ran(R) {		
	return Math.floor((R+1)*Math.random())
}


$(function(){
	$.each( $.find("a") , function(i,val) {
		if ( val.href==$("base").attr("href")+"#" ) {
			val.href=window.location+"#";
			$("#"+i).attr("href",window.location+"#")	 ;
		}
	})	;

	$.each( $.find("area") , function(i,val) {
		if ( val.href==$("base").attr("href")+"#" ) {
			val.href=window.location+"#";
			$("#"+i).attr("href",window.location+"#")	 ;
		}
	})	;

	$("#add_bookmark").click(function(){
		add_bookmark(SITE_NAME,BASE_HOST);
	})	;

	$("#keyword").click(function(){
		$(this).attr('value','');
	})	;

	/*#	如果是Firefox浏览器	#*/
	$.each($.browser,function(i,val){
		if (i=="mozilla") {
			$.getScript("/js/firefox.js",function(){
			})	;
		}
	});

});

//window.onerror = kill_errors	;

var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]  
   
 //extra height in px to add to iframe in FireFox 1.0+ browsers  
   
var FFextraHeight=getFFVersion>=0.1? 16 : 0   
   
   
function dyniframesize(iframename) {  
   
   var pTar = null;  
   
   if (document.getElementById){  
   
     pTar = document.getElementById(iframename);  
   
   }  
   
   else{  
   
     eval('pTar = ' + iframename + ';');  
   
   }  
   
   if (pTar && !window.opera){  
   
     //begin resizing iframe  
   
     pTar.style.display="block"  
   
       
   
     if (pTar.contentDocument && pTar.contentDocument.body.offsetHeight){  
   
       //ns6 syntax  
   
       pTar.height = pTar.contentDocument.body.offsetHeight+FFextraHeight;   
   
     }  
   
     else if (pTar.Document && pTar.Document.body.scrollHeight){  
   
       //ie5+ syntax  
   
       pTar.height = pTar.Document.body.scrollHeight;  
   
     }  
   
   }  
   
}//-- end of function 