var nazwa_klasy_menu='';

function $$$(e) {
  return document.getElementById(e);
}
function wlacz_menu(e) {
	for (var i=1;i<=9;i++) {
		if (e.id=='menu'+i) {
			//wlacz
			if (!jQuery('#menu'+i).hasClass('over')) {
				jQuery('#menu'+i).addClass('over');
			}
		} else {
			//wylacz
			if (jQuery('#menu'+i).hasClass('over')) {
				jQuery('#menu'+i).removeClass('over');
			}
		}
	}
}
function wylacz_menu(e) {
  if (jQuery('#'+e).hasClass('over')) {
    jQuery('#'+e).removeClass('over');
  }
}


function SendRequest_usun_komentarz(id_komentarza) {
	var dane="";
  dane+="&id_komentarza="+id_komentarza;
  jQuery.ajax({  
    type: "POST",  
    url: global_link+"ajax/usun_komentarz.php",  
    data: dane,  
    success: function(response){
    	$$$("usun_komentarz_odp"+id_komentarza).innerHTML = response;
    }  
  });
}

function SendRequest_ocena(id, rodzaj) {
	var dane="";
  dane+="&id="+id;
  dane+='&rodzaj='+rodzaj;
  dane+='&wyniki=1';
	jQuery.ajax({  
    type: "POST",  
    url: global_link+"ajax/ocena.php",  
    data: dane,  
    success: function(response){
    	//alert(response);
      //alert("ocena_ok_"+rodzaj+"_"+id);
      if ($$$("container_raty_"+id+"_"+rodzaj)) {
				$$$("container_raty_"+id+"_"+rodzaj).innerHTML=response;
			}
    }  
  });  
}

function SendRequest_polecane(id, rodzaj, dodaj) {
	var dane="";
  dane+="dodaj="+dodaj;
  dane+="&id="+id;
  dane+='&rodzaj='+rodzaj;
  
	jQuery.ajax({  
    type: "POST",  
    url: global_link+"ajax/polecane.php",  
    data: dane,  
    success: function(response){
    	//alert(response);
      //alert("ocena_ok_"+rodzaj+"_"+id);
      if ($$$("odp_dodaj_do_polecanych")) {
				$$$("odp_dodaj_do_polecanych").innerHTML=response;
			}
			if (response=='OK') {
				if ($$$("polecane_odp_"+rodzaj+"_"+id)) {
					if (dodaj==1) {
						var srcn=global_link+"style/"+global_styl+"/ik/star.png";
					} else {
						var srcn=global_link+"style/"+global_styl+"/ik/star-empty.png";
					}
					$$$("polecane_odp_"+rodzaj+"_"+id).src=srcn;
				}
			}
    }  
  });  
}

function toggle(item2, stan) {
	var item = document.getElementById(item2);
	if (stan==1) item.style.display = '';
	else if (stan==2) item.style.display = 'none';
	else {
		if (item.style.display == '') {
			item.style.display = 'none';
		} else {
			item.style.display = '';
		}
	}
}

/*Zakladki*/
function zmien_zakladke(prefix, ktory, max) {
	for (var i=1;i<=max;i++) {
		var e = document.getElementById("z_"+prefix+i);
		if (e!=null) {
			if (i==ktory) {
				stan=1;
				e.className='zakladka';
			} else {
				stan=2;
				e.className='zakladka zakladka_off';
			}
			toggle(prefix+i, stan);
		}
	}
}

/*Strona glowna*/
/*Newsy*/
var akt_rodzaj=0;
var akt_item=0;
var s;

