//*仿Select下拉菜单
var sPop = null;
var postSubmited = false;
var smdiv = new Array();

var userAgent = navigator.userAgent.toLowerCase();
var is_webtv = userAgent.indexOf('webtv') != -1;
var is_kon = userAgent.indexOf('konqueror') != -1;
var is_mac = userAgent.indexOf('mac') != -1;
var is_saf = userAgent.indexOf('applewebkit') != -1 || navigator.vendor == 'Apple Computer, Inc.';
var is_opera = userAgent.indexOf('opera') != -1 && opera.version();
var is_moz = (navigator.product == 'Gecko' && !is_saf) && userAgent.substr(userAgent.indexOf('firefox') + 8, 3);
var is_ns = userAgent.indexOf('compatible') == -1 && userAgent.indexOf('mozilla') != -1 && !is_opera && !is_webtv && !is_saf;
var is_ie = (userAgent.indexOf('msie') != -1 && !is_opera && !is_saf && !is_webtv) && userAgent.substr(userAgent.indexOf('msie') + 5, 3);

function tabit(btn){
	var idname = new String(btn.id);
	var s = idname.indexOf("_");
	var e = idname.lastIndexOf("_")+1;
	var tabName = idname.substr(0, s);
	var id = parseInt(idname.substr(e, 1));
	var tabNumber = btn.parentNode.childNodes.length;
	 if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){ 
	 tabNumber = tabNumber-3;
	 }
	for(i=0;i<tabNumber;i++){
			document.getElementById(tabName+"_div_"+i).style.display = "none";
			document.getElementById(tabName+"_btn_"+i).className = "";
		};

		document.getElementById(tabName+"_div_"+id).style.display = "block";
		btn.className = "curr";
};


function findtags(parentobj, tag) {
	if(!isUndefined(parentobj.getElementsByTagName)) {
		return parentobj.getElementsByTagName(tag);
	} else if(parentobj.all && parentobj.all.tags) {
		return parentobj.all.tags(tag);
	} else {
		return null;
	}
}


function $ec(id) {
	return document.getElementById(id);
}

function in_array(needle, haystack) {
	if(typeof needle == 'string') {
		for(var i in haystack) {
			if(haystack[i] == needle) {
					return true;
			}
		}
	}
	return false;
}

function isUndefined(variable) {
	return typeof variable == 'undefined' ? true : false;
}

function doane(event) {
	e = event ? event : window.event ;
	if(is_ie) {
		e.returnValue = false;
		e.cancelBubble = true;
	} else {
		e.stopPropagation();
		e.preventDefault();
	}
}


var jsmenu = new Array();
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);
		}

		if(click && duration) {
			ctrlobj.clickfunc = typeof ctrlobj.onclick == 'function' ? ctrlobj.onclick : null;
			ctrlobj.onclick = function (e) {
				doane(e);
				if(jsmenu['active'][layer] == null || jsmenu['active'][layer].ctrlkey != this.id) {
					if(this.clickfunc) this.clickfunc();
					else showMenu(this.id, true);
				} else {
					hideMenu(layer);
				}
			}
		}

		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) {
	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 = 500;
		if(is_ie && !is_mac) {
			//menuobj.style.filter += "progid:DXImageTransform.Microsoft.shadow(direction=135,color=#CCCCCC,strength=2)";//阴影
		}
		initMenuContents(menuobj);
	}
}

