function ieBrowser(){
	var agt = navigator.userAgent.toLowerCase();
	return (agt.indexOf("msie")!=-1 && document.all);
}
function openWin(url){
	var w = window.open(url);
	if(!w){
		location.href = url;
	}
}
/*$(can't use while prototype.js)
o not need,default is document */
function $$(ID,o){	
	var obj=o?o:document;
	if(ID.substring(0,1)=="#")return obj.getElementById(ID.substring(1));
	return obj.getElementsByTagName(ID);
}
/*$$Class() is early getByClass()
o not need,default is document */
function $$Class(clsn,tag,returnArray,o){
var i,co,coi,arr=new Array(),isfind,obj;
var clsnIndex,charBefore,charAfter;
obj=o?o:document;
co=obj.getElementsByTagName(tag);
for(i=0;i<co.length;i++){
	coi=co[i];
	var coClsn=coi.className;
	clsnIndex=coClsn.indexOf(clsn);
 if (clsnIndex!=-1)
 	{
		charBefore= coClsn.charAt(clsnIndex-1);
		charAfter= coClsn.charAt(clsnIndex+clsn.length);
		if((charBefore=="" || charBefore==" ")&&(charAfter=="" || charAfter==" ")){
			if(!returnArray){
			return coi;
			}else{
			arr.push(coi);isfind=true;
			}
		}
	}
 }
 if(isfind)return arr;else return false;
}
function loadCss(url){
document.write('<lin'+'k rel="stylesheet" href="'+url+'" type="text/css" />');
}
function loadScript(url){
document.write('<scr'+'ipt type="text/javascript" src="'+url+'" ></scr'+'ipt>');
}
function createCssRel(url){
	var styleObj=document.createElement("link");
	styleObj.rel="stylesheet";
	styleObj.type="text/css";
	styleObj.href=url;
	$$("head")[0].appendChild(styleObj);
	return styleObj;
}
function createJsRel(url){
	var jsObj=document.createElement("script");
	jsObj.language="javascript";
	jsObj.type="text/javascript";
	jsObj.src=url;
	$$("head")[0].appendChild(jsObj);
	return jsObj;
}
function execInFrame(url){
	var hiddenFrame=document.createElement("iframe");
	hiddenFrame.src=url;
	hiddenFrame.style.display="none";
	document.body.appendChild(hiddenFrame);
	hiddenFrame=null;
}
Array.prototype.append=function(aitem,boo){
	return this.push(aitem);//return length
}
Array.prototype.remove=function(aitem){
	var len,arri;
	len=this.length;
	for(var i=0;i<len;i++){
		arri=this[i];
		if(arri==aitem){
				this.splice(i,1);
				return true;
		}
	}
	return false;
}
String.prototype.trim=function(){
  return this.replace(/^(?:\s|　|&nbsp;)*|(?:\s|　|&nbsp;)*$/g,"");
}
function addWinFavorite(){
	window.external.addFavorite(document.location.href,document.title)
}
function setFrontPage(th){//th=this
	th.style.behavior='url(#default#homepage)';
	th.setHomePage(document.location.href);
}
/*替换ostr内匹配字符串str1的所有内容为str2，replace只替换一个*/
function replaceAll(ostr,str1,str2){
  var str=ostr.replace(str1,str2);
  if(str.indexOf(str1)!=-1){
  	str=str.replace(str1,str2);
	return str;
  }else{
	return str;
  }
/*  if(str.indexOf(str1)!=-1){
  	str=replaceAll(str,str1,str2);
	//stack overflow error?
  	return str;
  }else{
  	return str;
  }*/
}
function clearHTML(html){
var str=html;
str=str.replace(/<.*?>|(?:&.*?;)/gi,"")
return str;
}
/*the srceen position of mouse*/
function mouseXY(e){
	var e=window.event || e;
	var mx=(e.clientX || e.pageX)+(document.documentElement.scrollLeft||document.body.scrollLeft);
	var my=(e.clientY || e.pageY)+(document.documentElement.scrollTop||document.body.scrollTop);
	return {x:mx,y:my}
}
/*the absolute position of obj*/
function getPosition(o){
var cx=0,cy=0;
 if (o.offsetParent){
        while (o.offsetParent){
            cx += o.offsetLeft;
            cy += o.offsetTop;
 			   o = o.offsetParent;
        }		
    }else if (o.x){
        cx += o.x;
        cy += o.y;
    }
	return {left:cx,top:cy};
}
function getScreenSize(){
		var w = 0;
		var h = 0;
		if( typeof( window.innerWidth ) == 'number' ) {
			w = window.innerWidth;
			h = window.innerHeight;
		} else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
			w = document.documentElement.clientWidth;
			h = document.documentElement.clientHeight;
		} else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
			w = document.body.clientWidth;
			h = document.body.clientHeight;
		}
		return {width:w,height:h};
}
function setFloatDivHeight(id){
	var floatDiv=document.getElementById(id);
	if(floatDiv){
	floatDiv.style.height=floatDiv.offsetHeight+"px";
	}
}
function setSelect(sfname,svalue){
	if(!sfname)return;
	var op,len=sfname.options.length;
	for (i=0;i<len;i++){
	op=sfname.options[i];
	if(op.value==svalue)op.selected="selected";
	}
}
function chkRadio(form,radioName){
	var rad = document[form][radioName];
	if(!rad) return false;
	var len = rad.length;
	if(!len){
		return rad.checked;
	}//single not array, has no len
	for(var i = 0;i<len;i++){
		if (rad[i].checked==true) {
			return true;
		}
	}
	return false;
}

