﻿function getDate() {
	var d = new Date();
	var Aryweek = ["日", "一", "二", "三", "四", "五", "六"];
	var strweek = Aryweek[d.getDay()];
	return (d.getFullYear()) + "年" + (d.getMonth() + 1) + "月" + d.getDate() + "日" + " 星期" + strweek;
}

function setHomepage() {
	if (document.all) {
		document.body.style.behavior = 'url(#default#homepage)';
		document.body.setHomePage('http://www.ib100.com');
	} else if (window.sidebar) {
		if (window.netscape) {
			try {
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch (e) { alert("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[signed.applets.codebase_principal_support]设置为“true”，点击“加入收藏”后忽略安全提示，即可设置成功。"); }
		}
		var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
		prefs.setCharPref('browser.startup.homepage', 'http://www.ib100.com');
	}
}

var CancelShowMenu, scObj = new Array();
function ShowMenuCancel() {
	if (CancelShowMenu != null)
		clearTimeout(CancelShowMenu);
	//CancelShowMenu = true;
}
function ShowMenu(t, padId, num) {
	CancelShowMenu = window.setTimeout(function() {
		//if (!CancelShowMenu) {
		if (scObj != null) {
			scObj[0].className = "";
		}
		var p = document.getElementById(padId + num);
		scObj[2].scrollTop = p.offsetTop - scObj[1].offsetTop;
		t.className = "on";
		scObj[0] = t;
		//}
	}, 100);
}

//gg
function adclose(id) {
	eval("sf_" + id + "auto=false");
	var btn = $("#" + id + "_btn");
	btn.get(0).onclick = null;
	btn.unbind();
	var a = $("#" + id);
	var aimg = a.children("a").children("img");
	var a2 = $("#" + id + "_2");

	if (btn.data("h") == "1") {
		a2.fadeOut(100, function() {
			var w = a.width();
			var h = aimg.height();
			a.animate({
				height: h,
				width: w,
				opacity: 1
			}, 600, function() {
				btn.css("background-position", "0px 0px").data("h", "0").click(new Function("adclose('" + id + "')"));
			});
		});
	} else {
		a.height()
		a.height(aimg.height());
		a.width(aimg.width());
		var w = a.width();
		var h = a2.height();
		a.animate({
			height: h,
			width: w,
			opacity: 0.5
		}, 600, function() {
			a.css("overflow", "hidden"); a2.fadeIn(100, function() { btn.css("background-position", "0px -15px").data("h", "1").click(new Function("adclose('" + id + "')")); btn = a = aimg = a2 = null; });
		});
	}
}

function ToSearch(sname) {
	var v = document.getElementById(sname).value;
	var vv = v.trim();
	if (vv == "" || vv == "输入搜索内容...") {
		alert("请输入搜索内容");
	} else {
		var searchHref = "http://www.ib100.com/Commodity/Search----------{key}.html";
		var h = searchHref.replaceAll("{key}", encodeURIComponent(v.replaceAll("\\\\", " ").replaceAll("/", " ")));
		switch (document.getElementById("SearhPlat").value) {
			case "1":
				var h = searchHref.replaceAll("{key}", encodeURIComponent(v.replaceAll("\\\\", " ").replaceAll("/", " ")));
				window.open(h, "_blank");
				break;
			case "2":
				var h = "http://www.ib100.com/brand/Searchbrand.aspx?KeyWord=" + encodeURIComponent(v.replaceAll("\\\\", " ").replaceAll("/", " "));
				window.open(h, "_blank");
				break;
			case "3":
				var h = "http://article.ib100.com/plus/search.php?kwtype=0&keyword=" + encodeURIComponent(v.replaceAll("\\\\", " ").replaceAll("/", " "));
				window.open(h, "_blank");
				break;
		}
	}
}
function ToSearchBrand() {
    var v = document.getElementById("SearchText").value;
    var vv = v.trim();
    if (vv == "" || vv == "请输入您要搜索的品牌") {
        alert("请输入搜索内容");
    } else {
        var h = "Searchbrand.aspx?KeyWord=" + encodeURIComponent(v.replaceAll("\\\\", " ").replaceAll("/", " "));
        window.location.href = h;

    }
}