$(document).ready(function() {
  $('div#login a.logon').click(function() {
  	$('div#login-hide').slideToggle();
  	return false;	
  });
  
  $('div#menu-info a').click(function() {
  	$('div#submenu-0').toggle();
  	return false;	
  });
  
  $('div#menu-left .menucat a').click(function() {
  	var s = $('div#submenu-' + this.rel);
    s.slideToggle();
    if (s.attr('rel') != 'show') {
    	product_cat(this.rel);
    	s.attr({ rel: "show"});	
    } else {
    	$('div#dynamic-content').fadeOut('fast').hide();
    	$('div#big').fadeIn('fast').show();
    	s.attr({ rel: ""});}
    return false;
  });

  $('ul#menu-news li.item a').click(function() {
  	$('div.news-block').hide();
    $('div#news-block-' + this.rel).toggle();
	return false;
  });
  
  $('div#menu-top ul li a[title=Witamy], div#menu-top ul li a[title=Welcome]').click(function() {
  	$('div#block-welcome').slideToggle();
  	return false;
  });
  
  $('div#product h5#addfile').click(function() {
  	$('div#product div#addfile-hide').slideToggle();
  	return false;
  });
});

function switchInfo(obj){
        if(document.getElementById){
        var el = document.getElementById(obj);
        var ar = document.getElementById('product').getElementsByTagName('div');
                if(el.style.display != "block"){
                        for (var i=0; i<ar.length; i++){
                                if (ar[i].className=='product-info-block')
                                ar[i].style.display = "none";
                        }
                        el.style.display = "block";
                }/*else{
                        el.style.display = "none";
                }*/
        }
}

function confirm_box(text,l){
	input_box=confirm(text);
		if (input_box==true) {
			parent.location.href=l;
		}
	return;
}

function confirm_del(text) {
	input_box=confirm(text);
		if (input_box==true) {
			return true;
		}
	return false;
}

function product_cat(ID) {
 $.get("/product_cat.php",
 	{ID: ID},
 	function(data) {
 		$('div#big').hide();
        $('div#dynamic-content').hide().html(data).fadeIn('slow');
 });
}

function count_cli(ID) {
 $.post('/click.php',
 	{id: ID},
	function(data){
	window.open(data);}
 );
}

function filter_set(optVal) {
	if (optVal != "0") {
		window.location=optVal;
	}
}