function enabledBtn(act,formName){
	var btns = $$("input",document[formName]),btn,len = btns.length;
	for(var i=0;i<len;i++){
		btn = btns[i];
		if(btn.type == "button" || btn.type == "submit" || btn.type == "reset"){
			if(act == false){
				btn.disabled = true;
			}else{
				btn.disabled = false;
			}
		}
	}
}
function scaleImg(oimg,iwidth,iheight){
		if(oimg.width>0 && oimg.height>0){ 
         if(oimg.width/oimg.height>= iwidth/iheight){ 
          if(oimg.width>iwidth){   
          oimg.width=iwidth; 
          oimg.height=(oimg.height*iwidth)/oimg.width; 
         	 }
          } 
         else{ 
          if(oimg.height>iheight){   
          oimg.height=iheight; 
          oimg.width=(oimg.width*iheight)/oimg.height;   
          	}
          } 
         }
		/* var im;
		 if(oimg.height<iheight){
		 	im=iheight-oimg.height;
			oimg.style.paddingTop=oimg.style.paddingBottom=im/2+"px";
		 }
		  if(oimg.width<iwidth){
			  im=iwidth-oimg.width;
			  oimg.style.paddingLeft=oimg.style.paddingRight=im/2+"px";
		  }*/
}

function scaleSelectImg(classID,width,height,containerID){
	var container = containerID?$$("#"+containerID):document;
	//只设置显现的图片尺寸，否则可能把隐藏的图片尺寸固定
	var imgs=$$Class(classID,"img",true,container);
	if(imgs){
		var ilen=imgs.length;
		for(var i=0;i<ilen;i++){
			scaleImg(imgs[i],width,height);
		}
	}
}

function removeErrImg(id){
	var c = $$("#"+id);
	var imgs = $$("img",c),len = imgs.length,img;
	for(var i = 0;i<len;i++){
		img = imgs[i];
		img.onerror=function(){//<a><img /></a>
			this.parentNode.parentNode.removeChild(this.parentNode);
		}
	}
}

function add_pho_hit(photo_id,uid,utype){
	var ajax = new net.ContentLoader(
			"/js/asp/add_pho_hit.asp",
			"photo_id="+photo_id+"&uid="+uid+"&utype="+utype,
			"GET",
			function(){
				var req = this.req.responseText;
		});
	ajax = null;	
}