function initMenuContents(menuobj) {
	if(menuobj.title == 'menu') {
		//menuobj.style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)";
		//menuobj.style.opacity = 0.85;
		menuobj.title = '';
	} else {
		var tds = findtags(menuobj, 'div');
		for(var i = 0; i < tds.length; i++) {
			if(tds[i].className == 'popupmenu_option' || tds[i].className == 'editor_colornormal') {
				if(is_ie && !is_mac) {
					//tds[i].style.filter += "progid:DXImageTransform.Microsoft.Alpha(opacity=85,finishOpacity=100,style=0)";
				}
				//tds[i].style.opacity = 0.85;
				if(tds[i].title && tds[i].title == 'nohighlight') {
					tds[i].title = '';
				} else {
					tds[i].ctrlkey = this.ctrlkey;
					if(tds[i].className != 'editor_colornormal') {
						tds[i].onmouseover = menuoption_onmouseover;
						tds[i].onmouseout = menuoption_onmouseout;
					}
					if(typeof tds[i].onclick == 'function') {
						tds[i].clickfunc = tds[i].onclick;
						tds[i].onclick = menuoption_onclick_function;
					} else {
						tds[i].onclick = menuoption_onclick_link;
					}
					if(!is_saf && !is_kon)	{
						try {
							links = findtags(tds[i], 'a');
							for(var j = 0; j < links.length; j++) {
								if(isUndefined(links[j].onclick)) {
									links[j].onclick = ebygum;
								}
							}
						}
						catch(e) {}
					}
				}
			}
		}
	}
}

function showMenu(ctrlid, click, offset, duration, timeout, layer, showid, maxh) {
	var ctrlobj = $ec(ctrlid);
	if(!ctrlobj) return;
	if(isUndefined(click)) click = false;
	if(isUndefined(offset)) offset = 0;
	if(isUndefined(duration)) duration = 2;
	if(isUndefined(timeout)) timeout = 500;
	if(isUndefined(layer)) layer = 0;
	if(isUndefined(showid)) showid = ctrlid;
	var showobj = $ec(showid);
	var menuobj = $ec(showid + '_menu');
	if(!showobj|| !menuobj) return;
	if(isUndefined(maxh)) maxh = 400;
	hideMenu(layer);

	for(var id in jsmenu['timer']) {
		if(jsmenu['timer'][id]) clearTimeout(jsmenu['timer'][id]);
	}

	initCtrl(ctrlobj, click, duration, timeout, layer);
	initMenu(ctrlid, menuobj, duration, timeout, layer);

	menuobj.style.display = '';
	if(!is_opera) {
		menuobj.style.clip = 'rect(auto, auto, auto, auto)';
	}

	var showobj_pos = fetchOffset(showobj);
	var showobj_x = showobj_pos['left'];
	var showobj_y = showobj_pos['top'];
	var showobj_w = showobj.offsetWidth;
	var showobj_h = showobj.offsetHeight;
	var menuobj_w = menuobj.offsetWidth;
	var menuobj_h = menuobj.offsetHeight;

	menuobj.style.left = (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.body.scrollTop + document.body.clientHeight) && (showobj_y - menuobj_h >= 0)) ? (showobj_y - menuobj_h) + 'px' : showobj_y + showobj_h + 'px');

	if(menuobj.style.clip && !is_opera) {
		menuobj.style.clip = 'rect(auto, auto, auto, auto)';
	}

	if(is_ie && is_ie < 7) {
		if(!jsmenu['iframe'][layer]) {
			var iframe = document.createElement('iframe');
			iframe.style.display = 'none';
			iframe.frameBorder='0';
			iframe.style.border='0';
			//iframe.style.border='1px #317108 solid';
			iframe.style.position = 'absolute';
			iframe.scrolling = 'no';
			//iframe.style.height = '190';
			if (document.readyState=="complete") {
			iframe.style.filter = 'progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=90)';
			$ec('jsmenu_parent') ? $ec('jsmenu_parent').appendChild(iframe) : menuobj.parentNode.appendChild(iframe);
			}else{
			setTimeout("showMenu(ctrlid, click, offset, duration, timeout, layer, showid, maxh);", 3000);	
			}
			jsmenu['iframe'][layer] = iframe;
		}
		jsmenu['iframe'][layer].style.top = menuobj.style.top;
		jsmenu['iframe'][layer].style.left = menuobj.style.left;
		jsmenu['iframe'][layer].style.width = menuobj_w;
		//if(ctrlid=='history') {
		//jsmenu['iframe'][layer].style.height = 190;
		//}else
		//{
		jsmenu['iframe'][layer].style.height = menuobj_h;
		//}
		jsmenu['iframe'][layer].style.display = 'block';
	}

	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 hideMenu(layer) {
	if(isUndefined(layer)) layer = 0;
	if(jsmenu['active'][layer]) {
		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+1, 'top' : top_offset+1};
}

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 = findtags(obj, '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();
	}
}