function zmien_newsy(rodzaj, item, wylacz) {
	if (wylacz==1) {
		window.clearInterval(s);
	}
	akt_rodzaj=rodzaj;
	akt_item=item;
	for (var i=0;i<4;i++) {
		var e = document.getElementById("zakladka_"+i);
		if (e!=null) {
			if (i==rodzaj) {
				stan=1;
				e.className='zakladka zakladka_on';
			} else {
				stan=2;
				e.className='zakladka';
			}
			toggle("okno_"+i, stan);
		}
	}
	
	for (var i=0;i<5;i++) {
		var e = document.getElementById("numery_"+rodzaj+"_"+i);
		if (e!=null) {
			if (i==item) {
				stan=1;
				e.className='numer numer_on';
			} else {
				stan=2;
				e.className='numer';
			}
			toggle("okno_"+rodzaj+"_"+i, stan);
		}
	}
}
function uruchom_newsy() {
	s = window.setInterval("zmien_newsy_czas();", 10000);
	zmien_newsy(akt_rodzaj, akt_item);
}
function zmien_newsy_czas() {
	if (max[akt_rodzaj]>akt_item) {
		akt_item++;
	} else {
		if (akt_rodzaj==3) {akt_rodzaj=0;}
		else {akt_rodzaj++;}
		akt_item=0;
	}
	zmien_newsy(akt_rodzaj, akt_item);
}

/*Artykuly*/
var art_akt_rodzaj=0;
var art_akt_item=0;
var art_s;

function zmien_newsy_art(rodzaj, item, wylacz){
	if (wylacz == 1) {
		window.clearInterval(art_s);
	}
	art_akt_rodzaj = rodzaj;
	art_akt_item = item;
	for (var i = 0; i < 1; i++) {
		var e = document.getElementById("zakladka_art_" + i);
		if (e != null) {
			if (i == rodzaj) {
				stan = 1;
				//e.className = 'zakladka zakladka_on';
			}
			else {
				stan = 2;
				//e.className = 'zakladka';
			}
			toggle("okno_art_" + i, stan);
		}
	}
	
	for (var i = 0; i < 8; i++) {
		var e = document.getElementById("numery_art_" + rodzaj + "_" + i);
		if (e != null) {
			if (i == item) {
				stan = 1;
				e.className = 'miniatura miniatura_on';
			}
			else {
				stan = 2;
				e.className = 'miniatura';
			}
			toggle("okno_art_" + rodzaj + "_" + i, stan);
		}
	}
}
function uruchom_newsy_art() {
	art_s = window.setInterval("zmien_newsy_czas_art();", 10000);
	zmien_newsy_art(art_akt_rodzaj, art_akt_item);
}
function zmien_newsy_czas_art() {
	if (art_max[art_akt_rodzaj]>art_akt_item) {
		art_akt_item++;
	} else {
		if (art_akt_rodzaj==0) {art_akt_rodzaj=0;}
		else {art_akt_rodzaj++;}
		art_akt_item=0;
	}
	zmien_newsy_art(art_akt_rodzaj, art_akt_item);
}

/*Tematy specjalne*/
var ts_akt_rodzaj=0;
var ts_akt_item=0;
var ts_s;

function zmien_newsy_ts(rodzaj, item, wylacz){
	if (wylacz == 1) {
		window.clearInterval(ts_s);
	}
	ts_akt_rodzaj = rodzaj;
	ts_akt_item = item;
	for (var i = 0; i < 1; i++) {
		var e = document.getElementById("zakladka_ts_" + i);
		if (e != null) {
			if (i == rodzaj) {
				stan = 1;
				//e.className = 'zakladka zakladka_on';
			}
			else {
				stan = 2;
				//e.className = 'zakladka';
			}
			toggle("okno_ts_" + i, stan);
		}
	}
	
	for (var i = 0; i <=ts_max[ts_akt_rodzaj]; i++) {
		//alert(i);
		var e = document.getElementById("numery_ts_" + rodzaj + "_" + i);
		//alert(e+' '+"numery_ts_" + rodzaj + "_" + i);
		if (e != null) {
			if (i == item) {
				stan = 1;
				e.className = 'miniatura miniatura_on';
			}
			else {
				stan = 2;
				e.className = 'miniatura';
			}
			toggle("okno_ts_" + rodzaj + "_" + i, stan);
		}
	}
}
function uruchom_newsy_ts() {
	ts_s = window.setInterval("zmien_newsy_czas_ts();", 10000);
	zmien_newsy_ts(ts_akt_rodzaj, ts_akt_item);
}
function zmien_newsy_czas_ts() {
	if (ts_max[ts_akt_rodzaj]>ts_akt_item) {
		ts_akt_item++;
	} else {
		if (ts_akt_rodzaj==0) {ts_akt_rodzaj=0;}
		else {ts_akt_rodzaj++;}
		ts_akt_item=0;
	}
	zmien_newsy_ts(ts_akt_rodzaj, ts_akt_item);
}


