//zmiana obrazka (po najechaniu myszka)
function changeSrc(el,img){
	if(el!=null){
		el.src=img;
	}
}

//zmiana tla
function changeTlo(el,tlo){
	if(el!=null){
		el.className=tlo;
	}
}

//pytaniie czy usunac element
function czy_usun(linkp,komunikat){
	if(confirm(komunikat)){
		location.href=linkp;
	}
}

//zaznaczanie wszystkich checkbox
function zaznacz_checkboxy(formularz,tablica,statusel) {
	var elts=(typeof(formularz.elements[tablica+'[]'])!= 'undefined') ? formularz.elements[tablica+'[]'] : '';
	var elts_cnt = (typeof(elts.length) != 'undefined') ? elts.length : 0;
	if (elts_cnt){
		for (var i = 0; i < elts_cnt; i++){
		 	elts[i].checked=statusel;
		}
  } else {
		elts.checked = statusel;
	}
}

//dodawanie tagow do pola text
function dodajtag(FormName,FieldName,tag,prompttext) {
	if (tag=='b'){ tag_prompt='bold'; }
	if (tag=='i'){ tag_prompt='italic'; }
	inserttext = prompt(prompttext+'\n<'+tag+'>xxx</'+tag+'>','');
	if ((inserttext != null) && (inserttext != '')) {
		document.forms[FormName].elements[FieldName].value += '<'+tag+'>'+inserttext+'</'+tag+'>';
	}
	document.forms[FormName].elements[FieldName].focus();
}

//dodawanie emotikonow do pola text
function emotikony_obrazek(pole,znaczek) {
  emotikony_pole=document.getElementById(pole);
  emotikony_pole.value=emotikony_pole.value+znaczek;
  emotikony_pole.focus();
}

//popup obrazka bez zbednych marginesow
function popup_image(okno,imageURL,imageTitle,w,h,margines){

	if(margines==''){
		$margines=0;
	}

	w=w+(2*margines);
	h=h+(2*margines);
	
	PositionY=(screen.height-h)/2; 
	if (PositionY<0){
		PositionY=0;
	}
	
	PositionX=(screen.width-w)/2; 
	if (PositionY<0){
		PositionY=0;
	}	
	
	
  var imgWin = window.open('',okno,'scrollbars=no,resizable=1,width='+w+',height='+h+',left='+PositionX+',top='+PositionY);
	//popup blockers should not cause errors
  if( !imgWin ) { 
		return true; 
	}

	imgWin.moveTo(PositionX,PositionY);
	imgWin.resizeTo(w,h);	
  imgWin.document.write('<html><head><title>'+imageTitle+'<\/title><\/head><body style="margin:0px; padding:0px; text-align:center"><div style="padding:'+margines+'px">'+'<img src="'+imageURL+'" alt=\"\" style=\"cursor:pointer\" onclick=\"window.close();\" />'+'<\/div><\/body><\/html>');
	
	imgWin.document.close();	
	
  if( imgWin.focus ) { 
		imgWin.focus(); 
	}

}

//zwykly popup centrowany
function popup_open(okno,adres,w,h,margines) {

	if(margines==''||!margines||margines=='undefined'||isNaN(margines)){
		margines=0;
	}

	w=w+margines;
	h=h+margines;

	top_okno=(screen.height-h)/2; 
	if (top_okno<0){
		top_okno=0;
	}
	left_okno=(screen.width-w)/2; 
	
	if (left_okno<0){
		left_okno=0;
	}

	imgWin=window.open(adres,okno,'top='+top_okno+',left='+left_okno+',width='+w+',height='+h+',toolbar=no,menubar=no,location=no,directories=no,alwaysRaised=no,status=no,scrollbars=no,resizable=yes,fullscreen=0');
	
	imgWin.moveTo(left_okno,top_okno);
	imgWin.resizeTo(w,h);	
			
	//popup blockers should not cause errors
  if( !imgWin ) { 
		return true; 
	}		
	
  if( imgWin.focus ) { 
		imgWin.focus(); 
	}

} 


