var Cookie = new Object();
Cookie.setCookie = function (C, E, D) {
	var F = C + "=" + encodeURIComponent(E);
	if (D) {
		if (D.expireDays) {
			var B = new Date();
			var A = D.expireDays * 24 * 3600 * 1000;
			B.setTime(B.getTime() + A);
			F += "; expires=" + B.toGMTString();
		} else {
			F += "; expires=" + D;
		}
		if (D.path) {
			F += "; path=" + D.path;
		}
		if (D.domain) {
			F += "; domain" + D.domain;
		}
		if (D.secure) {
			F += "; true";
		}
	}
	document.cookie = F;
};

Cookie.getCookie = function (C) {
	var B = document.cookie.split("; ");
	var E = new Object();
	for (var D = 0; D < B.length; D++) {
		var A = B[D].split("=");
		if (A[0] == C) {
			return decodeURIComponent(A[1]);
		}
	}
	return "";
};

Cookie.deleteCookie = function(A) {
	this.setCookie(A, "", {expireDays: -1})
};

function windowOpenCenter(href, width, height) {
  var ex;
  try {
    var left = (screen.width - width) / 2,
      top = (screen.height - height) / 2,
      param = 'fullscreen=0, resizable=0, scrollbars=0, width=' + width + ', height=' + height + ', left=' + left + ', top=' + top;
    window.open(href, 'alimp3', param);
    return false;
  } catch (ex) {
    return false;
  }
}

function setImgSize(B, D, A) {
	var G = D;
	var E = A;
	var F = B.offsetHeight / B.offsetWidth;
	var C = B.offsetWidth / B.offsetHeight;
	if (B.offsetWidth > G) {
		B.width = G;
		B.height = G * F;
	}
	if (B.offsetHeight > E) {
		B.height = E;
		B.width = E * C;
	}
}

var _VENDOR = 100102;
var _cV = Cookie.getCookie("www_yahoo_cn_userid");

function JSlog(o) {
	o = o || {};
	var e = encodeURIComponent,
			b = new Image(),
			sQ = "",
			sV = "";
	
	if (typeof DEFINED_PARAMS !== "undefined") {
		for (v in DEFINED_PARAMS) {
			if (!o[v]) {
				sQ += v + "=" + DEFINED_PARAMS[v] + "&";
			}
		}
	}
	
	if (/bid=([^&]+)/.test(location.search)) {
		var bid = RegExp.$1;
		if (/^\d+$/.test(bid)) {
			sQ += "bd=" + bid + "&";
		}
	}
	
	for (v in o) {
		switch (v) {
			case "q":
			case "oq":
			case "bs":
				sV = e(o[v].replace(/<[^<>]+>/g, ""));
			break;
			
			case "u":
				sV = escape(o[v]);
			break;
			
			default:
				sV = o[v];
		}
		sQ += v + "=" + sV + "&";
	}
	
	b.src = "http://click.s.aliyun.com/0.gif?v=" + _VENDOR + "&c=" + _cV + "&" + sQ + "vr=1&t=" + new Date().getTime();
	return true;
}

$().ready(function() {
	$(".ttabcon li a").live("click", function() {
		var p = $.trim($("#p").val());
		
		if (p.length > 0) {
			var q = encodeURIComponent(p);
			
			if (this.href.indexOf("q=") != -1) {
				this.href = this.href.replace(/q=[^&$]*/, "q=" + q);
			} else {
				this.href += "?q=" + q;
			}
		}
	});
});