function setsearch(goid,t) {
	$('#m').val(goid);
	$('#cl').val(t);
}

function chktopsearch() {
	var keys = $('#wd').val();
	var goid = $('#m').val();
	if ($.trim(keys) == '' || $.trim(keys) == null || $.trim(keys) == '请输入关键字')
	{
		alert('请输入搜索关键字。');
		$('#wd').focus();
		return false;
	}
	else {
		switch (parseInt(goid))
		{
			case 8:
				var gourl='http://cool.alixixi.com/?selectkey='+escape(keys)+'&amp;m='+goid;
				break;
			case 9:
				var gourl='http://bbs.alixixi.com/search.aspx';
				break;
			default:
				var gourl='http://www.alixixi.com/search.asp?wd='+escape(keys)+'&amp;m='+goid;
				break;
		}
		window.location.href=gourl;
		return false;
	}
}

//*搜索栏默认值
jQuery.fn.toggleVal = function(focusClass) {
	this.each(function() {
		$(this).focus(function() {
			// clear value if current value is the default
			if($(this).val() == this.defaultValue) { $(this).val(""); }
			
			// if focusClass is set, add the class
			if(focusClass) { $(this).addClass(focusClass); }
		}).blur(function() {
			// restore to the default value if current value is empty
			if($(this).val() == "") { $(this).val(this.defaultValue); }
			
			// if focusClass is set, remove class
			if(focusClass) { $(this).removeClass(focusClass); }
		});
	});
}

function EnterSubmit(){
        var _key;
        document.onkeyup = function(e){
            if (e == null) { // ie
                _key = event.keyCode;
            } else { // firefox
                _key = e.which;
            }
            
            if(_key == 13){
                s_submit();
            }
        }
    }
function s_submit() {
  document.getElementById("ss").click();
}
		
//*顶部浮动层效果*//
	var prox;
	var proy;
	var proxc;
	var proyc;

	function showquick(id,x,y){/*--打开--*/
		clearInterval(prox);
		clearInterval(proy);
		clearInterval(proxc);
		clearInterval(proyc);
		if (id!=="fd") {
		document.getElementById('fd').style.display='none';
		}
		if (id!=="se") {
		document.getElementById('se').style.display='none';
		}
		var o = document.getElementById(id);
		if (o.style.display == "none") {
		o.style.display = "block";
		o.style.width = "1px";
		o.style.height = "1px"; 
		prox = setInterval(function(){openx(o,x,y)},10);
		}else {
		closeed(id);
		}
	}	

	function openx(o,x,y){/*--打开x--*/
		var cx = parseInt(o.style.width);
		if(cx < x)
		{
			o.style.width = (cx + Math.ceil((x-cx)/5)) +"px";
		}
		else
		{
			clearInterval(prox);
			proy = setInterval(function(){openy(o,y)},10);
		}
	}
	
	function openy(o,y){/*--打开y--*/	
		var cy = parseInt(o.style.height);
		if(cy < y)
		{
			o.style.height = (cy + Math.ceil((y-cy)/5)) +"px";
		}
		else
		{
			clearInterval(proy);			
		}
	}	
	function closeed(id){/*--关闭--*/
		clearInterval(prox);
		clearInterval(proy);
		clearInterval(proxc);
		clearInterval(proyc);
		var o = document.getElementById(id);
		if(o.style.display == "block")
		{
			proyc = setInterval(function(){closey(o)},10);			
		}		
	}	
	function closey(o){/*--关闭y--*/	
		var cy = parseInt(o.style.height);
		if(cy > 0)
		{
			o.style.height = (cy - Math.ceil(cy/5)) +"px";
		}
		else
		{
			clearInterval(proyc);				
			proxc = setInterval(function(){closex(o)},10);
		}
	}	
	function closex(o){/*--关闭x--*/
		var cx = parseInt(o.style.width);
		if(cx > 0)
		{
			o.style.width = (cx - Math.ceil(cx/5)) +"px";
		}
		else
		{
			clearInterval(proxc);
			o.style.display = "none";
		}
	}	

