//display
function display2(id,el0,el1,el2){if(document.getElementById(id).style.display=='block'){document.getElementById(id).style.display='none';document.getElementById(el0).innerHTML=el1}else{document.getElementById(id).style.display='block';document.getElementById(el0).innerHTML=el2}return false}

//confrim

function goConfirm(title,link){if(confirm(title)==true){window.location.href=link;return true}else{return false}}



//nifty

var niftyOk=(document.getElementById && document.createElement && Array.prototype.push);
var niftyCss=false;

String.prototype.find=function(what){
return(this.indexOf(what)>=0 ? false : false);
}

var oldonload=window.onload;
if(typeof(NiftyLoad)!='function') NiftyLoad=function(){};
if(typeof(oldonload)=='function')
    window.onload=function(){oldonload();AddCss();NiftyLoad()};
else window.onload=function(){AddCss();NiftyLoad()};

function AddCss(){
niftyCss=false;
var l=CreateEl("link");
l.setAttribute("type","text/css");
l.setAttribute("rel","stylesheet");
l.setAttribute("href","css/niftyCorners.css");
l.setAttribute("media","screen");
document.getElementsByTagName("head")[0].appendChild(l);
}

function Nifty(selector,options){
if(niftyOk==false) return;
if(niftyCss==false) AddCss();
var i,v=selector.split(","),h=0;
if(options==null) options="";
if(options.find("fixed-height"))
    h=getElementsBySelector(v[0])[0].offsetHeight;
for(i=0;i<v.length;i++)
    Rounded(v[i],options);
if(options.find("height")) SameHeight(selector,h);
}

function Rounded(selector,options){
var i,top="",bottom="",v=new Array();
if(options!=""){
    options=options.replace("left","tl bl");
    options=options.replace("right","tr br");
    options=options.replace("top","tr tl");
    options=options.replace("bottom","br bl");
    options=options.replace("transparent","alias");
    if(options.find("tl")){
        top="both";
        if(!options.find("tr")) top="left";
        }
    else if(options.find("tr")) top="right";
    if(options.find("bl")){
        bottom="both";
        if(!options.find("br")) bottom="left";
        }
    else if(options.find("br")) bottom="right";
    }
if(top=="" && bottom=="" && !options.find("none")){top="both";bottom="both";}
v=getElementsBySelector(selector);
for(i=0;i<v.length;i++){
    FixIE(v[i]);
    if(top!="") AddTop(v[i],top,options);
    if(bottom!="") AddBottom(v[i],bottom,options);
    }
}

