﻿function chkInput(){
	var aType = ["曲目名称","歌手名称","专辑名称"];
	var iType = $("#kt").val();
	var sKw = $.trim($('#kw').val());
	if(sKw=="")
		window.alert("请输入要查询的" + aType[iType] + "！");
	else{
		var sUrl = "/Search/?kt=" + iType + "&kw=" + escape(sKw);
		window.location.href = sUrl;
	}
}

function fnKeydown(e){
	var iKey = (window.event) ? e.keyCode : ((e.which)? e.which : 0);
	if(iKey==13){chkInput();}
}
function addFavor(title, url){
		if (document.all)   //IE
			window.external.AddFavorite(url, title);  
		else if (window.sidebar)  //FireFox 
			window.sidebar.addPanel(title, url, "")  
} 
function addToFav(){
	var sTitle = document.title;
	var sUrl = location.href;
	addFavor(sTitle,sUrl);
}

document.writeln("<div class=\"user\"><a href=\"#\" class=\"newreg\">新用户注册<\/a> | <a href=\"#\">登录<\/a> | <a href=\"javascript:void(0);\" onclick=\"addToFav()\">加入收藏夹</a> | <a href=\"javascript:void(0);\" onclick=\"this.style.behavior='url(#default#homepage)';this.setHomePage('http://story.moocity.com/');return(false);\">将本站设为主页</a><\/div>");
document.writeln("<div class=\"search\">");
document.writeln("<strong>站内搜索<\/strong>");
document.writeln("<select name=\"select\" id=\"kt\"  onkeydown=\"fnKeydown(event);\" >");
document.writeln("<option value=\"0\">搜索曲目<\/option>");
document.writeln("<option value=\"1\">搜索歌手<\/option>");
document.writeln("<option value=\"2\">搜索专辑<\/option>");
document.writeln("<\/select>");
document.writeln("<input name=\"kw\" id=\"kw\" type=\"text\" size=\"30\" maxlength=\"30\" class=\"txtKey\" onkeydown=\"fnKeydown(event);\" \/>");
document.writeln("<input type=\"button\" name=\"btnSend\" value=\"确定查找\" class=\"btnSend\" onClick=\"chkInput()\" \/>");
document.writeln("<\/div>");

$(function(){
 $("img").each(function(i){
           this.onerror = function(){ this.src='/templets/default/images/loading.gif';}
    }); 
});