$(document).ready(function(){
    initContentSidebar();
});

var imgdir = "http://www.biscue.net/images/style/";

function initContentSidebar(){
  var imgplus = imgdir+"bulletplus.gif";
  var imgminus = imgdir+"bulletminus.gif";
  var imgdefault = imgplus;

  $("ul#mediamenu>li").each(function(){
    $(">ul:first", $(this)).attr("class") == "open" ? imgdefault = imgminus : imgdefault = imgplus;
    var bullet = $('<a href="#"></a>').addClass("toggle").append($("<img>").attr({"src":imgdefault,"width":"11px","height":"11px"}).addClass("bulletimg"));
    $(">ul:first", $(this)).parent().prepend(bullet);
  });

  $("ul#mediamenu>li>a.toggle").click(function(){
    $(">ul", $(this).parent()).toggleClass("open");
    var bullet = $("img", $(this));
    (bullet.attr("src")==imgminus) ? bullet.attr({"src":imgplus}) : bullet.attr({"src":imgminus});
    return false;
  });

  $("ul#genremenu>li").each(function(){
    $(">ul:first", $(this)).attr("class") == "open" ? imgdefault = imgminus : imgdefault = imgplus;
    var bullet = $('<a href="#"></a>').addClass("toggle").append($("<img>").attr({"src":imgdefault,"width":"11px","height":"11px"}).addClass("bulletimg"));
    $(">ul:first", $(this)).parent().prepend(bullet);
  });

  $("ul#genremenu>li>a.toggle").click(function(){
    $(">ul", $(this).parent()).toggleClass("open");
    var bullet = $("img", $(this));
    (bullet.attr("src")==imgminus) ? bullet.attr({"src":imgplus}) : bullet.attr({"src":imgminus});
    return false;
  });
};


function el_kyk(){
    var dw,dh,w,h,x,val;
    dw = screen.width;
    dh = screen.height;
    if(!dw){dw = 800;}
    if(!dh){dh = 600;}
    w = 480;
    h = Math.round(dh * 0.9);
    x = Math.round((dw - w) * 0.98);
    val = "left=" + x + ",top=0,width=" + w + ",height=" + h + ",scrollbars=1,resizable=1";
    ekykwindow = window.open("http://www.biscue.net/bcelekyk.html","ekyk",val);
    ekykwindow.focus();
}

function k_kyk(){
    var dw,dh,w,h,x,val;
    dw = screen.width;
    dh = screen.height;
    if(!dw){dw = 800;}
    if(!dh){dh = 600;}
    w = 480;
    h = Math.round(dh * 0.9);
    x = Math.round((dw - w) * 0.98);
    val = "left=" + x + ",top=0,width=" + w + ",height=" + h + ",scrollbars=1,resizable=1";
    kkykwindow = window.open("http://www.biscue.net/bckkyk.html","kkyk",val);
    kkykwindow.focus();
}

function r_kyk(){
    var dw,dh,w,h,x,val;
    dw = screen.width;
    dh = screen.height;
    if(!dw){dw = 800;}
    if(!dh){dh = 600;}
    w = 480;
    h = Math.round(dh * 0.9);
    x = Math.round((dw - w) * 0.98);
    val = "left=" + x + ",top=0,width=" + w + ",height=" + h + ",scrollbars=1,resizable=1";
    rkykwindow = window.open("http://biscue.net/bcrkyk.html","rkyk",val);
    rkykwindow.focus();
}

var zooming;

function showImg(id){
	
	if(zooming){
		hideImg(zooming);
	}
	
	var y = window.pageYOffset || (window.document.documentElement.scrollTop || window.document.body.scrollTop);
	var windowHeight = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
	var zoomY = y + windowHeight/2;

	$("#"+id).animate({top : zoomY});
	$("#"+id).show("fast");
	
	zooming = id;
}
function hideImg(id){
	$("#"+id).hide();
	zooming = null;
}

$(function(){
	var eyecatch_icon = imgdir+'media_tab_eyecatch.png';

	jQuery.each($('#medias li span'), function(k,val) {
		var text = $(val).text();
		$(val).html('<img src="'+eyecatch_icon+'">'+text);
	});

});