/*Przepisy*/
var prz_akt_rodzaj=0;
var prz_akt_item=0;
var prz_s;

function zmien_newsy_prz(rodzaj, item, wylacz){
	if (wylacz == 1) {
		window.clearInterval(prz_s);
	}
	prz_akt_rodzaj = rodzaj;
	prz_akt_item = item;
	for (var i = 0; i < 1; i++) {
		var e = document.getElementById("zakladka_prz_" + i);
		if (e != null) {
			if (i == rodzaj) {
				stan = 1;
				//e.className = 'zakladka zakladka_on';
			}
			else {
				stan = 2;
				//e.className = 'zakladka';
			}
			toggle("okno_prz_" + i, stan);
		}
	}
	
	for (var i = 0; i <=prz_max[prz_akt_rodzaj]; i++) {
		//alert(i);
		var e = document.getElementById("numery_prz_" + rodzaj + "_" + i);
		//alert(e+' '+"numery_prz_" + rodzaj + "_" + i);
		if (e != null) {
			if (i == item) {
				stan = 1;
				e.className = 'miniatura miniatura_on';
			}
			else {
				stan = 2;
				e.className = 'miniatura';
			}
			toggle("okno_prz_" + rodzaj + "_" + i, stan);
		}
	}
}
function uruchom_newsy_prz() {
	prz_s = window.setInterval("zmien_newsy_czas_prz();", 10000);
	zmien_newsy_prz(prz_akt_rodzaj, prz_akt_item);
}
function zmien_newsy_czas_prz() {
	if (prz_max[prz_akt_rodzaj]>prz_akt_item) {
		prz_akt_item++;
	} else {
		if (prz_akt_rodzaj==0) {prz_akt_rodzaj=0;}
		else {prz_akt_rodzaj++;}
		prz_akt_item=0;
	}
	zmien_newsy_prz(prz_akt_rodzaj, prz_akt_item);
}

/*Najnowsze artykuły*/
var nart_akt_rodzaj=0;
var nart_akt_item=0;
var nart_s;

function zmien_newsy_nart(rodzaj, item, wylacz){
	if (wylacz == 1) {
		window.clearInterval(nart_s);
	}
	nart_akt_rodzaj = rodzaj;
	nart_akt_item = item;
	for (var i = 0; i < 1; i++) {
		var e = document.getElementById("zakladka_nart_" + i);
		if (e != null) {
			if (i == rodzaj) {
				stan = 1;
				//e.className = 'zakladka zakladka_on';
			}
			else {
				stan = 2;
				//e.className = 'zakladka';
			}
			toggle("okno_nart_" + i, stan);
		}
	}
	
	for (var i = 0; i <=nart_max[nart_akt_rodzaj]; i++) {
		//alert(i);
		var e = document.getElementById("numery_nart_" + rodzaj + "_" + i);
		//alert(e+' '+"numery_nart_" + rodzaj + "_" + i);
		if (e != null) {
			if (i == item) {
				stan = 1;
				e.className = 'miniatura miniatura_on';
			}
			else {
				stan = 2;
				e.className = 'miniatura';
			}
			toggle("okno_nart_" + rodzaj + "_" + i, stan);
		}
	}
}
function uruchom_newsy_nart() {
	nart_s = window.setInterval("zmien_newsy_czas_nart();", 10000);
	zmien_newsy_nart(nart_akt_rodzaj, nart_akt_item);
}
function zmien_newsy_czas_nart() {
	if (nart_max[nart_akt_rodzaj]>nart_akt_item) {
		nart_akt_item++;
	} else {
		if (nart_akt_rodzaj==0) {nart_akt_rodzaj=0;}
		else {nart_akt_rodzaj++;}
		nart_akt_item=0;
	}
	zmien_newsy_nart(nart_akt_rodzaj, nart_akt_item);
}



