﻿var address = document.location.href.toLowerCase();
var file = address.substr(address.lastIndexOf("/") + 1);
file = file.substr(0, file.lastIndexOf("."));
if (file.indexOf("-") > -1) {
    file = file.substr(0, file.indexOf("-"));
}
var nameArr = new Array(10);
nameArr[0] = "default";
nameArr[1] = "musicclasstype|latest|hot|musicclass|song|mv|musicclasspreview|musciclass|musictheme|musicclassdetail|songdetail|mvlastestdetail|mvdetail|photo";
nameArr[2] = "creation";
nameArr[3] = "activity|event|vote|themeactivity|onlineactivity|eventdetail|votedetail|eventmember|eventphoto";
nameArr[4] = "news|newsdetail";
nameArr[5] = "musicclassrecommend|musicclassrecommenddetail|refereedetail";
nameArr[6] = "artisttop|artistlist|info";
nameArr[7] = "user|construction";
nameArr[8] = "about|companynews|companynewsdetail|awarditem|awarditemdetail|group|seller|recruit|copyright|privacy|use|help|link|ad|contactus|guestbook|sellerdetail|blog|aboutmuko";
nameArr[9] = "c|cinfo|cusercheck|result";
nameArr[10] = "award";
var pageIDs = "Default,Music,Creation,Activity,News,Recommend,Artist,User,About,Authentication,Award";
var idArr = pageIDs.split(",");
var on = false;
for (i = 0; i < nameArr.length; i++) {
    var obj = document.getElementById(idArr[i]);
    if (i == 0) {
        obj.className = "menu-left";
    }
    if (i == nameArr.length - 1) {
        obj.className = "menu-right";
    }
    if (nameArr[i].indexOf("|") > -1) {
        var arr2 = nameArr[i].split("|");
        for (j = 0; j < arr2.length; j++) {
            if (file == arr2[j]) {
                if (i == 0) {
                    obj.className = "menu-left-on";
                }
                else if (i == nameArr.length - 1) {
                    obj.className = "menu-right-on";
                }
                else {
                    obj.className = "menu-on";
                }
                on = true;
                break;
            }
        }
    }
    else {
        if (file == nameArr[i]) {
            if (i == 0) {
                obj.className = "menu-left-on";
            }
            else if (i == nameArr.length - 1) {
                obj.className = "menu-right-on";
            }
            else {
                obj.className = "menu-on";
            }
            on = true;
        }
    }
}
if (!on) {
    var obj = document.getElementById(idArr[0]);
    obj.className = "menu-left-on";
}
//键盘搜索
function KeySearch() {
    if (event.keyCode == 13) {
        SearchClick();
    }
}
//搜索
function SearchClick() {
    var keyword = document.getElementById("Keyword").value;
    if (keyword != "") {
        var searchType = document.getElementById("SearchType").value;
        var url = "/Search/" + encodeURI(keyword) + ".html";
        switch (searchType) {
            case "0":
                url = "/MusicClass" + url;
                break;
            case "1":
                url = "/Mv" + url;
                break;
            case "2":
                url = "/Song" + url;
                break;
            case "3":
                url = "/ArtistSearch" + url;
                break;
            default:
                break;
        }
        window.location.href = url;
    }
    else {
        alert("请输入搜索关键字");
    }
}
//字符处理
function UrlEncode(Content) {
    var i = 0;
    var Result = "";
    var Temp;
    while (i < Content.length) {
        Temp = Content.charCodeAt(i);
        if (Temp > 255) {
            Temp = "0000" + Temp.toString(16);
            Result += "%u" + Temp.substr(Temp.length - 4, 4).toUpperCase();
        }
        else {
            Result += Content.substr(i, 1);
        }
        i++;
    }
    return Result;
}

function show(obj) {
    var Cont = "show" + obj;
    ContAll = "show" + obj;
    document.getElementById(Cont).style.display = "none";
    document.getElementById(ContAll).style.display = "";
    Cont = ContAll;
}
function none(obj) {
    var Cont = "show" + obj;
    ContAll = "show" + obj;
    document.getElementById(Cont).style.display = "";
    document.getElementById(ContAll).style.display = "none";
    Cont = ContAll;
}
///插入flash
function DisplayFlash(url, width, height, parameter) {
    document.write('<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="' + width + '" height="' + height + '"> ');
    document.write('<param name="movie" value="' + url + '">');
    document.write('<param name="quality" value="high"> ');
    document.write('<param name="wmode" value="transparent"> ');
    document.write('<param name="FlashVars" value="' + parameter + '">');
    document.write('<param name="menu" value="false"> ');
    document.write('<embed src="' + url + '" quality="high" FlashVars="' + parameter + '" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' + width + '" height="' + height + '" wmode="transparent"></embed> ');
    document.write('</object> ');
}