function updateCountyDropdown() {
	if($('#CompanyID')) {
		if($('#CompanyID').val().substr(0, 4) != 'WATE') {
			$('#to-rent-button').attr('onclick', 'return false;').css({ 'background-position': '-84px 0px'});
		} else {
			$('#to-rent-button').attr('onclick', '').css({ 'background-position': '0px 0px'});
		}
	}
}

function changeSrc(el,img){
	if(el!=null){
		el.src=img;
	}
}

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

function czy_usun(linkp,komunikat){
	if(confirm(komunikat)){
		location.href=linkp;
	}
}


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


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

function emotikony_obrazek(pole,znaczek) {
  emotikony_pole=document.getElementById(pole);
  emotikony_pole.value=emotikony_pole.value+znaczek;
  emotikony_pole.focus();
}


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.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=\"\" />'+'</div><\/body><\/html>');

  if( imgWin.focus ) { 
		imgWin.focus(); 
	}
	
  return false;
}

function popup_open(okno,adres,w,h,margines) {

	if(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');
	
	//popup blockers should not cause errors
  if( !imgWin ) { 
		return true; 
	}		
	
  if( imgWin.focus ) { 
		imgWin.focus(); 
	}
	
  return false;	
	
} 

function search_action(cel){

	daneform=document.getElementById('form_home');	
	cp=document.getElementById('p').value=cel;
	document.form_home.submit();

}


function landlords(nr){

	sp7=document.getElementById('landlords_s7');

	if(nr==1){
		document.getElementById('landlords_i1').style.display='';
		document.getElementById('landlords_i2').style.display='';		
		document.getElementById('landlords_i3').style.display='';
		document.getElementById('landlords_i4').style.display='';				
		document.getElementById('landlords_i5').style.display='';
		document.getElementById('landlords_i6').style.display='';		
		document.getElementById('landlords_i7').style.display='';
		document.getElementById('landlords_i8').style.display='';					
		document.getElementById('landlords_i9').style.display='';
		document.getElementById('landlords_i10').style.display='';	
		document.getElementById('landlords_c1').className="landlords_selected";
		document.getElementById('landlords_c2').className="";		
		document.getElementById('landlords_c3').className="";				
		sp7.innerHTML='7';
	} else if(nr==2){
		document.getElementById('landlords_i1').style.display='';
		document.getElementById('landlords_i2').style.display='';		
		document.getElementById('landlords_i3').style.display='';
		document.getElementById('landlords_i4').style.display='';				
		document.getElementById('landlords_i5').style.display='';
		document.getElementById('landlords_i6').style.display='';		
		document.getElementById('landlords_i7').style.display='';
		document.getElementById('landlords_i8').style.display='';					
		document.getElementById('landlords_i9').style.display='none';
		document.getElementById('landlords_i10').style.display='none';			
		document.getElementById('landlords_c2').className="landlords_selected";
		document.getElementById('landlords_c1').className="";		
		document.getElementById('landlords_c3').className="";							
		sp7.innerHTML='7';	
	} else if(nr==3){
		document.getElementById('landlords_i1').style.display='';
		document.getElementById('landlords_i2').style.display='';		
		document.getElementById('landlords_i3').style.display='';
		document.getElementById('landlords_i4').style.display='';				
		document.getElementById('landlords_i5').style.display='';
		document.getElementById('landlords_i6').style.display='none';		
		document.getElementById('landlords_i7').style.display='';
		document.getElementById('landlords_i8').style.display='none';					
		document.getElementById('landlords_i9').style.display='none';
		document.getElementById('landlords_i10').style.display='none';	
		document.getElementById('landlords_c3').className="landlords_selected";
		document.getElementById('landlords_c1').className="";		
		document.getElementById('landlords_c2').className="";										
		sp7.innerHTML='6';		
	} else {
		document.getElementById('landlords_i1').style.display='none';
		document.getElementById('landlords_i2').style.display='none';		
		document.getElementById('landlords_i3').style.display='none';
		document.getElementById('landlords_i4').style.display='none';				
		document.getElementById('landlords_i5').style.display='none';
		document.getElementById('landlords_i6').style.display='none';		
		document.getElementById('landlords_i7').style.display='none';
		document.getElementById('landlords_i8').style.display='none';					
		document.getElementById('landlords_i9').style.display='none';
		document.getElementById('landlords_i10').style.display='none';	
		document.getElementById('landlords_c1').className="";
		document.getElementById('landlords_c2').className="";		
		document.getElementById('landlords_c3').className="";									
		sp7.innerHTML='7';			
	}

}

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

String.prototype.trim=function(){
	var reExtraSpace=/^\s+(.*?)\s+$/;
	return this.replace(reExtraSpace,"$1");
}


function field_clear(field,val,czysc){

	wartosc=document.getElementById(field);
	klasa=wartosc.className;
	
	if(czysc){
		if(wartosc.value==val){
			wartosc.value='';						
		}		
	} else {
		if(wartosc.value==''){			
			wartosc.value=val;			
		}				
	}
	
	if(wartosc.value==val){	
		wartosc.className=klasa.replace("propertyTextFld2 ","propertyTextFld ");	
	} else {
		wartosc.className=klasa.replace("propertyTextFld ","propertyTextFld2 ");	
	}

}