// Copyright (C) 2005-2008 Ilya S. Lyubinskiy. All rights reserved.
// Technical support: http://www.php-development.ru/
//
// YOU MAY NOT
// (1) Remove or modify this copyright notice.
// (2) Re-distribute this code or any part of it.
//     Instead, you may link to the homepage of this code:
//     http://www.php-development.ru/javascripts/dropdown.php
//
// YOU MAY
// (1) Use this code on your website.
// (2) Use this code as part of another product.
//
// NO WARRANTY
// This code is provided "as is" without warranty of any kind.
// You expressly acknowledge and agree that use of this code is at your own risk.


// ***** Popup Control *********************************************************

// ***** at_show_aux *****

function at_show_aux(parent, child)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child );

  var top  = (c["at_position"] == "y") ? p.offsetHeight+2 : 0;
  var left = (c["at_position"] == "x") ? p.offsetWidth +2 : 0;

  for (; p; p = p.offsetParent)
  {
    top  += p.offsetTop;
    left += p.offsetLeft;
  }

  c.style.position   = "absolute";
  c.style.top        = top +'px';
  c.style.left       = left+'px';
  //c.style.visibility = "visible";
  c.style.zIndex	=30000;
  jQuery('#'+child).slideDown('fast');
}

// ***** at_show *****

function at_show()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  
  wlacz_menu(p);

  at_show_aux(p.id, c.id);
  clearTimeout(c["at_timeout"]);
}

// ***** at_hide *****

function at_hide()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);
  
  var nazwa=this["at_parent"];
  
  //var txt="document.getElementById('"+c.id+"').style.visibility = 'hidden'; ";
  var txt="at_hide_aux('"+c.id+"'); ";
  if (nazwa.substring(0,4)=='menu') {
    txt=txt+" wylacz_menu('"+p.id+"');";
  }
  c["at_timeout"] = setTimeout(txt, 333);
}

function at_hide_aux(child) {
   jQuery('#'+child).slideUp('fast');
}
// ***** at_click *****

function at_click()
{
  var p = document.getElementById(this["at_parent"]);
  var c = document.getElementById(this["at_child" ]);

  if (c.style.visibility != "visible") at_show_aux(p.id, c.id); else c.style.visibility = "hidden";
  
  return false;
}

// ***** at_attach *****

// PARAMETERS:
// parent   - id of the parent html element
// child    - id of the child  html element that should be droped down
// showtype - "click" = drop down child html element on mouse click
//            "hover" = drop down child html element on mouse over
// position - "x" = display the child html element to the right
//            "y" = display the child html element below
// cursor   - omit to use default cursor or specify CSS cursor name

function at_attach(parent, child, showtype, position, cursor)
{
  var p = document.getElementById(parent);
  var c = document.getElementById(child);

  p["at_parent"]     = p.id;
  c["at_parent"]     = p.id;
  p["at_child"]      = c.id;
  c["at_child"]      = c.id;
  p["at_position"]   = position;
  c["at_position"]   = position;

  c.style.position   = "absolute";
  //c.style.visibility = "hidden";
  jQuery('#'+child).hide();

  if (cursor != undefined) p.style.cursor = cursor;

 
  switch (showtype)
  {
    case "click":
      p.onclick     = at_click;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
    case "hover":
      p.onmouseover = at_show;
      p.onmouseout  = at_hide;
      c.onmouseover = at_show;
      c.onmouseout  = at_hide;
      break;
  }
}

function document_ready() {
	jQuery(function() {
    jQuery(function() {
	  	jQuery(".tt").tipTip({
	  		delay:0,
	  		defaultPosition:"top",
	  	});
	  });
	});
	jQuery(function() {
		jQuery("#form_komentarz").submit(function(event) {
			event.preventDefault(); 
			var dane=jQuery("#form_komentarz").serialize();
			jQuery.ajax({  
		    type: "POST",  
		    url: global_link+"ajax/komentarz.php",  
		    data: dane,
		    success: function(response){
		    	jQuery("#form_komentarz_odp").html(response);
		    	jQuery("#form_komentarz_odp").slideDown('fast');
		    	setTimeout('jQuery("#form_komentarz_odp").slideUp("fast");',3000);
		    }  
		  });
		});
	});
}