function coverObjTag(act){
	var objects,selects,frames,olen,frameName,wino,actStr;
	frames=$$('iframe');
	frameName=frames[0]?frames[0].name:null;
	if(!frames || !frameName){
		objects=$$('object');
		selects=$$('select');
	}else{
		objects=$$('object');
		wino=window.frames[frameName].document;
		selects=$$('select',wino);
	}
	olen=(objects?objects.length:0)+(selects?selects.length:0)+(frames?frames.length:0);
	actStr=act=="hide"?"hidden":"visible";
	if (objects || selects || frames){
			for(var i=0;i<olen;i++){
			if(objects[i])objects[i].style.visibility=actStr;
			if(selects[i])selects[i].style.visibility=actStr;
			//if(frames[i])frames[i].style.visibility=act=="hide"?"hidden":"visible";
		}
	}	
}
//工具提示
function styleTip(str,act,outtime,cssStr,NotCoverObjTag){
	var o=$$("#styleTipID");
	if(!o){
		o=document.createElement("div");
		o.id="styleTipID";
		document.body.appendChild(o);
	}
	o.innerHTML=str;
	var os=o.style;
	var ss=getScreenSize();
	if(!NotCoverObjTag){
		//coverObjTag('hide');
	}
	os.cssText="color:#000;position:absolute;border:2px solid #999;background-color:#FFD;padding:15px 50px 13px;"+(cssStr||"");
	os.display="block";
	os.left=ss.width/2-o.offsetWidth/2+document.documentElement.scrollLeft+"px";
	os.top=ss.height/2-o.offsetHeight/2+document.body.scrollTop+document.documentElement.scrollTop+"px";
	if(act=="hide"){
		//styleTipMove();
	window.setTimeout(
		function(){
			$$("#styleTipID").style.display="none";
			document.onmousemove=null;
			if(!NotCoverObjTag){
				//coverObjTag("show");
		}},outtime);
	}else{
		//styleTipMove();
	}
}
function styleTipMove(){
	document.onmousemove=function(e){
	var p=mouseXY(e);
	var o=$$("#styleTipID");
	with(o.style){
			left=p.x+"px";
			top=p.y+20+"px";
		}
	}
}
function mouseHover(id,tag,style,head){
	var lis=$$(tag,$$("#"+id)),liLen=lis.length,li,i=0;
	if(head)i=1;
	for(;i<liLen;i++){
		li=lis[i];
		li.onmouseover=function(){
			this.className+=style;
		}
		li.onmouseout=function(){
			this.className=this.className.replace(style,"");
		}
	}
}
/*
addFavourite
会员专用函数，加登录检测
if(!chkLogin()){
	return false;
}
visitorID在登录时已设置
*/
function addFavourite(mf_type){
	var ajax=new net.ContentLoader(
		   "/inc/addFavourite.asp",
			"mf_path="+escape(location.href)+"&mf_title="+escape(document.title)+"&mf_type="+mf_type+"&visitorID="+visitorID,
			"GET",
			function(){
				var req=this.req.responseText;
				if (req==0){
					alert('记录已经存在');
					//styleTip("记录已经存在",'hide',2000);
					return;
				}
				alert('已成功收藏');
				//styleTip('已成功收藏','hide',2000);										
			});	
	ajax=null;
}
function emptyLink(container,act){
	if (act=="clear"){
		var c=container ? $$("#"+container) : document,cas=$$("a",c),clen=cas.length,ca;
		var href,loc=location.href,loc1=loc+location.hash;
		for(var i=0;i<clen;i++){
			ca=cas[i];
			href=ca.href;
			if (href==loc || href==loc.split('?')[0] || href==loc1 || href==loc1.split('#')[0] || href=="" || (href.substr(href.length-3)=="///")){
				ca.target="_self";
				ca.style.cursor="default";
				ca.onclick=function(){return false};
			}
		}
	}
}
function showCaptchaImg(con, src, lang){
	if(!$$('img',$$("#"+con))[0]){
		var html = '<img src="' + src + '" " alt= "' + lang + '" class="hand" width="60" height="18" align="absmiddle" onClick="this.src=\'' + src + '\'+new Date().valueOf()" />';
		$$("#"+con).innerHTML = html;
	}
}
function delSel(title){
	return confirm('确认要删除“' + title + '”吗？\n一旦删除将无法恢复');
}
//below temp use
function addListener(o,eStr,func,capture){
var c=capture||true;
	if(window.attachEvent){
	o.attachEvent(eStr, func);
	}else{
	var e=eStr.substring(2);
	var obj=e=="load"&&o==document?window:o;
	obj.addEventListener(e, func, c);
	}
}
