
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++)
	{
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}

/*#数组添加成员#*/
Array.prototype.add=function(key){
	this[this.length]=key;
};

/*#字符串是否为空 true 为空#*/
function isNone(str){
	return str==null||str.trim()=="" ? true:false;
};

/*#将焦点指定到对应的obj上#*/
function efocu(obj){
	try{$(obj).focus();}catch(e){}
};

/*#插入HTML代码#*/
function insHtm(obj,code,pos){
	obj=$(obj);
	if(isIE){
		obj.parentNode.insertAdjacentHTML(pos==null?"beforeend":"afterbegin",code);
	}
	else{
		var r=obj.ownerDocument.createRange();
		r.setStartBefore(obj);
		eval("obj.parentNode."+(pos==null?"appendChild":"insertBefore")+"(r.createContextualFragment(code),obj.parentNode.firstChild)");
	}
}


/*#查看k1是否在当前字符串中,k2为分割符默认为逗号#*/
String.prototype.inc=function(k1,k2){
	if(k2==null){k2=","};
	return (k2+this+k2).indexOf(k2+k1+k2) > -1 ? true:false;
};

/*#从字符串中截取k1字符串#*/
String.prototype.sub=function(k1,k2){
	if(k2==null){k2=","};
	var tmp = k2 + this + k2;
	var size = tmp.indexOf(k1);
	if(size ==-1){
		return 0;
	}
	var i = 0;
	while(tmp.charAt(size+3+i) != '/'){
		i++;
	}
	return tmp.substring(size+3,size+3+i);
};


function setOpacity(opacity, theID) {
	var object = $(theID).style;
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		if (opacity == 100) { opacity = 99.9999; } // This is majorly awkward
	}
	object.filter = "alpha(opacity=" + opacity + ")"; // IE/Win
	object.opacity = (opacity / 100);                 // Safari 1.2, Firefox+Mozilla
}

function getSize() {
	//var myWidth,myHeight,myScroll;
	if (self.innerHeight) { // Everyone but IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
		myScroll = window.pageYOffset;
	} else if (document.documentElement && document.documentElement.clientHeight) { // IE6 Strict
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
		myScroll = document.documentElement.scrollTop;
	} else if (document.body) { // Other IE, such as IE7
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
		myScroll = document.body.scrollTop;
	}
}


function flashWrite( id, flashUri, vWidth, vHeight, winMode ) {
	var _obj_ = "";
	_obj_ = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + vWidth + '" height="' + vHeight + '" id="' + id + '" align="middle">';
	_obj_ += '<param name="movie" value="' + flashUri + '" />';
	_obj_ += '<param name="quality" value="high" />';
	_obj_ += '<param name="wmode" value="' + winMode + '" />';
	_obj_ += '<param name="bgcolor" value="#ffffff" />';
	_obj_ += '<embed src="' + flashUri + '" quality="high" wmode="' + winMode + '" bgcolor="#ffffff" width="' + vWidth +'" height="' + vHeight + '" id="' + id + '" align="middle" allowscriptaccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></embed>    ';
	_obj_ += '</object>';
	document.write( _obj_ );
}


function layerswich(){	
	if($('boxswitch') === null ) {return;}
	var e, i = 0;
	var evtType = $('boxswitch').getAttribute('evt');	
	while (e = $('boxswitch').getElementsByTagName ('DIV') [i++]) {
		if (e.className == 'on' || e.className == 'off') {
			if(evtType=='click'){
				e.onclick = function () {
					var getEls = $('layer_switch').getElementsByTagName('DIV');
						for (var z=0; z<getEls.length; z++) {
						getEls[z].className=getEls[z].className.replace('show', 'hide');
						getEls[z].className=getEls[z].className.replace('on', 'off');
						}
					this.className = 'on';
					var max = this.getAttribute('title');
					$(max).className = "show";
				}
			}
			else{
				e.onmouseover = function () {
					var getEls = $('layer_switch').getElementsByTagName('DIV');
						for (var z=0; z<getEls.length; z++) {
						getEls[z].className=getEls[z].className.replace('show', 'hide');
						getEls[z].className=getEls[z].className.replace('on', 'off');
						}
					this.className = 'on';
					var max = this.getAttribute('title');
					$(max).className = "show";
				}
			}
		}	
	}

}