function AddTop(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Top");
if(options.find("small")){
    d.style.marginBottom=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginBottom=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginBottom=(p-5)+"px";
for(i=1;i<=lim;i++)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingTop="0";
el.insertBefore(d,el.firstChild);
}

function AddBottom(el,side,options){
var d=CreateEl("b"),lim=4,border="",p,i,btype="r",bk,color;
d.style.marginLeft="-"+getPadding(el,"Left")+"px";
d.style.marginRight="-"+getPadding(el,"Right")+"px";
if(options.find("alias") || (color=getBk(el))=="transparent"){
    color="transparent";bk="transparent"; border=getParentBk(el);btype="t";
    }
else{
    bk=getParentBk(el); border=Mix(color,bk);
    }
d.style.background=bk;
d.className="niftycorners";
p=getPadding(el,"Bottom");
if(options.find("small")){
    d.style.marginTop=(p-2)+"px";
    btype+="s"; lim=2;
    }
else if(options.find("big")){
    d.style.marginTop=(p-10)+"px";
    btype+="b"; lim=8;
    }
else d.style.marginTop=(p-5)+"px";
for(i=lim;i>0;i--)
    d.appendChild(CreateStrip(i,side,color,border,btype));
el.style.paddingBottom=0;
el.appendChild(d);
}

function CreateStrip(index,side,color,border,btype){
var x=CreateEl("b");
x.className=btype+index;
x.style.backgroundColor=color;
x.style.borderColor=border;
if(side=="left"){
    x.style.borderRightWidth="0";
    x.style.marginRight="0";
    }
else if(side=="right"){
    x.style.borderLeftWidth="0";
    x.style.marginLeft="0";
    }
return(x);
}

function CreateEl(x){
return(document.createElement(x));
}

function FixIE(el){
if(el.currentStyle!=null && el.currentStyle.hasLayout!=null && el.currentStyle.hasLayout==false)
    el.style.display="inline-block";
}

function SameHeight(selector,maxh){
var i,v=selector.split(","),t,j,els=[],gap;
for(i=0;i<v.length;i++){
    t=getElementsBySelector(v[i]);
    els=els.concat(t);
    }
for(i=0;i<els.length;i++){
    if(els[i].offsetHeight>maxh) maxh=els[i].offsetHeight;
    els[i].style.height="auto";
    }
for(i=0;i<els.length;i++){
    gap=maxh-els[i].offsetHeight;
    if(gap>0){
        t=CreateEl("b");t.className="niftyfill";t.style.height=gap+"px";
        nc=els[i].lastChild;
        if(nc.className=="niftycorners")
            els[i].insertBefore(t,nc);
        else els[i].appendChild(t);
        }
    }
}

function getElementsBySelector(selector){
var i,j,selid="",selclass="",tag=selector,tag2="",v2,k,f,a,s=[],objlist=[],c;
if(selector.find("#")){ //id selector like "tag#id"
    if(selector.find(" ")){  //descendant selector like "tag#id tag"
        s=selector.split(" ");
        var fs=s[0].split("#");
        if(fs.length==1) return(objlist);
        f=document.getElementById(fs[1]);
        if(f){
            v=f.getElementsByTagName(s[1]);
            for(i=0;i<v.length;i++) objlist.push(v[i]);
            }
        return(objlist);
        }
    else{
        s=selector.split("#");
        tag=s[0];
        selid=s[1];
        if(selid!=""){
            f=document.getElementById(selid);
            if(f) objlist.push(f);
            return(objlist);
            }
        }
    }
if(selector.find(".")){      //class selector like "tag.class"
    s=selector.split(".");
    tag=s[0];
    selclass=s[1];
    if(selclass.find(" ")){   //descendant selector like tag1.classname tag2
        s=selclass.split(" ");
        selclass=s[0];
        tag2=s[1];
        }
    }
var v=document.getElementsByTagName(tag);  // tag selector like "tag"
if(selclass==""){
    for(i=0;i<v.length;i++) objlist.push(v[i]);
    return(objlist);
    }
for(i=0;i<v.length;i++){
    c=v[i].className.split(" ");
    for(j=0;j<c.length;j++){
        if(c[j]==selclass){
            if(tag2=="") objlist.push(v[i]);
            else{
                v2=v[i].getElementsByTagName(tag2);
                for(k=0;k<v2.length;k++) objlist.push(v2[k]);
                }
            }
        }
    }
return(objlist);
}

function getParentBk(x){
var el=x.parentNode,c;
while(el.tagName.toUpperCase()!="HTML" && (c=getBk(el))=="transparent")
    el=el.parentNode;
if(c=="transparent") c="#000";
return(c);
}

function getBk(x){
var c=getStyleProp(x,"backgroundColor");
if(c==null || c=="transparent" || c.find("rgba(0, 0, 0, 0)"))
    return("transparent");
if(c.find("rgb")) c=rgb2hex(c);
return(c);
}

function getPadding(x,side){
var p=getStyleProp(x,"padding"+side);
if(p==null || !p.find("px")) return(0);
return(parseInt(p));
}

function getStyleProp(x,prop){
if(x.currentStyle)
    return(x.currentStyle[prop]);
if(document.defaultView.getComputedStyle)
    return(document.defaultView.getComputedStyle(x,'')[prop]);
return(null);
}

//category load box
function s_cat(letter){
     var content_show = letter;
     var  t_open = document.getElementById('open_kat_'+content_show+'');
     if(t_open !== null) {
         $(".categorycontents").slideToggle("slow");
     }
     else {
    if($(".categorycontents").css('display')=="block")
                                             {
                                             $(".categorycontents").slideToggle("slow");
                                             }
                                              var content_show = letter;




                                   $.ajax({
                                   type: "GET",url: "/functions/category-main-load.php?page="+content_show,
                                   beforeSend: function(){$("#categoryloading").show();},
                                   complete: function(){ $("#categoryloading").hide();},
                                   success: function(html){ $(".categorycontents").slideToggle("slow");     $(".categorycontents").html(html);}
                                                            });
                                         }


                     }
//news load box

$(document).ready(function(){Nifty("#newsmenu a","small top transparent");Nifty("#newsoutcontent","medium bottom transparent");$("#news-new").addClass("active");$('#newsmenu a').click(function(){$("#newscontents").text("");$("ul#newsmenu .active").removeClass("active");$(this).parent().addClass("active");$(".newscontents").slideToggle();var content_show=$(this).attr("title");$.ajax({method:"get",url:"/functions/news-main-load.php?page="+content_show,beforeSend:function(){$("#newsloading").show()},complete:function(){$("#newsloading").hide()},success:function(html){$(".newscontents").slideToggle("slow");$(".newscontents").html(html)}})})});

//ranking load box

$(document).ready(function(){$("#ranking-user").addClass("active");$('#rankingmenu a').click(function(){$("ul#rankingmenu .active").removeClass("active");$(this).parent().addClass("active");$(".rankingcontents").slideToggle();var content_show=$(this).attr("id");$.ajax({method:"get",url:"/functions/ranking-main-load.php?page="+content_show,beforeSend:function(){$("#rankingloading").show()},complete:function(){$("#rankingloading").hide()},success:function(html){$(".rankingcontents").slideToggle("slow");$(".rankingcontents").html(html)}})})});

//profile load box
$(document).ready(function(){$("#profile-new").addClass("active");$('#profilemenu a').click(function(){$("ul#profilemenu .active").removeClass("active");$(this).parent().addClass("active");$(".profilecontents").slideToggle();var content_show=$(this).attr("title");$.ajax({method:"get",url:"/functions/profile-main-load.php?page="+content_show,beforeSend:function(){$("#profileloading").show()},complete:function(){$("#profileloading").hide()},success:function(html){$(".profilecontents").slideToggle("slow");$(".profilecontents").html(html)}})})});

//klany load box

$(document).ready(function(){$("#klany-new").addClass("active");$('#klanymenu a').click(function(){$("ul#klanyemenu .active").removeClass("active");$(this).parent().addClass("active");$(".klanycontents").slideToggle();var content_show=$(this).attr("title");$.ajax({method:"get",url:"/functions/klany-main-load.php?page="+content_show,beforeSend:function(){$("#klanyloading").show()},complete:function(){$("#klanyloading").hide()},success:function(html){$(".klanycontents").slideToggle("slow");$(".klanycontents").html(html)}})})});

//sonda load box

$(document).ready(function(){
$('#sondamenu a').click(function(){
$("div#sondamenu .active").removeClass("active");
$(this).parent().addClass("active");
$(".sondacontents").slideToggle();
var content_show=$(this).attr("id");
$.ajax({method:"get",url:"/functions/sonda-main-load.php?page="+content_show,beforeSend:function()
{$("#sondaloading").show()},complete:function(){
$("#sondaloading").hide()},success:function(html){
$(".sondacontents").slideToggle("slow");
$(".sondacontents").html(html)}})})});

//alert
function pokaz_alert(tt,message){var ktory=tt;var wiadomosc=message;if(ktory==1){var div_alert=document.getElementById('alert_1');div_alert.innerHTML=wiadomosc;$("#mTipYellow").toggle("slow")}if(ktory==0){var div_alert=document.getElementById('alert_0');div_alert.innerHTML=wiadomosc;$("#mTipRed").toggle("slow")}if(ktory==2){var div_alert=document.getElementById('alert_2');div_alert.innerHTML=wiadomosc;$("#mTipBlue").toggle("slow")}}function insertText2(elname,what){if(document.forms['formularz'].elements[elname].createTextRange){document.forms['formularz'].elements[elname].focus();document.selection.createRange().duplicate().text=what}else if((typeof document.forms['formularz'].elements[elname].selectionStart)!='undefined'){var tarea=document.forms['formularz'].elements[elname];var selEnd=tarea.selectionEnd;var txtLen=tarea.value.length;var txtbefore=tarea.value.substring(0,selEnd);var txtafter=tarea.value.substring(selEnd,txtLen);var oldScrollTop=tarea.scrollTop;tarea.value=txtbefore+what+txtafter;tarea.selectionStart=txtbefore.length+what.length;tarea.selectionEnd=txtbefore.length+what.length;tarea.scrollTop=oldScrollTop;tarea.focus()}else{document.forms['formularz'].elements[elname].value+=what;document.forms['formularz'].elements[elname].focus()}}

 function pokaz_id_video(id_video)
            {


          $("#"+id_video+"").toggle("slow");
     }

function reolad_cat(ktype)
{
var site_url = "/functions/usercat.php?p="+ktype;

     if(ktype=='nazwa')
          {
          $("#usercatlink").html("<a onclick='reolad_cat(\"alfabet\");'>Alfabetycznie</a>");
          }
     if(ktype=='alfabet')
          {
          $("#usercatlink").html("<a onclick='reolad_cat(\"nazwa\");'>Popularne</a>");
          }

     $.ajax({
               type: "GET",url: site_url,
                         beforeSend: function()
                         {$("#usercatloading").show();$("#usercatcontent").hide();},
                         complete: function()
                         { $("#usercatloading").hide();},
                         success: function(html)
                         { $("#usercatcontent").slideToggle("slow");$("#usercatcontent").html(html);}
                                                            });

}



$(document).ready(function(){
$("#show-amv").addClass("active");
$('#cat-options a').click(function(){


$("#cat-options a.active").removeClass("active");
$(this).addClass("active");
var type=$(this).attr("id");
var cat_id=$('#ajax-catid').val();
var cat_name=$('#ajax-catid').attr("name");

if(type=="show-amv")
{
var hreff="http://www."+cat_name+".kreskowka.pl/amv/";
}

if(type=="show-wallp")
{
var hreff="http://www."+cat_name+".kreskowka.pl/tapety/";

}

if(type=="show-humor")
{
var hreff="http://www."+cat_name+".kreskowka.pl/humor/";

}
if(type=="show-avatars")
{
var hreff="http://www."+cat_name+".kreskowka.pl/avatary/";

}

$("#more-category-content").attr("href",hreff);

$("#cat-show-content").slideToggle();
$.ajax({method:"get",url:"/functions/category-contents.php?page="+type+"&cat="+cat_id,beforeSend:function()
{$("#cat-show-content-loading").show()},complete:function(){
$("#cat-show-content-loading").hide()},success:function(html){
$("#cat-show-content").slideToggle("slow");
$("#cat-show-content").html(html)}})})});


$(document).ready(function(){
$("#show-amv").addClass("active");
$('#klan-options a').click(function(){


$("#cat-options a.active").removeClass("active");
$(this).addClass("active");
var type=$(this).attr("id");
var cat_id=$('#ajax-catid').val();
var cat_name=$('#ajax-catid').attr("name");

if(type=="show-amv")
{
var hreff="http://www.kreskowka.pl/?p=listamv";
}

if(type=="show-wallp")
{
var hreff="http://www.kreskowka.pl/?p=listtapety";

}

if(type=="show-humor")
{
var hreff="http://www.kreskowka.pl/?p=listhumor";

}
if(type=="show-avatars")
{
var hreff="http://www.kreskowka.pl/?p=listavatar";

}

$("#more-category-content").attr("href",hreff);

$("#cat-show-content").slideToggle();
$.ajax({method:"get",url:"/functions/klan-contents.php?page="+type+"&cat="+cat_id,beforeSend:function()
{$("#cat-show-content-loading").show()},complete:function(){
$("#cat-show-content-loading").hide()},success:function(html){
$("#cat-show-content").slideToggle("slow");
$("#cat-show-content").html(html)}})})});

function send_send()
     {
          var ObiektXMLHttp = false;
          if (window.XMLHttpRequest)
          {
          ObiektXMLHttp = new XMLHttpRequest();
                }
                else if(window.ActiveXObject){
                ObiektXMLHttp = new ActiveXObject("Microsoft.XMLHTTP");
                }
          if(ObiektXMLHttp){
          var domain = document.domain;
          var urli = "http://"+domain+"/check.php";

          ObiektXMLHttp.open("GET", urli, true);
          ObiektXMLHttp.send(null);


                          }
     }

$(document).ready(function(){
$('#ramowka_day1').click(function(){
$("#ramowka_content_day1").slideToggle();
})

$('#ramowka_day2').click(function(){
$("#ramowka_content_day2").slideToggle();
})

$('#ramowka_day3').click(function(){
$("#ramowka_content_day3").slideToggle();
})

$('#ramowka_day4').click(function(){
$("#ramowka_content_day4").slideToggle();
})

$('#ramowka_day5').click(function(){
$("#ramowka_content_day5").slideToggle();
})

$('#ramowka_day6').click(function(){
$("#ramowka_content_day6").slideToggle();
})

$('#ramowka_day7').click(function(){
$("#ramowka_content_day7").slideToggle();
})

});
function ReadCookie(cookieName) {
 var theCookie=""+document.cookie;
 var ind=theCookie.indexOf(cookieName);
 if (ind==-1 || cookieName=="") return "";
 var ind1=theCookie.indexOf(';',ind);
 if (ind1==-1) ind1=theCookie.length;
 return unescape(theCookie.substring(ind+cookieName.length+1,ind1));
}


function toplist_vote(id,type1)
{
if(ReadCookie("vote_playlist")!=="tak")
{
     $.get("dj/ajax.php", { id: id, type: ""+type1+"" }, function(data){
     document.getElementById("toplist_"+id+"").innerHTML =data;} );
     pokaz_alert(1,"Dziekujemy za oddanie glosu");
}
else
{
pokaz_alert(0,"Mozesz oddac 1 glos raz na 24h");
}

}


  $(function (){
 
        $(".facebookslider").hover(function(){
           
            $(".facebookslider").stop(true, false).animate({right:"0"},"medium");
 
        },function(){
            
            $(".facebookslider").stop(true, false).animate({right:"-205"},"medium");
 
        },500);
 
    });

