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();
}
//

// 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;
	

	try {
		if (typeof $('#menu_item_' + pId + '_' + j).attr('id') != 'undefined') {
			$('#menu_item_' + pId + '_' + j).addClass('active');
		}
	}catch(err){}
	
	try {
		if (typeof $('#sub_menu_item_' + pId).parent().parent().attr('id') != 'undefined') {
			parent = $('#sub_menu_item_' + pId).parent().parent();
			parent.addClass('active');
		}
	}catch(err){}
	

/*
	while ( j < gl && !res ) {  
		i = 0;
		tElements[0] = $('#menu_item_' + pId + '_' + j);

		$('#menu_item_' + pId + '_' + j).addClass('active');

		while ( i < it && !res ) {
			el_parent = tElements[i].parent();//.parent();

			alert(el_parent.attr('id'));

			if ( el_parent.attr('id') == 'main_menu' ) {
				tElements[i].addClass('active');
				res = true;
			} else {
				i++;
				tElements[i] = tElements[i - 1].parent().parent();
			}
		}

		j++;
	}

	
	try{
	$('#li_menu_prev_'+pId).css('display','block');
	$('#li_menu_next_'+pId).css('display','block');
	$('#odstep_'+pId).css('display','none');
	if($('#li_menu_prev_'+pId).prev().hasClass('odstep')){
		$('#li_menu_prev_'+pId).prev().css('display','none');
		//alert($('#menu_prev_'+pId).prev().attr('id'));
	}
	
	if($('#menu_item_' + pId + '_1').hasClass('menu_last')){
		odstep = $('#menu_item_' + pId + '_1').prev().prev();
		odstep.css('display','none');
		
	}
	
	if(typeof $('#sub_menu_item_' + pId).parent().parent().attr('id') != 'undefined'){
	//alert($('#sub_menu_item_' + pId).parent().parent());
		parent = $('#sub_menu_item_' + pId).parent().parent();
		parent.addClass('active');
		
		
		
		if(typeof parent.attr('id') != 'undefined'){
			parentId = parent.attr('id').replace('menu_item_','').split('_1');
			parentId = parentId[0];
			//alert(parentId);
			$('#li_menu_prev_'+parentId).css('display','block');
			$('#li_menu_next_'+parentId).css('display','block');
			$('#odstep_'+parentId).css('display','none');
			//alert($('#odstep_'+parentId).attr('id'));
		}
		
	}
	}catch(err){

	}
	//*/
}

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;
	}
}

function PokazPodmenu(id) {
//alert('kupa');
	$("#"+id).slideDown();
	
}

function SchowajPodmenu(id) {
	//alert('dupa');
		$("#"+id).slideUp();
}	
