try{document.execCommand('BackgroundImageCache',false,true);}catch(e){}
var isIE=!-[1,];
var isGecko=(navigator.userAgent.indexOf("Gecko")>-1)&&(navigator.userAgent.indexOf("KHTML")==-1);
function $(o) {if(document.getElementById&&document.getElementById(o)){return document.getElementById(o);}else if (document.all&&document.all(o)){return document.all(o);}else if (document.layers&&document.layers[o]){return document.layers[o];}else{return false;}} 
function setCls(o,c,f){if(!o)return;var oc=o.className=o.className.replace(new RegExp('( ?|^)'+c+'\\b'),'');if(!f)o.className=oc.length>0?(oc+' '+c):c}
String.prototype.trim= function(){return this.replace(/(^\s*)|(\s*$)/g,"");}
if(!Array.prototype.indexOf)Array.prototype.indexOf=function(item,i){i||(i=0);var l=this.length;if(i<0)i=l+i;for(;i<l;i++)if(this[i]===item)return i;return -1}
function isEmail(s){var p=/^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-])+/;return p.test(s)}
function isUrl(s){var p=new RegExp("((^http)|(^https)):\/\/(\\w)+\.(\\w)+");return p.test(s)}
function onEvent(A,B,C){B=B.replace(/^on/,'').toLowerCase();if(A.attachEvent){A[B+C]=function(){C.call(A,window.event)};A.attachEvent('on'+B,A[B+C])}else A.addEventListener(B,C,false);return A}
function unEvent(A,B,C){B=B.replace(/^on/,'').toLowerCase();if(A.attachEvent){A.detachEvent('on'+B,A[B+C]);A[B+C]=null}else A.removeEventListener(B,C,false);return A}
function show(){this.style.display='block'}
function hide(){this.style.display='none'}
function setVisibile(A,B){if(typeof A=='string')A=$(A);if(A)A.style.display=B?'block':'none'}
function bytes(s){if(typeof(s)!="string"){s=s.value}var l=0;for(var i=0;i<s.length;i++){if(s.charCodeAt(i)>127){l++}l++}return l}
function preloadImage(){var args = preloadImage.arguments;if(!document.preloadImageArray)document.preloadImageArray=[];for(var i=0,len=args.length;i<args;i++){document.preloadImageArray.push(new Image());document.preloadImageArray[document.preloadImageArray.length].src=args[i]}}

// 搜索关键字文本框onfocus, onblur 事件
function setSoKeywords(A,E){
	var V = A.value.trim();
	if(!A.defaultValue) A.defaultValue = V;
	if(V != A.defaultValue && V != '') return ;
	A.value = E == 'focus' ? '' : A.defaultValue;
	setCls(A, 'soKeyFocus', E != 'focus');
	
}

//按比例缩放图片
function resizeImage(img,fitWidth,fitHeight,self){
	fitWidth = fitWidth || 600;
	
	var tempImg = new Image();
	tempImg.src = img.src;
	var scale=1.0;
	var width=0,height=0;

	if(document.all){
		if(tempImg.readyState=='complete'){
			width = tempImg.width;
			height = tempImg.height;
		}
	}
	else(tempImg.complete)
	{
		width = tempImg.width;
		height = tempImg.height;
	}
	if(fitWidth < width){
		scale = width/height;
		if(width > fitWidth){
			width = fitWidth;
			height = width/scale; 
			if(height > fitHeight)
			{
			  height = fitHeight;
			  width = height*scale;
			}
		}
		if(height > fitHeight){
			height = fitHeight;
			width = height*scale;
		}
		if(width==0 || height==0){width = fitWidth;height = fitHeight;}
		img.width = width;
		img.height = height;
		img.style.width = width + 'px';
		img.style.height = height + 'px';
	}
	if(self){
		var x = parseInt((fitWidth - width) / 2);
		var y = parseInt((fitHeight - height) / 2);
		img.style.marginTop = y + 'px';
		img.style.marginLeft = x + 'px';
	}else{
		img.parentNode.style.width = width + 'px';
	}
}
function setImageView(img, width, desc){resizeImage(img, width)}


//字体控制大小
function doZoom(size){
	document.getElementById('zoom').style.fontSize=size+'px'
}

