﻿//--活页代码--
	function getNames(obj,name,tij)
	{	
		var p = document.getElementById(obj);
		var plist = p.getElementsByTagName(tij);
		var rlist = new Array();
		for(i=0;i<plist.length;i++)
		{
			if(plist[i].getAttribute("name") == name)
			{
				rlist[rlist.length] = plist[i];
			}
		}
		return rlist;
	}

		function huoye(obj,name)
		{
			var p = obj.parentNode.getElementsByTagName("td");
			var p1 = getNames(name,"f","table");
			for(i=0;i<p1.length;i++)
			{
				if(obj==p[i])
				{
					p[i].className = "s";
					p1[i].className = "show";
				}
				else
				{
					p[i].className = "";
					p1[i].className = "unshow";
				}
			}
		}
		function huoyea(obj,name)
		{
			var p = obj.parentNode.getElementsByTagName("td");
			var p1 = getNames(name,"fa","div");
			for(i=0;i<p1.length;i++)
			{
				if(obj==p[i])
				{
					p[i].className = "sa";
					p1[i].className = "show";
				}
				else
				{
					p[i].className = "";
					p1[i].className = "unshow";
				}
			}
		}
		function huoyeb(obj,name)
		{
			var p = obj.parentNode.getElementsByTagName("td");
			var p1 = getNames(name,"fb","div");
			for(i=0;i<p1.length;i++)
			{
				if(obj==p[i])
				{
					p[i].className = "sb";
					p1[i].className = "show";
				}
				else
				{
					p[i].className = "";
					p1[i].className = "unshow";
				}
			}
		}
//--活页代码结束-->

/*menu start*/
function LMYC() {
	var lbmc;
	for (i=1;i<=number;i++) {
		lbmc = eval('LM' + i);
		lbmc.style.display = 'none';
	}
}
function ShowFLT(i) {
	lbmc = eval('LM' + i);
	if (lbmc.style.display == 'none') {
		LMYC();
		lbmc.style.display = '';
	}
	else {
		lbmc.style.display = 'none';
	}
}
/*menu end*/


function goNavTab(cat){
    var list;
    list = document.getElementsByTagName("li");
    for(var i=0; i<list.length; i++){
        if(list[i].id.indexOf("navItem_") == 0){
            if(list[i].id == "navItem_" + cat)
                list[i].className = "hot";
            else
                list[i].className = "";
        }
    }
    
    list = document.getElementsByTagName("ul");
    for(var i=0; i<list.length; i++){
        if(list[i].id.indexOf("navSubItem_") == 0){
            if(list[i].id == "navSubItem_" + cat)
                list[i].className = "";
            else
                list[i].className = "displayNone";
        }
    }
}

String.prototype.trim = function()
{
	return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}

String.prototype.len = function()
{
    return this.replace(/[^\x00-\xff]/g,"**").length;
}

function choice(v) {
	if(v > 0) location.href = "index2.php?cate_id=" + v;
}

/*
 * 提交搜索
 */
function gosearch(choice) {
	switch(choice) {
		case 1:
			location.href = 'http://product.5351.net/search.php?keyword=' + escape(s1.value);
			break;
		case 2:
			location.href = 'http://product.5351.net/advice/';
			break;
		case 3:
			location.href = 'http://need.5351.net/search.php?keyword=' + escape(s3.value);
			break;
		case 4:
			break;
	}
}

function newReq() {
	var req = false;
	try {
		req = new XMLHttpRequest();
	} catch (trymicrosoft) {
		try {
			req = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (othermicrosoft) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (failed) {
				req = false;
			}
		}
	}
	return req;
}

function userlogin() {
	var username = document.login.username.value.trim();
	var password = document.login.password.value.trim();
	var xmlHttp = newReq();
	xmlHttp.onreadystatechange = function () {
		if(xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			if(xmlHttp.responseText == 1) {
				location.reload();
			} else {
				location.href = "http://www.5351.net/user/login.html";
			}
		}
	};
	var qurl = "chklogin.php";
	var post = "username=" + username + "&password=" + password;
	xmlHttp.open("POST", qurl, true);
	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlHttp.send(post);
}

function logout() {
	if(confirm('确认退出吗？')) location.href = "logout.php";
}

function building() {
	alert('尚未开通，敬请期待！');
}
