var cookie_name = 0;
var agt = navigator.userAgent.toLowerCase();
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_gecko= (navigator.product == "Gecko");

getObj = function(id) {
	return document.getElementById(id);
}
function $(id) {
	return document.getElementById(id);
}
function ietruebody(){
	return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body;
}
function IsElement(id){
	return document.getElementById(id)!=null ? true : false;
}
function newdiv(idname,width,height,top,left){
	openback();
	var newalert=document.createElement("div");//创建div
	if(!width)width="400px";
	if(!height)height="auto";
	if(!top)top=loadtopleft(width,'top');
	if(!left)left=loadtopleft(width,'left');
	newalert.id=idname;
	newalert.style.position="absolute";
	newalert.style.height=height;
	newalert.style.width=width;
	newalert.style.top=top;
	newalert.style.left=left;
	newalert.style.border="#ECF1F3 2px solid";
	newalert.style.fontSize="12px"
	newalert.style.lineHeight="25px"
	newalert.style.padding="5px"
	newalert.style.zIndex="100"
	newalert.style.visibility ="visible";
	newalert.style.background="#F9FAFB";
	//newalert.style.opacity="0.9"; 
	//newalert.style.filter="alpha(opacity=90)" ;
	var obj='<img src="http://home.emland.net/images/close.gif" title="关闭" style="position:absolute;right:6px;top:5px;cursor:pointer;" id="closed" onmousedown="closeWindow();this.parentNode.style.display=\'none\'"/>';
	newalert.innerHTML=''+obj+'';
	newalert.innerHTML+="<div style=\'position:absolute; top:50%;\'>&nbsp;&nbsp;<img src='http://home.emland.net/images/loading.gif'> 内容读取中，请稍候...</div>";
	document.body.appendChild(newalert);//把创建好的div插入到body节点后，否则newalert会处于游离状态，无法显示；
}
function loadtopleft(divwidth,divtype){//取得正中的top和left
	var ns=(document.layers);
	var ie=(document.all);
	var w3=(document.getElementById && !ie);
	if (ie){
		documentWidth  =ietruebody().offsetWidth/2+ietruebody().scrollLeft-20;
		documentHeight =ietruebody().offsetHeight/2+ietruebody().scrollTop-20;
	} else if (ns){
		documentWidth=window.innerWidth/2+window.pageXOffset-20;
		documentHeight=window.innerHeight/2+window.pageYOffset-20;
	} else if (w3){
		documentWidth=self.innerWidth/2+window.pageXOffset-20;
		documentHeight=self.innerHeight/2+window.pageYOffset-20;
	}
	var de = document.documentElement;
	var w = window.innerWidth || self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
	var h = window.innerHeight || self.innerHeight || (de&&de.clientHeight) || document.body.clientHeight;	
	
	var releft = (w-divwidth.replace("px",""))/2+'px';
	var retop = documentHeight-(h/2)+172 + 'px';
	if(divtype=="left")return releft;
	if(divtype=="top")return retop;
}
function openback(){
	var isIe=(document.all)?true:false;
	if(isIe){   
		setSelectState('hidden');
	}
	var bWidth=parseInt(document.documentElement.scrollWidth);   
	var bHeight=parseInt(document.documentElement.scrollHeight);   
	var back=document.createElement("div");   
	back.id="back";   
	var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";   
	styleStr+=(isIe)?"filter:alpha(opacity=40);":"opacity:0.40;";   
	back.style.cssText=styleStr;   
	document.body.appendChild(back);
}
function closeWindow(){//关闭窗口
	var isIe=(document.all)?true:false;
	if(document.getElementById('back')!=null){   
		document.getElementById('back').parentNode.removeChild(document.getElementById('back'));   
	}   
	if(document.getElementById('mesWindow')!=null){   
		document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));   
	}   
	if(isIe){   
		setSelectState('');
	}
}
function setSelectState(state){//设置select的可见状态  
	var objl=document.getElementsByTagName('select');   
	for(var i=0;i<objl.length;i++)   
	{   
		objl[i].style.visibility=state;   
	}   
}
function goto(url,time){
setTimeout("javascript:location.href='"+url+"'", time);
}
function findPosX(obj){
	var curleft = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x)
		curleft += obj.x;
	return curleft - ietruebody().scrollLeft;
}
function findPosY(obj){
	var curtop = 0;
	if (obj.offsetParent){
		while (obj.offsetParent){
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}else if (obj.y){
		curtop += obj.y;
	}
	return curtop - ietruebody().scrollTop;;
}
function click_open(idName,object,type){
	if(getObj("showmenu").style.display==''){
		closepp();
		return false;
	}
	cookie_name = 1;
	mouseover_open(idName,object,type);
}
function mouseover_open(idName,object,type){

	if(typeof type == "undefined"){
		type = 1;
	}
	if(cookie_name == 1 || type>2){
		obj  = getObj("showmenu");
		obj2 = getObj(idName);
		obj3 = getObj(object);

		var left  = findPosX(obj3) + ietruebody().scrollLeft;
		var top   = findPosY(obj3) + ietruebody().scrollTop;
		
		obj.innerHTML = obj2.innerHTML;
        obj.className = obj2.className;
		obj.style.filter = "alpha(opacity=96);opacity:0.96;";
		obj.style.display = "";
		
		var height = obj.offsetHeight;
		var width  = obj.offsetWidth;
		
		if(left + width > ietruebody().scrollLeft + ietruebody().clientWidth){
			left -= width;
		}
		if(type=='2' && height + top > ietruebody().scrollTop + ietruebody().clientHeight){
			top -= height;
		} else{
			top += type=='4' ? 31 : 15;
		}
		obj.style.top	= top + 'px';
		obj.style.left	= left + 'px';

		if(type>'2'){
			addEvent(document,"mouseout",doc_mouseout);
		} else if(type<'2'){
			addEvent(document,"mousedown",doc_mousedown);
		}
	}
	return false;
}
function closep(type){
	if(typeof type == "undefined"){
		type = 'down';
	}
	cookie_name = 0;
	obj = getObj("showmenu");
	obj.innerHTML = "";
	obj.className = "";
	obj.style.display = "none";
	if(type=='out'){
		removeEvent(document,"mouseout",doc_mouseout);
	} else{
		removeEvent(document,"mousedown",doc_mousedown);
	}
	return false;
}
function closepp(type){
	if(typeof type == "undefined"){
		type = 'down';
	}
	cookie_name = 0;
	obj = getObj("showmenu");
	obj.innerHTML = "";
	obj.className = "";
	obj.style.display = "none";
	if(type=='out'){
		removeEvent(document,"mouseout",doc_mouseout);
	} else{
		removeEvent(document,"mousedown",doc_mousedown);
	}
	return false;
}
function doc_mousedown(e){
	var e = is_ie ? event: e;
	obj	= getObj("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + ietruebody().scrollTop : e.pageY;
	_x1 = obj.offsetLeft;
	_x2 = obj.offsetLeft + obj.offsetWidth;
	_y1 = obj.offsetTop - 25;
	_y2 = obj.offsetTop + obj.offsetHeight;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
		closepp('down');
	}
}
function doc_mouseout(e){
	var e = is_ie ? event: e;
	obj	= getObj("showmenu");
	_x	= is_ie ? e.x : e.pageX;
	_y	= is_ie ? e.y + ietruebody().scrollTop : e.pageY;
	_x1 = obj.offsetLeft - 20;
	_x2 = obj.offsetLeft + obj.offsetWidth + 20;
	_y1 = obj.offsetTop - 35;
	_y2 = obj.offsetTop + obj.offsetHeight + 20;

	if(_x<_x1 || _x>_x2 || _y<_y1 || _y>_y2){
		closepp('out');
	}
}
function addEvent(el,evname,func){
	if(is_ie){
		el.attachEvent("on" + evname,func);
	} else{
		el.addEventListener(evname,func,true);
	}
};
function removeEvent(el,evname,func){
	if(is_ie){
		el.detachEvent("on" + evname,func);
	} else{
		el.removeEventListener(evname,func,true);
	}
};

/*
function ResumeError() { 
return true; 
} 
window.onerror = ResumeError;
*/

var lang = new Array();
var userAgent = navigator.userAgent.toLowerCase();
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko') && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);
var is_mac = userAgent.indexOf('mac') != -1;

function doane(event) {
	e = event ? event : window.event;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else if(e) {
		e.stopPropagation();
		e.preventDefault();
	}
}



var clipboardswfdata;
function setcopy(text, alertmsg){
	if(is_ie) {
		clipboardData.setData('Text', text);
		if(alertmsg) {
			alert(alertmsg);
		}
	} else {
		floatwin('open_clipboard', -1, 300, 110);
		$('floatwin_clipboard_title').innerHTML = '剪贴板';
		str = '<div style="text-decoration:underline;">点此复制到剪贴板</div>' +
			AC_FL_RunContent('id', 'clipboardswf', 'name', 'clipboardswf', 'devicefont', 'false', 'width', '100', 'height', '20', 'src', 'images/common/clipboard.swf', 'menu', 'false',  'allowScriptAccess', 'sameDomain', 'swLiveConnect', 'true', 'wmode', 'transparent', 'style' , 'margin-top:-20px');
		$('floatwin_clipboard_content').innerHTML = str;
		clipboardswfdata = text;
	}
}



function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

var jsmenu = new Array();
var ctrlobjclassName;
jsmenu['active'] = new Array();
jsmenu['timer'] = new Array();
jsmenu['iframe'] = new Array();

function initCtrl(ctrlobj, click, duration, timeout, layer) {
	if(ctrlobj && !ctrlobj.initialized) {
		ctrlobj.initialized = true;
		ctrlobj.unselectable = true;

		ctrlobj.outfunc = typeof ctrlobj.onmouseout == 'function' ? ctrlobj.onmouseout : null;
		ctrlobj.onmouseout = function() {
			if(this.outfunc) this.outfunc();
			if(duration < 3) jsmenu['timer'][ctrlobj.id] = setTimeout('hideMenu(' + layer + ')', timeout);
		}

		ctrlobj.overfunc = typeof ctrlobj.onmouseover == 'function' ? ctrlobj.onmouseover : null;
		ctrlobj.onmouseover = function(e) {
			doane(e);
			if(this.overfunc) this.overfunc();
			if(click) {
				clearTimeout(jsmenu['timer'][this.id]);
			} else {
				for(var id in jsmenu['timer']) {
					if(jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
				}
			}
		}
	}
}

function initMenu(ctrlid, menuobj, duration, timeout, layer, drag) {
	if(menuobj && !menuobj.initialized) {
		menuobj.initialized = true;
		menuobj.ctrlkey = ctrlid;
		menuobj.onclick = ebygum;
		menuobj.style.position = 'absolute';
		if(duration < 3) {
			if(duration > 1) {
				menuobj.onmouseover = function() {
					clearTimeout(jsmenu['timer'][ctrlid]);
				}
			}
			if(duration != 1) {
				menuobj.onmouseout = function() {
					jsmenu['timer'][ctrlid] = setTimeout('hideMenu(' + layer + ')', timeout);
				}
			}
		}
		menuobj.style.zIndex = 999;
		if(drag) {
			menuobj.onmousedown = function(event) {try{menudrag(menuobj, event, 1);}catch(e){}};
			menuobj.onmousemove = function(event) {try{menudrag(menuobj, event, 2);}catch(e){}};
			menuobj.onmouseup = function(event) {try{menudrag(menuobj, event, 3);}catch(e){}};
		}
	}
}

var menudragstart = new Array();
function menudrag(menuobj, e, op) {
	if(op == 1) {
		if(in_array(is_ie ? event.srcElement.tagName : e.target.tagName, ['TEXTAREA', 'INPUT', 'BUTTON', 'SELECT'])) {
			return;
		}
		menudragstart = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
		menudragstart[2] = parseInt(menuobj.style.left);
		menudragstart[3] = parseInt(menuobj.style.top);
		doane(e);
	} else if(op == 2 && menudragstart[0]) {
		var menudragnow = is_ie ? [event.clientX, event.clientY] : [e.clientX, e.clientY];
		menuobj.style.left = (menudragstart[2] + menudragnow[0] - menudragstart[0]) + 'px';
		menuobj.style.top = (menudragstart[3] + menudragnow[1] - menudragstart[1]) + 'px';
		doane(e);
	} else if(op == 3) {
		menudragstart = [];
		doane(e);
	}
}

function showMenu(ctrlid, click, offset, duration, timeout, layer, showid, maxh, drag) {
	var ctrlobj = $(ctrlid);
	if(!ctrlobj) return;
	if(isUndefined(click)) click = false;
	if(isUndefined(offset)) offset = 0;
	if(isUndefined(duration)) duration = 2;
	if(isUndefined(timeout)) timeout = 400;
	if(isUndefined(layer)) layer = 0;
	if(isUndefined(showid)) showid = ctrlid;
	var showobj = $(showid);
	var menuobj = $(showid + '_menu');
	if(!showobj|| !menuobj) return;
	if(isUndefined(maxh)) maxh = 400;
	if(isUndefined(drag)) drag = false;

	if(click && jsmenu['active'][layer] == menuobj) {
		hideMenu(layer);
		return;
	} else {
		hideMenu(layer);
	}

	var len = jsmenu['timer'].length;
	if(len > 0) {
		for(var i=0; i<len; i++) {
			if(jsmenu['timer'][i]) clearTimeout(jsmenu['timer'][i]);
		}
	}

	initCtrl(ctrlobj, click, duration, timeout, layer);
	ctrlobjclassName = ctrlobj.className;
	ctrlobj.className += ' hover';
	initMenu(ctrlid, menuobj, duration, timeout, layer, drag);

	menuobj.style.display = '';
	if(!is_opera) {
		menuobj.style.clip = 'rect(auto, auto, auto, auto)';
	}

	setMenuPosition(showid, offset);

	if(maxh && menuobj.scrollHeight > maxh) {
		menuobj.style.height = maxh + 'px';
		if(is_opera) {
			menuobj.style.overflow = 'auto';
		} else {
			menuobj.style.overflowY = 'auto';
		}
	}

	if(!duration) {
		setTimeout('hideMenu(' + layer + ')', timeout);
	}

	jsmenu['active'][layer] = menuobj;

}

function setMenuPosition(showid, offset) {
	var showobj = $(showid);
	var menuobj = $(showid + '_menu');
	if(isUndefined(offset)) offset = 0;
	if(showobj) {
		showobj.pos = fetchOffset(showobj);
		showobj.X = showobj.pos['left'];
		showobj.Y = showobj.pos['top'];
		if($(InFloat) != null) {
			var InFloate = InFloat.split('_');
			if(!floatwinhandle[InFloate[1] + '_1']) {
				floatwinnojspos = fetchOffset($('floatwinnojs'));
				floatwinhandle[InFloate[1] + '_1'] = floatwinnojspos['left'];
				floatwinhandle[InFloate[1] + '_2'] = floatwinnojspos['top'];
			}
			showobj.X = showobj.X - $(InFloat).scrollLeft - parseInt(floatwinhandle[InFloate[1] + '_1']);
			showobj.Y = showobj.Y - $(InFloat).scrollTop - parseInt(floatwinhandle[InFloate[1] + '_2']);
			InFloat = '';
		}
		showobj.w = showobj.offsetWidth;
		showobj.h = showobj.offsetHeight;
		menuobj.w = menuobj.offsetWidth;
		menuobj.h = menuobj.offsetHeight;
		if(offset < 3) {
			menuobj.style.left = offset == 1 ? (showobj.X + showobj.w + menuobj.w > document.body.clientWidth) && (showobj.X + showobj.w - menuobj.w >= 0) ? showobj.X - menuobj.w - 5 + 'px' : showobj.X + showobj.w + 5 + 'px' :(showobj.X + menuobj.w > document.body.clientWidth) && (showobj.X + showobj.w - menuobj.w >= 0) ? showobj.X + showobj.w - menuobj.w + 'px' : showobj.X + 'px';
			menuobj.style.top = offset == 1 ? showobj.Y + 'px' : (offset == 2 || ((showobj.Y + showobj.h + menuobj.h > document.documentElement.scrollTop + document.documentElement.clientHeight) && (showobj.Y - menuobj.h >= 0)) ? (showobj.Y - menuobj.h) + 'px' : showobj.Y + showobj.h + 'px');
		} else if(offset == 3) {
			menuobj.style.left = (document.body.clientWidth - menuobj.clientWidth) / 2 + document.body.scrollLeft + 'px';
			menuobj.style.top = (document.body.clientHeight - menuobj.clientHeight) / 2 + document.body.scrollTop + 'px';
		}

		if(menuobj.style.clip && !is_opera) {
			menuobj.style.clip = 'rect(auto, auto, auto, auto)';
		}
	}
}

function hideMenu(layer) {
	if(isUndefined(layer)) layer = 0;
	if(jsmenu['active'][layer]) {
		try {
			$(jsmenu['active'][layer].ctrlkey).className = ctrlobjclassName;
		} catch(e) {}
		clearTimeout(jsmenu['timer'][jsmenu['active'][layer].ctrlkey]);
		jsmenu['active'][layer].style.display = 'none';
		if(is_ie && is_ie < 7 && jsmenu['iframe'][layer]) {
			jsmenu['iframe'][layer].style.display = 'none';
		}
		jsmenu['active'][layer] = null;
	}
}

function fetchOffset(obj) {
	var left_offset = obj.offsetLeft;
	var top_offset = obj.offsetTop;
	while((obj = obj.offsetParent) != null) {
		left_offset += obj.offsetLeft;
		top_offset += obj.offsetTop;
	}
	return { 'left' : left_offset, 'top' : top_offset };
}

function ebygum(eventobj) {
	if(!eventobj || is_ie) {
		window.event.cancelBubble = true;
		return window.event;
	} else {
		if(eventobj.target.type == 'submit') {
			eventobj.target.form.submit();
		}
		eventobj.stopPropagation();
		return eventobj;
	}
}

function menuoption_onclick_function(e) {
	this.clickfunc();
	hideMenu();
}

function menuoption_onclick_link(e) {
	choose(e, this);
}

function menuoption_onmouseover(e) {
	this.className = 'popupmenu_highlight';
}

function menuoption_onmouseout(e) {
	this.className = 'popupmenu_option';
}

function choose(e, obj) {
	var links = obj.getElementsByTagName('a');
	if(links[0]) {
		if(is_ie) {
			links[0].click();
			window.event.cancelBubble = true;
		} else {
			if(e.shiftKey) {
				window.open(links[0].href);
				e.stopPropagation();
				e.preventDefault();
			} else {
				window.location = links[0].href;
				e.stopPropagation();
				e.preventDefault();
			}
		}
		hideMenu();
	}
}


//FloatWin
var hiddenobj = new Array();
var floatwinhandle = new Array();
var floatscripthandle = new Array();
var floattabs = new Array();
var floatwins = new Array();
var InFloat = '';
var floatwinreset = 0;
var floatwinopened = 0;
function floatwin(action, script, w, h, scrollpos) {
	var actione = action.split('_');
	action = actione[0];
	if((!allowfloatwin || allowfloatwin == 0) && action == 'open' && w >= 600) {
		location.href = script;
		return;
	}
	var handlekey = actione[1];
	var layerid = 'floatwin_' + handlekey;
	if(is_ie) {
		var objs = $('wrap').getElementsByTagName("OBJECT");
	} else {
		var objs = $('wrap').getElementsByTagName("EMBED");
	}
	if(action == 'open') {
		loadcss('float');
		floatwinhandle[handlekey + '_0'] = layerid;
		if(!floatwinopened) {
			$('wrap').onkeydown = floatwin_wrapkeyhandle;
			for(i = 0;i < objs.length; i ++) {
				if(objs[i].style.visibility != 'hidden') {
					objs[i].setAttribute("oldvisibility", objs[i].style.visibility);
					objs[i].style.visibility = 'hidden';
				}
			}
		}
		scrollpos = !scrollpos ? '' : 'floatwin_scroll(\'' + scrollpos + '\');';
		var clientWidth = document.body.clientWidth;
		var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
		var scrollTop = document.body.scrollTop ? document.body.scrollTop : document.documentElement.scrollTop;
		if(script && script != -1) {
			if(script.lastIndexOf('/') != -1) {
				script = script.substr(script.lastIndexOf('/') + 1);
			}
			var scriptfile = script.split('?');
			scriptfile = scriptfile[0];
			if(floatwinreset || floatscripthandle[scriptfile] && floatscripthandle[scriptfile][0] != script) {
				if(!isUndefined(floatscripthandle[scriptfile])) {
					$('append_parent').removeChild($(floatscripthandle[scriptfile][1]));
					$('append_parent').removeChild($(floatscripthandle[scriptfile][1] + '_mask'));
				}
				floatwinreset = 0;
			}
			floatscripthandle[scriptfile] = [script, layerid];
		}
		if(!$(layerid)) {
			floattabs[layerid] = new Array();
			div = document.createElement('div');
			div.className = 'floatwin';
			div.id = layerid;
			div.style.width = w + 'px';
			div.style.height = h + 'px';
			div.style.left = floatwinhandle[handlekey + '_1'] = ((clientWidth - w) / 2) + 'px';
			div.style.position = 'absolute';
			div.style.zIndex = '999';
			div.onkeydown = floatwin_keyhandle;
			$('append_parent').appendChild(div);
			$(layerid).style.display = '';
			$(layerid).style.top = floatwinhandle[handlekey + '_2'] = ((clientHeight - h) / 2 + scrollTop) + 'px';
			$(layerid).innerHTML = '<div><h3 class="float_ctrl"><em><img src="' + IMGDIR + '/loading.gif"></em><span><a href="javascript:;" class="float_close" onclick="floatwinreset = 1;floatwin(\'close_' + handlekey + '\');">&nbsp</a></span></h3></div>';
			divmask = document.createElement('div');
			divmask.className = 'floatwinmask';
			divmask.id = layerid + '_mask';
			divmask.style.width = (parseInt($(layerid).style.width) + 14) + 'px';
			divmask.style.height = (parseInt($(layerid).style.height) + 14) + 'px';
			divmask.style.left = (parseInt($(layerid).style.left) - 6) + 'px';
			divmask.style.top = (parseInt($(layerid).style.top) - 6) + 'px';
			divmask.style.position = 'absolute';
			divmask.style.zIndex = '998';
			divmask.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(opacity=90,finishOpacity=100,style=0)';
			divmask.style.opacity = 0.9;
			$('append_parent').appendChild(divmask);
			if(script && script != -1) {
				script += (script.search(/\?/) > 0 ? '&' : '?') + 'infloat=yes&handlekey=' + handlekey;
				try {
					ajaxget(script, layerid, '', '', '', scrollpos);
				} catch(e) {
					setTimeout("ajaxget('" + script + "', '" + layerid + "', '', '', '', '" + scrollpos + "')", 1000);
				}
			} else if(script == -1) {
				$(layerid).innerHTML = '<div><h3 class="float_ctrl"><em id="' + layerid + '_title"></em><span><a href="javascript:;" class="float_close" onclick="floatwinreset = 1;floatwin(\'close_' + handlekey + '\');">&nbsp</a></span></h3></div><div id="' + layerid + '_content"></div>';
				$(layerid).style.zIndex = '1099';
				$(layerid + '_mask').style.zIndex = '1098';
			}
		} else {
			$(layerid).style.width = w + 'px';
			$(layerid).style.height = h + 'px';
			$(layerid).style.display = '';
			$(layerid).style.top = floatwinhandle[handlekey + '_2'] = ((clientHeight - h) / 2 + scrollTop) + 'px';
			$(layerid + '_mask').style.width = (parseInt($(layerid).style.width) + 14) + 'px';
			$(layerid + '_mask').style.height = (parseInt($(layerid).style.height) + 14) + 'px';
			$(layerid + '_mask').style.display = '';
			$(layerid + '_mask').style.top = (parseInt($(layerid).style.top) - 6) + 'px';
		}
		floatwins[floatwinopened] = handlekey;
		floatwinopened++;
	} else if(action == 'close' && floatwinhandle[handlekey + '_0']) {
		floatwinopened--;
		for(i = 0;i < floatwins.length; i++) {
			if(handlekey == floatwins[i]) {
				floatwins[i] = null;
			}
		}
		if(!floatwinopened) {
			for(i = 0;i < objs.length; i ++) {
				if(objs[i].attributes['oldvisibility']) {
					objs[i].style.visibility = objs[i].attributes['oldvisibility'].nodeValue;
					objs[i].removeAttribute('oldvisibility');
				}
			}
			$('wrap').onkeydown = null;
		}
		hiddenobj = new Array();
		$(layerid + '_mask').style.display = 'none';
		$(layerid).style.display = 'none';
	} else if(action == 'size' && floatwinhandle[handlekey + '_0']) {
		if(!floatwinhandle[handlekey + '_3']) {
			var clientWidth = document.body.clientWidth;
			var clientHeight = document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
			var w = clientWidth > 800 ? clientWidth * 0.9 : 800;
			var h = clientHeight * 0.9;
			floatwinhandle[handlekey + '_3'] = $(layerid).style.left;
			floatwinhandle[handlekey + '_4'] = $(layerid).style.top;
			floatwinhandle[handlekey + '_5'] = $(layerid).style.width;
			floatwinhandle[handlekey + '_6'] = $(layerid).style.height;
			$(layerid).style.left = floatwinhandle[handlekey + '_1'] = ((clientWidth - w) / 2) + 'px';
			$(layerid).style.top = floatwinhandle[handlekey + '_2'] = ((document.documentElement.clientHeight - h) / 2 + document.documentElement.scrollTop) + 'px';
			$(layerid).style.width = w + 'px';
			$(layerid).style.height = h + 'px';
		} else {
			$(layerid).style.left = floatwinhandle[handlekey + '_1'] = floatwinhandle[handlekey + '_3'];
			$(layerid).style.top = floatwinhandle[handlekey + '_2'] = floatwinhandle[handlekey + '_4'];
			$(layerid).style.width = floatwinhandle[handlekey + '_5'];
			$(layerid).style.height = floatwinhandle[handlekey + '_6'];
			floatwinhandle[handlekey + '_3'] = '';
		}
		$(layerid + '_mask').style.width = (parseInt($(layerid).style.width) + 14) + 'px';
		$(layerid + '_mask').style.height = (parseInt($(layerid).style.height) + 14) + 'px';
		$(layerid + '_mask').style.left = (parseInt($(layerid).style.left) - 6) + 'px';
		$(layerid + '_mask').style.top = (parseInt($(layerid).style.top) - 6) + 'px';
	}
}

function floatwin_scroll(pos) {
	var pose = pos.split(',');
	try {
		pagescroll.defaultleft = pose[0];
		pagescroll.defaulttop = pose[1];
		pagescroll.init();
	} catch(e) {}
}

function floatwin_wrapkeyhandle(e) {
	e = is_ie ? event : e;
	if(e.keyCode == 9) {
		doane(e);
	} else if(e.keyCode == 27) {
		for(i = floatwins.length - 1;i >= 0; i--) {
			floatwin('close_' + floatwins[i]);
		}
	}
}

function floatwin_keyhandle(e) {
	e = is_ie ? event : e;
	if(e.keyCode == 9) {
		doane(e);
		var obj = is_ie ? e.srcElement : e.target;
		var srcobj = obj;
		j = 0;
		while(obj.className.indexOf('floatbox') == -1) {
			obj = obj.parentNode;
		}
		obj.id = obj.id ? obj.id : 'floatbox_' + Math.random();
		if(!floattabs[obj.id]) {
			floattabs[obj.id] = new Array();
			var alls = obj.getElementsByTagName("*");
			for(i = 0;i < alls.length;i++) {
				if(alls[i].getAttribute('tabindex') == 1) {
					floattabs[obj.id][j] = alls[i];
					j++;
				}
			}
		}
		if(floattabs[obj.id].length > 0) {
			for(i = 0;i < floattabs[obj.id].length;i++) {
				if(srcobj == floattabs[obj.id][i]) {
					j = e.shiftKey ? i - 1 : i + 1;break;
				}
			}
			if(j < 0) {
				j = floattabs[obj.id].length - 1;
			}
			if(j > floattabs[obj.id].length - 1) {
				j = 0;
			}
			do{
				focusok = 1;
				try{ floattabs[obj.id][j].focus(); } catch(e) {
					focusok = 0;
				}
				if(!focusok) {
					j = e.shiftKey ? j - 1 : j + 1;
					if(j < 0) {
						j = floattabs[obj.id].length - 1;
					}
					if(j > floattabs[obj.id].length - 1) {
						j = 0;
					}
				}
			} while(!focusok);
		}
	}
}

//ShowSelect
function showselect(obj, inpid, t, rettype) {
	if(!obj.id) {
		var t = !t ? 0 : t;
		var rettype = !rettype ? 0 : rettype;
		obj.id = 'calendarexp_' + Math.random();
		div = document.createElement('div');
		div.id = obj.id + '_menu';
		div.style.display = 'none';
		div.className = 'showselect_menu';
		if($(InFloat) != null) {
			$(InFloat).appendChild(div);
		} else {
			$('append_parent').appendChild(div);
		}
		s = '';
		if(!t) {
			s += showselect_row(inpid, '一天', 1, 0, rettype);
			s += showselect_row(inpid, '一周', 7, 0, rettype);
			s += showselect_row(inpid, '一个月', 30, 0, rettype);
			s += showselect_row(inpid, '三个月', 90, 0, rettype);
			s += showselect_row(inpid, '自定义', -2);
		} else {
			if($(t)) {
				var lis = $(t).getElementsByTagName('LI');
				for(i = 0;i < lis.length;i++) {
					s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = this.innerHTML">' + lis[i].innerHTML + '</a><br />';
				}
				s += showselect_row(inpid, '自定义', -1);
			} else {
				s += '<a href="javascript:;" onclick="$(\'' + inpid + '\').value = \'\'">永久</a><br />';
				s += showselect_row(inpid, '7 天', 7, 1, rettype);
				s += showselect_row(inpid, '14 天', 14, 1, rettype);
				s += showselect_row(inpid, '一个月', 30, 1, rettype);
				s += showselect_row(inpid, '三个月', 90, 1, rettype);
				s += showselect_row(inpid, '半年', 182, 1, rettype);
				s += showselect_row(inpid, '一年', 365, 1, rettype);
				s += showselect_row(inpid, '自定义', -1);
			}
		}
		$(div.id).innerHTML = s;
	}
	showMenu(obj.id);
	if(is_ie && is_ie < 7) {
		doane(event);
	}
}

function changedisplay(openid,offid1,offid2,offid3){
	$(openid).style.display="";
	changec(openid+'_menu','s6');

	var img=$(openid).getElementsByTagName('img');//点开相应分类才显示图片
	for(var i=0,l=img.length;i<l;i++){
		if(img[i].getAttribute('topsrc')){
			img[i].src=img[i].getAttribute('topsrc');
			img[i].removeAttribute('topsrc','');
		}
	}
	
	$(offid1).style.display="none";
	changec(offid1+'_menu','s8');
	if(IsElement(offid2)){
		$(offid2).style.display="none";
		changec(offid2+'_menu','s8');
	}
	if(IsElement(offid3)){
		$(offid3).style.display="none";
		changec(offid3+'_menu','s8');
	}
}

function changec(id,newclass){
	$(id).className=newclass;	
}
function changhtml(id,htmlvar){
	$(id).innerHTML = htmlvar;
}
function ifhidden(id){
	var listid = id + "_list";
	var imgid = id + "_img";
	if($(listid).style.display=='none'){
		$(listid).style.display='block';
		$(imgid).className='open';
	}else{
		$(listid).style.display='none';	
		$(imgid).className='close';
	}
}
function offMenu(obj){
	$(obj).style.display="none";
}
function cstrlen(str){
	var len = 0;
	for(var i = 0; i < str.length; i++) {
		len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? 2 : 1;
	}
	return len;
}
function calclen(value, maxlength, minlength){
	var length = cstrlen(value);

	if(length < minlength) {
		$('lengthlimit').innerHTML = '<span style="color: Red;">长度不足 ' + length + ' / ' + minlength + '</span>';
	}else if(length > maxlength) {
		$('lengthlimit').innerHTML = '<span style="color: Red;">内容过长 ' + length + ' / ' + maxlength + '</span>';
	}else {
		$('lengthlimit').innerHTML = '字数统计 ' + length + ' / ' + maxlength;
	}
}
function quickpost(event,plobj,id){
	if((event.ctrlKey && event.keyCode == 13)){
		checkfourm(plobj,id);
	}
}

function changewidth(id,changdu){
	$(id).style.width = changdu;
	if(changdu=='0'){$('starpj').innerHTML='(滑动星星评价)';}
	if(changdu=='30px'){$('starpj').innerHTML='(6分，较差)';}
	if(changdu=='60px'){$('starpj').innerHTML='(7分，一般)';}
	if(changdu=='90px'){$('starpj').innerHTML='(8分，良好)';}
	if(changdu=='120px'){$('starpj').innerHTML='(9分，优秀)';}
	if(changdu=='150px'){$('starpj').innerHTML='(10分，神作)';}
}

function changed(id,type){
	$(id).style.display=type;
}
function changeone(obj,onenum){
	for(var i=1;i<2000;i++){
		if(IsElement(obj+i)){
			$(obj+i).style.display='none';
		}else{	
			break;
		}
	}
	$(obj+onenum).style.display='';
}
function setCookie(name,value){//设置cookie
	var t = new Date();
	t.setTime(t.getTime()+1*3600000);
	document.cookie = name + "=" + value + ";expires=" + t.toGMTString();
}
function getCookieVal(offset){//取得offset位置的cookie值
	var endstr = document.cookie.indexOf (";", offset);
	if(endstr == -1) endstr = document.cookie.length;
	return unescape(document.cookie.substring(offset, endstr));
}
function getCookie(name){//取得名称为name的cookie值
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while(i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) return getCookieVal(j);
		i = document.cookie.indexOf(" ", i) + 1;
		if(i == 0) break;
	}
	return null;
}
