var playUrl = "PPmate://www.ppsportstv.com/channels/config.txt";
//var playUrl = "ppmate://www.ppmate.com/channels/config.txt";
var obj_D = "PPMate.PPMateObj";
//document.onkeypress = go;
 
function go() {
    if(event.keyCode!=13&&event.keyCode!=0){
        return false;
    }
    var s = document.all.s;
    var m = false;
    var d = 0;
    for (i = 0; i < s.length; i++) {
        if (s[i].checked) {
            m = true;
            d = s[i].value;
            break;
        }
    }
    if (!m) {
        alert("请选择查询分类");
        return;
    }
    if (document.all.key.value == "") {
        alert("请输入查询值");
        return;
    }
    //    var r = Math.random();
    //    alert(document.all.keyword.value);
    if (d == 1) {
         document.forms[0].action = "http://www.ppmate.com/search/item.jsp";

        document.forms[0].submit();
    } else if (d == 2) {
	 document.forms[0].action = "http://www.ppmate.com/search/channel.jsp";

        document.forms[0].submit();

    }
    //        document.forms[0].submit();
}

function play(config) {
    var url;
    if (config != "") {
        if (config.indexOf("PCASS") !=-1) {
            url = "ppmates://playpps/id='" + config + "'";
        } else if (config.indexOf("PCASP") !=-1) {
            url = "ppmates://playppl/id='" + config + "'";
        } else {
            url = playUrl.replace("config", config);
        }
    }
    if (obj_exists()) {
        window.location = url;
    } else return false;
}

function subscribe(url) {
    //    alert("静心期待");
    //    alert(url);
    //    return false;
    window.location = url;
}

function obj_exists()
{
    var mbox_object;
    try {
        mbox_object = new ActiveXObject(obj_D);
        return true;
    } catch(e) {
        alert('尊敬的用户请先安装PPMate后，才能正常观赏节目');
        top.open("http://www.ppmate.com/down.html");
        return false;
    }
}

function encode_base64(what)
{
    var base64_encodetable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
    var result = "";
    var len = what.length;
    var x, y;
    var ptr = 0;

    while (len-- > 0)
    {
        x = what.charCodeAt(ptr++);
        result += base64_encodetable.charAt(( x >> 2 ) & 63);

        if (len-- <= 0)
        {
            result += base64_encodetable.charAt(( x << 4 ) & 63);
            result += "==";
            break;
        }

        y = what.charCodeAt(ptr++);
        result += base64_encodetable.charAt(( ( x << 4 ) | ( ( y >> 4 ) & 15 ) ) & 63);

        if (len-- <= 0)
        {
            result += base64_encodetable.charAt(( y << 2 ) & 63);
            result += "=";
            break;
        }

        x = what.charCodeAt(ptr++);
        result += base64_encodetable.charAt(( ( y << 2 ) | ( ( x >> 6 ) & 3 ) ) & 63);
        result += base64_encodetable.charAt(x & 63);

    }

    return result;
}