function getCookie(sMainName, sSubName){ 
    var re = new RegExp((sSubName ? sMainName + "=(.*?&)*?" + sSubName + "=(.*?)(&|;)" : sMainName + "=(.*?);"), "i"); 
    return re.test(unescape(document.cookie)) ? (sSubName ? RegExp["$2"] : RegExp["$1"]) : ""; 
}

function showlogin() {
if (getCookie('dnt','userid')==0||getCookie('dnt','userid')==''||getCookie('dnt','userid')==null) {
	document.write ("您好，欢迎访问阿里西西！<a href=\"http:\/\/www.alixixi.com\/my\/reg.asp\" class=\"hot\">[注册]</a>或<a href=\"http:\/\/www.alixixi.com\/my\" class=\"hot\">[登陆]</a>");	
} else {
//	if (getCookie('dnt','username')==""||getCookie('dnt','nickname')=="") {
	var mname = $.ajax({
  url: "/ajaxservice.asp?at=mname&id=" + getCookie('dnt','userid'),
  async: false
 }).responseText; 
	document.write ("您好，"+mname+"！ <a href=\"http:\/\/www.alixixi.com\/my\/logout.asp\" class=\"hot\">[退出]</a><a href=\"http:\/\/www.alixixi.com\/my\/\" class=\"hot\">[个人中心]</a>");	
//	} else {
//	document.write ("您好，"+getCookie('dnt','nickname')+"！ <a href=\"http:\/\/www.alixixi.com\/my\/logout.asp\" class=\"hot\">[退出]</a><a href=\"http:\/\/www.alixixi.com\/my\/\" class=\"hot\">[个人中心]</a>");	
//	}
}
}

// onclick = \"showquick('fd',500,200);return false;\"

function setCookie(name, value, hours){
var expire = "";
if(hours != null)
{
    expire = new Date((new Date()).getTime() + hours * 3600000);
    expire = "; expires=" + expire.toGMTString();
}
document.cookie = name + "=" + escape(value) + expire;
}


function qiehuan(num){
	for(var id = 0;id<=10;id++)
	{
		if(id==num)
		{
			document.getElementById("qh_con"+id).style.display="block";
			document.getElementById("mynav"+id).className="active";
		}
		else
		{
			document.getElementById("qh_con"+id).style.display="none";
			document.getElementById("mynav"+id).className="nav_web";
		}
	}
}
function curnav(mid) {
switch (parseInt(mid)) {
	case 0:
		qiehuan(0);
		break;
	case 1:
		qiehuan(1);
		break;
	case 11:
		qiehuan(2);
		break;
	case 12:
		qiehuan(3);
		break;
	case 2:
		qiehuan(4);
		break;
	case 13:
		qiehuan(5);
		break;
	case 16:
		qiehuan(6);
		break;
	case 15:
		qiehuan(7);
		break;
	case 555:
		qiehuan(8);
		break;
	case 666:
		qiehuan(9);
		break;
	case 888:
		qiehuan(10);
		break;
	default:
		qiehuan(0);
		break;
}
}

function makeFlashPlayer(src, id, width, height) 
{ 
src = src.replace(" ", ""); 
var TEMP_IMAGE = '<img src="$src$" height="$height$" width="$width$" border="0" />'; 
var TEMP_FLASH = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id=' + id + ' ' 
+ ' codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=4,0,2,0" ' 
+ ' height="$height$" width="$width$"> ' 
+ '<param name="movie" value="$src$" /> ' 
+ '<param name="quality" value="high" /> ' 
+ '<param name="wmode" value="transparent" /> ' 
+ '<EMBED src="$src$" quality="high" WIDTH="$width$" HEIGHT="$height$" ' 
+ ' wmode="opaque" TYPE="application/x-shockwave-flash" ' 
+ ' PLUGINSPAGE="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></EMBED> ' 
+ '</object>'; 
return (/\.swf$/gi.test(src) == true ? TEMP_FLASH : TEMP_IMAGE) 
.replace(/\$src\$/gi, src) 
.replace(/\$width\$/gi, width) 
.replace(/\$height\$/gi, height) 
}