﻿//-------------tip.js
var ns4 = document.layers;
var ns6 = document.getElementById && !document.all;
var ie4 = document.all;
offsetX = 0;
offsetY = 20;
var toolTipSTYLE="";

function initToolTips() {
    
    if(ns4||ns6||ie4) {
        if(ns4) toolTipSTYLE = document.toolTipLayer;
        else if(ns6) toolTipSTYLE = document.getElementById("toolTipLayer").style;
        else if(ie4) toolTipSTYLE = document.all.toolTipLayer.style;
        else toolTipSTYLE = document.getElementById("toolTipLayer").style;

        if(ns4) {
            document.captureEvents(Event.MOUSEMOVE);
        }
        else {
            toolTipSTYLE.visibility = "visible";
            toolTipSTYLE.display = "none";
        }
        document.onmousemove = moveToMouseLoc;
        
    }
}

function toolTip(msg, fg, bg) {
    if(toolTip.arguments.length < 1) {// hide         
        if(ns4) toolTipSTYLE.visibility = "hidden";
        else toolTipSTYLE.display = "none";
    }
    else {// show
        if(!fg) fg = "#999900";
        if(!bg) bg = "#FFFFFF";
        var content =
        '<table border="0" cellspacing="0" cellpadding="1" bgcolor="' + fg + '"><td>' +
        '<table border="0" cellspacing="0" cellpadding="3" bgcolor="' + bg + '">' +
        '<td align="left" CLASS=tip><font face="sans-serif" color="' + fg +
        '">&nbsp\;' + msg +
        '&nbsp\;</font></td></table></td></table>';
        if(ns4) {
        toolTipSTYLE.document.write(content);
        toolTipSTYLE.document.close();
        toolTipSTYLE.visibility = "visible";
        }
        if(ns6) {
            document.getElementById("toolTipLayer").innerHTML = content;
            toolTipSTYLE.display='block'
        }
        if(ie4) {
            document.all("toolTipLayer").innerHTML=content;
            toolTipSTYLE.display='block'
        }
        
    }
}

function moveToMouseLoc(e) {

    if(ns4||ns6) {
        x = e.pageX;
        y = e.pageY;
    }
    else {
        x = event.x + document.documentElement.scrollLeft ;
        y = event.y + document.documentElement.scrollTop ;
    }
    
    toolTipSTYLE.left = x + offsetX;
    toolTipSTYLE.top = y + offsetY;
    return true;
    
}

//搜索
function search(stxt)
{
    var url = "";
    //alert(arguments.length);
    if (arguments.length == 0)
    {
        var txt = $("#search_txt").attr("value");
    }
    else
    {
        var txt = stxt;
    }
    switch(SearchNow)
    {
        case 1: //音乐
            url="http://search.163888.net/?type=music&q=" + txt;
            break;
        case 2: //图片
            url="http://search.163888.net/?type=photo&q=" + txt;
            break;
        case 3: //视频
            url="http://search.163888.net/?type=video&q=" + txt;
            break;
        case 4: //伴奏
            url="http://search.163888.net/?type=accompaniment&q=" + txt;
            break;
        case 5: //娱乐圈
            url="http://search.163888.net/UTFToGB.aspx?SType=Club&KeyWord=" + txt;
            break;
        case 6: //用户
            url="http://search.163888.net/?type=user&q=" + txt;
            break;
    }
    window.open(encodeURI(url));
}

var SearchNow = 1;
var SearchOld = 0;
function search_tab(tab)
{
    if (tab != SearchNow)
    {
        //alert(SearchOld + " " + tab);
        if(SearchOld > 0)
        {
            $("#serach_tab" + SearchOld).html("<a href=\"javascript:void(0);\">" + $("#serach_tab" + SearchOld).text() + "</a>" + "|");
        }

        $("#serach_tab" + SearchNow).removeClass();
        $("#serach_tab" + SearchNow).html("<a href=\"javascript:void(0);\">" + $("#serach_tab" + SearchNow).text().replace("|","") + "</a>" + "|");
        $("#key_area" + SearchNow).hide();

        SearchNow = tab;
        $("#serach_tab" + tab).addClass("on");
        $("#serach_tab" + tab).html($("#serach_tab" + tab).text().replace("|",""));
        $("#search_txt").attr("value","请输入您要搜索的" + $("#serach_tab" + tab).text().replace("|","") + "名称");
        $("#key_area" + tab).show();
        
        if(tab > 1)
        {   var temp = tab - 1;
            $("#serach_tab" + temp).html("<a href=\"javascript:void(0);\">" + $("#serach_tab" + temp).text().replace("|","") + "</a>" + " ");
            SearchOld = temp;
        }
    }
}

var HotNow = 1;
var HotOld = 0;
function hot_tab(tab)
{
    if (tab != HotNow)
    { 
        if (HotOld > 0)
        {
            $("#hot_tab" + HotOld).html("<a href=\"javascript:void(0);\">" + $("#hot_tab" + HotOld).text() + "</a>" + "|");
        }

        $("#hot_tab" + HotNow).removeClass();
        $("#hot_tab" + HotNow).html("<a href=\"javascript:void(0);\">" + $("#hot_tab" + HotNow).text().replace("|","") + "</a>" + "|");
        $("#hot_area" + HotNow).hide();
        HotNow = tab;
        
        $("#hot_tab" + tab).addClass("on");
        $("#hot_tab" + tab).html($("#hot_tab" + tab).text().replace("|",""));
        $("#hot_area" + tab).show();

        if(tab > 1)
        {   var temp = tab - 1;
            $("#hot_tab" + temp).html("<a href=\"javascript:void(0);\">" + $("#hot_tab" + temp).text().replace("|","") + "</a>" + " ");
            HotOld = temp;
        }
    }
}

function change_tab(name,tab)
{
    var temp = 1;
    if (tab == 1){temp = 2;}
    
    var tabName = "#" + name + "_tab";
    var areaName = "#" + name + "_area"

    $(tabName + temp).removeClass();
    $(tabName + temp).html("<a href=\"javascript:void(0);\">" + $(tabName + temp).text() + "</a>");
    $(areaName + temp).hide();
    
    $(tabName + tab).addClass("on");
    $(tabName + tab).html($(tabName + tab).text());
    $(areaName + tab).show();
}

function change_tabs(name,tab,count)
{
    var temp = 1;
    //if (tab == 1){temp = 2;}
    
    var tabName = "#" + name + "_tab";
    var areaName = "#" + name + "_area";

    for (i=1;i<=count;i++)
    {
        $(tabName + i).removeClass();
        $(tabName + i).html("<a href=\"javascript:void(0);\">" + $(tabName + i).text() + "</a>");
        $(areaName + i).hide();
    }
    
    $(tabName + tab).addClass("on");
    $(tabName + tab).html($(tabName + tab).text());
    $(areaName + tab).show();
}
