function toggle(pId){
 var display=document.getElementById(pId).style.display;
 if(display=='none')
 {
   document.getElementById(pId).style.display='block';
 }
 else{
    document.getElementById(pId).style.display='none';
 }
}
function showMenu(pId){
  document.getElementById(pId).style.display='block';
}
function hideMenu(pId){
  document.getElementById(pId).style.display='none';
}

function imgShow(pSrc) {
  var z = pSrc.src;
  var len = z.length;
  var tmp = '';
  
  len -= 5;
  z.charAt(len) == '0' ? tmp = '1' : tmp = '0';
  pSrc.src = z.substr(0, len) + tmp + z.substr(len + 1, z.length - 1);
}
// print fragment strony
 function Prnt(x){
  var i,strefa=document.getElementById('strefaDrukowania'),
  W=strefa.getElementsByTagName('div')
  for(i=0;i<W.length;i++)
  W[i].className=x.parentNode==W[i]?'print':'noprint'
  window.print()
}
//print in new window

 function PrntNewWin(x){
  location.replace(x);
  window.print();
}
// print strone
 function Print(){
  window.print()
}
// formularz kontaktowy
function checkContactForm(pStr) {
  var form = document.forms[pStr];
  var msg = '';
  
  if (form.fName.value == '') msg += '- brak imienia i nazwiska\n';
  if (form.fSubject.value == '') msg += '- brak tematu wiadomo�ci\n';
  if (form.fEmail.value == '') msg += '- brak adresu email\n';
  if (form.fMessage.value == '') msg += '- brak tre�ci wiadomo�ci\n';
  
  if (msg != '') {
    alert('B��d:\n' + msg);
    return false;
  } else return true;
}
//

// nowe okno
function openWindow(pName, pUrl, pWidth, pHeight) {
  win = window.open(pUrl, pName, 'menubar=no, toolbar=no, location=no, scrollbars=no, resizable=no, status=no, width=' + pWidth + ', height=' + pHeight + ', left=30, top=30');
  win.focus();
}

//dodaje klase 'hover' do element pId
function addHover(pId){
  $('#menu_item_' + pId + '_1').addClass('hover');
}
//usuwa klase 'hover' z element pId
function removeHover(pId){
  $('#menu_item_' + pId + '_1').removeClass('hover');
}
// zaznaczenie aktywnej pozycji menu strony
function selectActiveMenu(pId) {
	var tElements = new Array();
	var el;
	var el_parent;
	var it = 3;
	var i = 0;
	var res = false;
	var j = 1;
	var gl = 4;

	//$('#menu_item_' + pId + '_1').removeClass('current');
	//$('#menu_item_' + pId + '_1 a').removeClass('current');
	$('#menu_item_' + pId + '_1').addClass('aktywne_menu');
}

function PokazUkryjDaneFirmy(id){
	var select = document.getElementById(id).value;
	var dane_firmy = $('#kontrahent_company_data');
	if ((select == 'hurtowy') || (select == 'dostawca')){
		dane_firmy.show();
	} else {
		dane_firmy.hide();
	}
}

function CzyWygenerowacHaslo(komunikat){
	if (confirm(komunikat)){ 
		document.forms['fnew_password'].submit();
	} else {
		return false;
	}
}
