function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=1,statusbar=1,menubar=0,resizable=1,width=600,height=400,left = 240,top = 212');");
}

// ################## Timer Plugini Başla ##################
jQuery.timer = function(time,func,callback){
    var a = {timer:setTimeout(func,time),callback:null}
    if(typeof(callback) == 'function'){a.callback = callback;}
    return a;
};
jQuery.clearTimer = function(a){
    clearTimeout(a.timer);
    if(typeof(a.callback) == 'function'){a.callback();};
    return this;
};
// ################## Timer Plugini Bitir ##################
function mp3_cal(elm, id, sanatci, sarki, url)
{
    $('#player_div').html('<center><img src="yukleniyor.gif" alt="Yükleniyor..." style="width: 433px; height: 13px;" /></center>');
    $.ajax({
        type: "POST",
        url: "index.php?youtube_flv=true",
        data: "url=" + url,
        success: function(gelen) {
            $('#mp3url').val(gelen);
            $('#mp3artist').val(sanatci);
            $('#mp3title').val(sarki);
            player_bas();
        }
    });
    $.ajax({
        type: "POST",
        url: "index.php?istatistik_guncelle=true",
        data: "sarki=" + sarki,
        success: function(mesaj) {}
    });
    var diger = '';
    for (i = 0; i < 20; i++) {
        if (i != id) {
            $('#' + elm + i).hide(600);
            if ($('#' + elm + i).css('display') == 'block') diger = 'var';
        }
        
    }
    if (diger) {
        $.timer(500, function() {
            $('#' + elm + id).slideToggle(500);
        });
    } else {
        $('#' + elm + id).slideToggle(500);
    }
    return false;
}
function mp3_cal2(sanatci, sarki, url)
{
    $('#player_div').html('<center><img src="yukleniyor.gif" alt="Yükleniyor..." style="width: 433px; height: 13px;" /></center>');
    $.ajax({
        type: "POST",
        url: "index.php?youtube_flv=true",
        data: "url=" + url,
        success: function(gelen) {
            $('#mp3url').val(gelen);
            $('#mp3artist').val(sanatci);
            $('#mp3title').val(sarki);
            player_bas();
        }
    });
    $.ajax({
        type: "POST",
        url: "index.php?istatistik_guncelle=true",
        data: "sarki=" + sarki,
        success: function(mesaj) {}
    });
}
function ziyaretci_player(url)
{ 
    $.ajax({
        type: "POST",
        url: "index.php?youtube_flv=true",
        data: "url=" + url,
        success: function(gelen) {
            var flashvars = {
                width:              '433',
                height:             '20',
                file:               encodeURIComponent(gelen),
                type:               'flv',
                overstretch:        'false', 
                autostart:          'true',
                showstop:           'true',
                showicons:          'true',
                showdigits:         'true',
                backcolor:          '0xffffff', 
                frontcolor:         '0xC90044', 
                lightcolor:         '0xC90044', 
                screencolor:        '0xC90044',
                smoothing:          'true',
                deblocking:         '3'
            };
            var params = {}
            swfobject.embedSWF('mediaplayer.swf', 'player', '433', '20', '9.0.115', false, flashvars, params, false);
        }
    });
}
function urlencode(str) {
    str = (str+'').toString();
    return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').                                                             replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}

var def = 'Aramak istediğiniz şarkıyı yazın...';
function aramaform() 
{
    var aranan = document.getElementById('arama').value;
    if (aranan && aranan != def)
        location.href = site_url+'/ara/' + aranan;
}

$(document).ready(function() {
    $(".panel").hide();
    $(".panel2").hide();
    $("#ara_text").focus(function () {
         if ($("#ara_text").val() == def) {
            $("#ara_text").val('');
         }
    });
    $("#ara_text").blur(function () {
         if ($("#ara_text").val() == '') {
            $("#ara_text").val(def);
         }
    });
});
function base64_encode(data) {
    var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
    var o1, o2, o3, h1, h2, h3, h4, bits, i = 0, ac = 0, enc="", tmp_arr = [];
    if (!data) { return data; }
    data = this.utf8_encode(data+'');
    do {
        o1 = data.charCodeAt(i++);
        o2 = data.charCodeAt(i++);
        o3 = data.charCodeAt(i++);
        bits = o1<<16 | o2<<8 | o3; 
        h1 = bits>>18 & 0x3f;
        h2 = bits>>12 & 0x3f;
        h3 = bits>>6 & 0x3f;
        h4 = bits & 0x3f; 
        tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h2) + b64.charAt(h3) + b64.charAt(h4);
    } while (i < data.length);
        enc = tmp_arr.join('');
    switch (data.length % 3) {
        case 1: enc = enc.slice(0, -2) + '==';        break;
        case 2: enc = enc.slice(0, -1) + '=';
        break;
    } 
    return enc;
}