//weryfikacja email
function spr_email(email){
	var forma_email=/^(?:(?:\w\-*)+\.?)*\w+@(?:(?:\w\-*)+\.)+\w{1,4}$/;
	return forma_email.test(email);
}

//funkcja trim
String.prototype.trim=function(){
	return this.replace(/^\s*|\s*$/g,"");
}

//czyszczenie defaultowej wartosci pola formularza
function field_clear(field,val,czysc){

	wartosc=document.getElementById(field);

	if(czysc){
		if(wartosc.value==val){
			wartosc.value='';
		}		
	} else {
		if(wartosc.value==''){
			wartosc.value=val;
		}				
	}
}

//zamykanie reklamy top layer
function adv_close() { 
	adv=document.getElementById('adv_layer');
  adv.style.display='none';
}

//dodawanie do ulubionych w przegladarkach
function dodaj_favorite(tytul,adres) {

 //FireFox
 if (window.sidebar) {
	
 	window.sidebar.addPanel(tytul, adres, "");

 //IE
 } else if (window.external) {
	
 	window.external.AddFavorite(adres, tytul);

 //Opera
 } else if (window.opera && window.print) {
	
 	var a = document.createElement('a'); a.setAttribute('href', adres); a.setAttribute('title', tytul); a.setAttribute('rel','sidebar'); a.click();
	
 }

}


function wlacz_wylacz(id){

	if(id){
	
		element=document.getElementById(id);
		
		if(element){
			if(element.style.display=='none'){
				element.style.display='';
			} else {
				element.style.display="none";
			}
		}
	}
	
}

function gotourl(s)
{
 var gourl = s.options[s.selectedIndex].value;
 if (s.selectedIndex != 0)
 location.href = gourl;
}

/*------------------------------------------------------------
	Document Text Sizer- Copyright 2003 - Taewook Kang.  All rights reserved.
	Coded by: Taewook Kang (txkang.REMOVETHIS@hotmail.com)
	Web Site: http://txkang.com
	Script featured on Dynamic Drive (http://www.dynamicdrive.com)

	Please retain this copyright notice in the script.
	License is granted to user to reuse this code on
	their own website if, and only if,
	this entire copyright notice is included.
--------------------------------------------------------------*/

//Specify affected tags. Add or remove from list:
var tgs = new Array( 'div','td','tr','a','p');

//Specify spectrum of different font sizes:
var szs = new Array( '10px','11px','12px','15px','18px','20px','24px' );
var szlh = new Array( '100%','110%','130%','150%','160%','180%','190%' );
var startSz = 2;

//function ts(trgt,inc,wt) {
//	if (!document.getElementById) return
//	var d = document,cEl = null,sz = startSz,i,j,cTags;
//
//	wt=parseInt(wt);
//
//	if(wt){
//		sz=wt;
//	} else {
//		sz += inc;
//	}
//
//	sz=parseInt(sz);
//
//	if ( sz < 0 ) sz = 0;
//	if ( sz > 6 ) sz = 6;
//	startSz = sz;
//
//	if (!(cEl = d.getElementById( trgt ))) {
//		cEl = d.getElementsByTagName( trgt )[ 0 ];
//	}
//
//	cEl.style.fontSize = szs[ sz ];
//
//	for ( i = 0 ; i < tgs.length ; i++ ) {
//		cTags = cEl.getElementsByTagName( tgs[ i ] );
//		for ( j = 0 ; j < cTags.length ; j++ )
//                {
//                    cTags[ j ].style.fontSize = szs[ sz ];
//                    cTags[ j ].style.lineHeight = szlh[ sz ];
//                }
//	}
//}



function miasto(woj)
{
    
    $.ajax({
      type: "POST",
      url: "index.php",
      data: "akcja=hurtownie_miasto&szuk_woj="+woj,
      cache: false,
      success: function(html){
        $("#miasto").html(html);
      }
    });
}
