/**
* @desc funkcje obsluguja specyfikacje oraz ustawiaja odp zmienne
* @param none 
* @return none
* @author Dariusz Pidzik <dariusz.pidzik@polconstruct.com>
*/

function moveByTime(pixels,ms){
	
	var prze = document.getElementById('prze');
	var poz = parseInt(prze.style.marginLeft.replace("px",""));
	var endTab = -((maxstrArray-3)*88);
	var step = 2;
	
	if(pixels>=0 && poz>=endTab){
		pixels-=2;	
		prze.style.marginLeft=poz-step+'px';
		setTimeout("moveByTime("+pixels+","+ms+")",ms);	
	}	
}

function moveByTimeBack(pixels,ms){
	
	var prze = document.getElementById('prze');
	var poz = parseInt(prze.style.marginLeft.replace("px",""));
	var startTab = 0;
	var step = 2;
	
		if(pixels>=0 && poz<=0){			
			pixels-=2;		
			prze.style.marginLeft=poz+step+'px';
			setTimeout("moveByTimeBack("+pixels+","+ms+")",ms);			
		}
}

function delTabAll(){
	
	document.getElementById('idShowOffer').value = '';
	document.getElementById('idOffer').value = '';
	document.getElementById('searchForm').submit();
	
}

function delTab(id){
	
	var delId = id;
	var arrayTab = (document.getElementById('idOffer').value).split("|");
	var showTab = document.getElementById('idShowOffer').value;
	var maxarrayTab = arrayTab.length;
	var str = '';
	var str2;
	var flag = 'false';
	
	for(i=0;i<maxarrayTab;i++){
		
		if(arrayTab[i]==delId){
			var flag = 'true';
		}
		
		if(arrayTab[i]!=delId){
			str += arrayTab[i]+'|';
			if(flag=='true'){
				document.getElementById('idShowOffer').value = arrayTab[i];
			}
		}
	}
	
	arrayTabNew = str.substr(0,str.length-1);
	document.getElementById('idOffer').value = arrayTabNew;
	document.getElementById('searchForm').submit();
	
}

function categoryShow(type){

	if(checkHelpStatus!='true'){
	
		var typeCat = type;
		
		if(typeCat==1){
			location = '/';
		}else if(typeCat==2){
			document.getElementById('TopLeftTab1').className='innerTopLeft2';
			document.getElementById('TopLeftTab2').className='innerTopLeftActive';
			document.getElementById('TopLeftTab3').className='innerTopLeft2';
			document.getElementById('TopTab1').className='innerTop2';
			document.getElementById('TopTab2').className='innerTopActive';
			document.getElementById('TopTab3').className='innerTop2';
			document.getElementById('idCategory').value='2';
			
			var sel = document.getElementById('typeTransaction');
						var maxlength = sel.options.length;
						
						for(i=0;i<maxlength;i++){
							if(sel.options[i].value=='44'){
								sel.selectedIndex=i;
								break;
							}
						}
			document.getElementById('idCity').value='';
			document.getElementById('idOffer').value='';
			document.getElementById('idShowOffer').value='';			
			document.getElementById('pricemin').value='';
			document.getElementById('pricemax').value='';
			document.getElementById('areamin').value='';
			document.getElementById('areamax').value='';
							
			document.getElementById('searchForm').submit();
		}else{
			document.getElementById('TopLeftTab1').className='innerTopLeft2';
			document.getElementById('TopLeftTab2').className='innerTopLeft2';
			document.getElementById('TopLeftTab3').className='innerTopLeftActive';
			document.getElementById('TopTab1').className='innerTop2';
			document.getElementById('TopTab2').className='innerTop2';
			document.getElementById('TopTab3').className='innerTopActive';
			
			var sel = document.getElementById('typeTransaction');
						var maxlength = sel.options.length;
						
						for(i=0;i<maxlength;i++){
							if(sel.options[i].value=='44'){
								sel.selectedIndex=i;
								break;
							}
						}	
			document.getElementById('idCategory').value='3';
			document.getElementById('idCity').value='';
			document.getElementById('idOffer').value='';
			document.getElementById('idShowOffer').value='';		
			document.getElementById('pricemin').value='';
			document.getElementById('pricemax').value='';
			document.getElementById('areamin').value='';
			document.getElementById('areamax').value='';
			
			document.getElementById('searchForm').submit();
		}
	}
		checkHelpStatus = 'false';
}

function activeSpec(){
	
	var checkStatus = document.getElementById('advancedSpec').style.display;
	
	if(checkStatus=='block'){
		document.getElementById('advancedSpec').style.display = 'none';
	}else{
		document.getElementById('advancedSpec').style.display = 'block';
	}
	new Draggable('advancedSpec', {});
	
}

function activeMapList(fromDiv){

	document.getElementById(fromDiv).style.display='block';
	document.getElementById('main-content-block').style.height='auto';
	
	if(fromDiv=='showOffer'){
		document.getElementById('showListingOffert').style.display='none';
		document.getElementById('map').style.display='none';
		document.getElementById('menuMapLeftActive1').className='innerTopLeft';
		document.getElementById('menuMapActive1').className='innerTop';
		document.getElementById('menuMapLeftActive2').className='innerTopLeft';
		document.getElementById('menuMapActive2').className='innerTop';
	}else if(fromDiv=='map'){
		document.getElementById('showListingOffert').style.display='none';
		document.getElementById('showOffer').style.display='none';
		document.getElementById('menuMapLeftActive2').className='innerTopLeft';
		document.getElementById('menuMapActive2').className='innerTop';
		document.getElementById('menuMapLeftActive1').className='menuMapLeftActive';
		document.getElementById('menuMapActive1').className='menuMapActive';
		document.getElementById('menuMapActive1').onfocus=blur();
		
	}else if(fromDiv=='showListingOffert'){
		document.getElementById('showOffer').style.display='none';
		document.getElementById('map').style.display='none';
		document.getElementById('menuMapLeftActive1').className='innerTopLeft';
		document.getElementById('menuMapActive1').className='innerTop';
		document.getElementById('menuMapLeftActive2').className='menuMapLeftActive';
		document.getElementById('menuMapActive2').className='menuMapActive';
		document.getElementById('menuMapActive2').onfocus=blur();
	}
	
}

function hiddenshowSpecification(){
	
	if(objectImg==1){
		name = 'Dv';
	}else if(objectImg==2){
		name = 'ReDv';
	}else if(objectImg==3){
		name = 'CP';
	}else if(objectImg==4){
		name = 'RP';
	}else if(objectImg==5){
		name = 'IL';
	}

    var oFirstButton = document.getElementById('firstButton_'+name)   
    var oSecondButton = document.getElementById('secondButton_'+name)   
    oFirstButton.className = 'button-searchType-selected';
    oFirstButton.onmouseout = null; oFirstButton.onmouseover = null;
    oSecondButton.className = 'button-searchType';
    oSecondButton.onmouseout = function() { document.getElementById('secondButton_'+name).className = 'button-searchType' };
    oSecondButton.onmouseover = function() { document.getElementById('secondButton_'+name).className = 'button-searchType-over' };

	document.getElementById('specification_'+name).style.display = 'none';	
	document.getElementById('localization_'+name).style.display = 'block';	

} 

function showSpecification(){

	var deleteDv;
	var deleteReDv;
	var deleteCP;
	var deleteRP;

	if(objectImg==1){
		name = 'Dv';
	}else if(objectImg==2){
		name = 'ReDv';
	}else if(objectImg==3){
		name = 'CP';
	}else if(objectImg==4){
		name = 'RP';
	}else if(objectImg==5){
		name = 'IL';
	}
	
	advAJAX.get({
        url: '/pressitonestate.php/mainproject/createSpec',
		parameters: {
			"objectImg": objectImg,
			"name": name
		},
        onSuccess: function(obj){  	  		
             if (name == 'RP') {
                document.getElementById('main-offers-search-'+name).style.height = '380px';
             }
             var oFirstButton = document.getElementById('firstButton_'+name)   
             var oSecondButton = document.getElementById('secondButton_'+name)   
             oFirstButton.className = 'button-searchType';
             oFirstButton.onmouseout = function() { document.getElementById('firstButton_'+name).className = 'button-searchType' };
             oFirstButton.onmouseover = function() { document.getElementById('firstButton_'+name).className = 'button-searchType-over' };
             oSecondButton.className = 'button-searchType-selected';
             oSecondButton.onmouseout = null; oSecondButton.onmouseover = null;

             document.getElementById('specification_'+name).style.display = 'block';
             document.getElementById('localization_'+name).style.display = 'none';
             
             document.getElementById('specification_'+name).innerHTML = '';       
             document.getElementById('specification_'+name).innerHTML = obj.responseText;
        },
        onError: function(obj){
            alert('Error in function showOffertsListing, error code: '+obj.status);
        }
   });
		
}

function clearOptions(){

	panel_typeAdv = '';
	panel_area = '';
	panel_areamin = '';
	panel_areamax = '';
	panel_price = '';
	panel_pricemin = '';
	panel_pricemax = '';
	globalZoomType = '';	
	kontSet = '';
	panstwoSet = '';
	regionSet ='';
	miastoSet = '';
	
	var oShortOffert = document.getElementById('shortOffert');
	if(oShortOffert != null) {
	   document.getElementById('shortOffert').innerHTML = '';
    }
	//optionsLeftBox = '';	
}

function clearSelect(){

	//document.getElementById('regions_Dv').selectedIndex=0; 
	//document.getElementById('regions_ReDv').selectedIndex=0; 
	//document.getElementById('regions_CP').selectedIndex=0; 
	//document.getElementById('regions_RP').selectedIndex=0;
	//document.getElementById('cities_Dv').selectedIndex=0; 
	//document.getElementById('cities_ReDv').selectedIndex=0; 
	//document.getElementById('cities_CP').selectedIndex=0; 
	//document.getElementById('cities_RP').selectedIndex=0;
	//document.getElementById('country_Dv').selectedIndex=0; 
	//document.getElementById('country_ReDv').selectedIndex=0; 
	//document.getElementById('country_CP').selectedIndex=0; 
	//document.getElementById('country_RP').selectedIndex=0;
	
	
}

function clearSpec(){

    var oSpecification_Dv = document.getElementById('specification_Dv');
    oSpecification_Dv.innerHTML = ''; oSpecification_Dv.style.display = 'none';
    document.getElementById('localization_Dv').style.display = 'block';
    document.getElementById('firstButton_Dv').className = 'button-searchType-selected';
    document.getElementById('secondButton_Dv').className = 'button-searchType';

    var oSpecification_ReDv = document.getElementById('specification_ReDv');
    oSpecification_ReDv.innerHTML = ''; oSpecification_ReDv.style.display = 'none';
    document.getElementById('localization_ReDv').style.display = 'block';
    document.getElementById('firstButton_ReDv').className = 'button-searchType-selected';
    document.getElementById('secondButton_ReDv').className = 'button-searchType';

    var oSpecification_CP = document.getElementById('specification_CP');
    oSpecification_CP.innerHTML = ''; oSpecification_CP.style.display = 'none';
    document.getElementById('localization_CP').style.display = 'block';
    document.getElementById('firstButton_CP').className = 'button-searchType-selected';
    document.getElementById('secondButton_CP').className = 'button-searchType';

    var oSpecification_RP = document.getElementById('specification_RP');
    oSpecification_RP.innerHTML = ''; oSpecification_RP.style.display = 'none';
    document.getElementById('localization_RP').style.display = 'block';
    document.getElementById('firstButton_RP').className = 'button-searchType-selected';
    document.getElementById('secondButton_RP').className = 'button-searchType';

	document.getElementById('specification_Dv').innerHTML=''; 
	document.getElementById('specification_ReDv').innerHTML=''; 
	document.getElementById('specification_CP').innerHTML=''; 
	document.getElementById('specification_RP').innerHTML='';
	
}
function reloadPages_F(){

	reloadPages = 'true';
	listing = 0;

	if(miastoSet!='' && miastoSet!=undefined){
		globalZoomType = 'city';
	}else if(panstwoSet!='' && panstwoSet!=undefined){
		globalZoomType = 'country';
	}else if(kontSet!='' && kontSet!=undefined){
		globalZoomType = 'continent';
	}else{
		globalZoomType = '';
	}
	
	showListingAjax(pages);

}

var onlyOne = 0;
function searchStart(){

	clearOptions();
	pages=0;
	
	try{
		panel_typeAdv = document.getElementById('type').value;	
	}catch(err){}	
	try{
		panel_area = document.getElementById('area').value;	
	}catch(err){}
	try{
		panel_areamin = document.getElementById('areamin').value;	
	}catch(err){}
	try{
		panel_areamax = document.getElementById('areamax').value;	
	}catch(err){}
	try{
		panel_price = document.getElementById('price').value;
	}catch(err){}
	try{
		panel_pricemin = document.getElementById('pricemin').value;	
	}catch(err){}
	try{
		panel_pricemax = document.getElementById('pricemax').value;	
	}catch(err){}
		
	if (objectImg == 1) {
		
		if(onlyOne==0){
			try{
				kontSet = document.getElementById('continent_Dv').value;
			}catch(err){}
			try{
				panstwoSet = document.getElementById('country_Dv').value;
			}catch(err){}
		}
		try{
			regionSet = document.getElementById('regions_Dv').value;
		}catch(err){}
		try{
			miastoSet = document.getElementById('cities_Dv').value;
		}catch(err){}
		
		nameSelect = 'Dv';
			
	}
	else 
		if (objectImg == 2) {
			
			if(onlyOne==0){
				try{
					kontSet = document.getElementById('continent_ReDv').value;
				}catch(err){}
				try{
					panstwoSet = document.getElementById('country_ReDv').value;
				}catch(err){}
			}
			try{
				regionSet = document.getElementById('regions_ReDv').value;
			}catch(err){}
			try{
				miastoSet = document.getElementById('cities_ReDv').value;
			}catch(err){}	
			
			nameSelect = 'ReDv';								
		}
		else 
			if (objectImg == 3) {
				
				if(onlyOne==0){
					try{
						kontSet = document.getElementById('continent_CP').value;
					}catch(err){}
					try{
						panstwoSet = document.getElementById('country_CP').value;
					}catch(err){}
				}
				try{
					regionSet = document.getElementById('regions_CP').value;
				}catch(err){}
				try{
					miastoSet = document.getElementById('cities_CP').value;
				}catch(err){}
				try{
					panel_transaction = document.getElementById('transaction').value;
				}catch(err){}
				
				nameSelect = 'CP';						
			}
			else 
				if (objectImg == 4) {
				
					if(onlyOne==0){					
						try{
							kontSet = document.getElementById('continent_RP').value;
						}catch(err){}
						try{
							panstwoSet = document.getElementById('country_RP').value;
						}catch(err){}
					}
					try{
						regionSet = document.getElementById('regions_RP').value;
					}catch(err){}
					try{
						miastoSet = document.getElementById('cities_RP').value;
					}catch(err){}
					try{
						panel_transaction = document.getElementById('transaction').value;
					}catch(err){}
					try{
						panel_bedroom = document.getElementById('bedroom').value;
					}catch(err){}
					try{
						panel_bathroom = document.getElementById('bathroom').value;	
					}catch(err){}
					
					nameSelect = 'RP';					
				}
				else 
					if (objectImg == 5) {					
						
						if(onlyOne==0){
							try{
								kontSet = document.getElementById('continent_IL').value;
							}catch(err){}
							try{
								panstwoSet = document.getElementById('country_IL').value;
							}catch(err){}
						}
						try{
							regionSet = document.getElementById('regions_IL').value;
						}catch(err){}
						try{
							miastoSet = document.getElementById('cities_IL').value;
						}catch(err){}
						try{
							panel_transaction = document.getElementById('transaction').value;
						}catch(err){}
						try{
							panel_bedroom = document.getElementById('bedroom').value;
						}catch(err){}
						try{
							panel_bathroom = document.getElementById('bathroom').value;	
						}catch(err){}
						
						nameSelect = 'IL';					
					}

	if(onlyOne==1){
		panstwoSet = 68;
		kontSet = 2;
	}	
	onlyOne=0;

	if(miastoSet!='' && miastoSet!=undefined){
		globalZoomType = 'city';
	}else if(panstwoSet!='' && panstwoSet!=undefined){
		globalZoomType = 'country';
	}else if(kontSet!='' && kontSet!=undefined){
		globalZoomType = 'continent';
	}else{
		globalZoomType = '';
	}
	
	/**
	 * Przeladowanie selecta
	 */

	if (setSelect != 1 && noSelect != 1) {
		reloadSelect(categoryAdvert, nameSelect);
		setSelect=1;
	}
	
	showListingAjax(pages); 
	
}

function reloadSelect(type,nameSelect){

		advAJAX.get({
          	url: '/pressitonestate.php/mainproject/reloadSelect',
		parameters: {
			"categoryAdvert": String(categoryAdvert)	
		},
        onSuccess: function(obj){  
	  		var json = eval(obj.responseText);
			var selIndx = 0;			
			
			if (json != null) {
				var l = json.length;
				var index = 1;
				
				document.getElementById('continent_' + nameSelect).options[index - 1] = new Option('All', '');
				index++;
				        
				for (i = 0; i < l; i++) {
					document.getElementById('continent_' + nameSelect).options[index - 1] = new Option(json[i][1], json[i][0]);
					if(json[i][0]==kontSet) selIndx = index-1;
					index++;
				}
                //document.getElementById('continent_' + nameSelect).selectedIndex = selIndx;
			}			
          },
        onError: function(obj){
        	alert('Error in function showOffertsListing, error code: '+obj.status);
          }
        });
	
}

function reloadLanguage(id,id_template,url,lang){
	
	advAJAX.get({
                  url: '/pressitonestate.php/mainproject/GetLanguageFromInt',
				  parameters: {
				  	"lang": lang
				  },
                  onSuccess: function(obj){
						lang = obj.responseText;					  
				  		location = 'http://'+url+'/pressitonestate.php/mainproject/changeCulture?culture='+lang;
                  },
                  onError: function(obj){
                    alert('Error in function showOffertsListing, error code: '+obj.status);
                  }
     });
	
}

function showOfferts(id,latX,latY){

	//location = '/pressitonestate.php/mainproject/showOffertsDetails/id/'+id;
	//location = '/pressitonestate.php/popupWindow/offerDetails/id/'+id+'/poz/0';
	/*	
	testwindow = window.open ('/pressitonestate.php/popupWindow/offerDetails/id/'+id+'/type/'+panstwoSet+'/poz/0', "mywindow"+id,
    	"resizable=1,location=0,status=0,scrollbars=1,width=750,height=700");
	*/
	
	var flag = 'true';
	document.getElementById('idShowOffer').value = id;
	document.getElementById('searchClick').value = 'yes';
	
	if(document.getElementById('idOffer').value==''){
		document.getElementById('idOffer').value = id;
	}else{
		var tab = document.getElementById('idOffer').value;
		var tabArray = tab.split("|");
		var maxArray = tabArray.length;
		
		for(i=0;i<=maxArray-1;i++){
			if(tabArray[i]==id){
				flag = 'false';
			}
		}
		if(flag=='true'){
			var str = id+'|'+document.getElementById('idOffer').value;
			document.getElementById('idOffer').value = str;	
		}				
	}
	document.getElementById('searchForm').submit();
	
	//globalOneLongitude = latY;
	//globalOneLatitude = latX;	
    //loadWithListing();
  	
}

function popupofferts(id,poz)
{

	testwindow= window.open ('/pressitonestate.php/popupWindow/offerDetails/id/'+id+'/type/'+panstwoSet+'/poz/'+poz, "mywindow"+id,
    	"resizable=1,location=0,status=0,scrollbars=1,width=750,height=700");
}

function showOffertsListing() {
	        
		   advAJAX.get({
                  url: '/pressitonestate.php/mainproject/showOffertsListing',
				  
				  onLoading: function(obj) {				  	
						document.getElementById('loadAjax').style.display = 'block';					
				  },
				  
				  onComplete: function(obj){				  	
						document.getElementById('loadAjax').style.display = 'none';					
				  },
				  
                  onSuccess: function(obj){  
				  		document.getElementById('showOffertsListing').innerHTML = '';       
                  		document.getElementById('showOffertsListing').innerHTML = obj.responseText;
                  },
                  onError: function(obj){
                    alert('Error in function showOffertsListing, error code: '+obj.status);
                  }
                });

}

function popupWindowShow(type){

document.getElementById('mainTab').style.height='';
document.getElementById('general').style.display='none';
document.getElementById('photo').style.display='none';
document.getElementById('financial').style.display='none';
document.getElementById('marketOffer').style.display='none';
document.getElementById('mapoffer').style.visibility='hidden';
document.getElementById('mapoffer').style.marginTop=-400+'px';
document.getElementById('mapStreetView').style.display='none';
document.getElementById('contact').style.display='none';

try{
	document.getElementById('infoMessage').style.display='none';
}catch(err){}
	
	switch(type){
		case 1:
			document.getElementById('general').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('genInfoPopup').onmouseout='';
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails');
		break;
		case 2:
			document.getElementById('photo').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('viewsPicsPopup').onmouseout='';
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails');
		break;
		case 3:
			document.getElementById('financial').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('financePopup').onmouseout='';
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails');
		break;
		case 4:
			document.getElementById('marketOffer').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('contactPopup').onmouseout='';
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
		break;
		case 5:
			document.getElementById('mapoffer').style.visibility='visible';
			document.getElementById('mainTab').style.height=886 + 'px';
			document.getElementById('mapoffer').style.marginTop=0+'px';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('contactPopup').onmouseout='';
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
		break;
		case 6:
			document.getElementById('mapStreetView').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('contactPopup').onmouseout='';
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
		break;
		case 7:
			document.getElementById('contact').style.display='block';
			document.getElementById('penTab'+type).setAttribute('class','menuTopActive');
			document.getElementById('penCenterTab'+type).setAttribute('class','menuTopCenterActive');
			for(i=1;i<8;i++){
				if(type!=i) try{document.getElementById('penTab'+i).setAttribute('class','menuTopNoActive');}catch(err){};
				if(type!=i) try{document.getElementById('penCenterTab'+i).setAttribute('class','menuTopCenterNoActive');}catch(err){};
			}
			//document.getElementById('contactPopup').onmouseout='';
			//document.getElementById('contactPopup').setAttribute('class','button-offerDetails-selected');
			//document.getElementById('financePopup').setAttribute('class','button-offerDetails');
			//document.getElementById('viewsPicsPopup').setAttribute('class','button-offerDetails');
			//document.getElementById('genInfoPopup').setAttribute('class','button-offerDetails');
		break;
		default:
			document.getElementById('general').style.display='block';
		break;
	}
}

function translateText(translate){

	var translateId = translate;
	var translateText = document.getElementById('Adv_'+translateId).innerHTML;

			   advAJAX.get({
                  url: '/pressitonestate.php/mainproject/translateText',
				parameters: {
					"translate": translateText,
					"language": language,
					"id": translateId
				},				
				onLoading : function(obj) { document.getElementById('ajaxLoad_'+translateId).style.display='block'; },
				onComplete : function(obj) { document.getElementById('ajaxLoad_'+translateId).style.display='none'; },
				
                  onSuccess: function(obj){
				  	
				  		if (obj.responseText.trim() != '' && obj.responseText.trim() != undefined) {
							document.getElementById('Adv_' + translateId).innerHTML = '';
							document.getElementById('Adv_' + translateId).innerHTML = obj.responseText;
						}
				},
                  onError: function(obj){
                    alert('Error in function showOffertsListing, error code: '+obj.status);
                  }
                });	
}

function translateTextClob(category,language,id){

	var translateId = category;
	var language = language;
	var idAdv = id;
		      
		   advAJAX.get({
	          url: '/pressitonestate.php/mainproject/translateTextClob',
			parameters: {
				"language": language,
				"id": translateId,
				"idAdv": idAdv
			},												
	        onSuccess: function(obj){

					if (obj.responseText.trim() != '' && obj.responseText.trim() != undefined) {
						document.getElementById('Adv_' + translateId).innerHTML = '';
						document.getElementById('Adv_' + translateId).innerHTML = obj.responseText;
					}						
			},
	        onError: function(obj){
	            alert('Error in function showOffertsListing, error code: '+obj.status);
	          }
	        });				
}

function showOneOffert(){

		advAJAX.get({
	          url: '/pressitonestate.php/mainproject/getRandList',
			parameters: {
				"category": String(categoryAdvert)
			},												
	        onSuccess: function(obj){
					
					var arrayTab = obj.responseText;
					var idType = arrayTab.split("|");
					
					if(idType[0]!=''){
						location = '/pressitonestate.php/mainproject/index/type/'+idType[1]+'/id/'+idType[0];						
					}
											
			},
	        onError: function(obj){
	            alert('Error in function showOffertsListing, error code: '+obj.status);
	          }
	        });	
}

function loadPoz(id){
	
	globalZoomType = 'reloadMaps';
	
			advAJAX.get({
	          url: '/pressitonestate.php/mainproject/getInfoList',
			parameters: {
				"id": id
			},												
	        onSuccess: function(obj){
					
					var arrayList = obj.responseText;
					var arrayTab = arrayList.split("|");
					
					globalLatitude = arrayTab[1];
					globalLongitude = arrayTab[2];
					
					tabArrayGlobal[0] = new Array();
					tabArrayGlobal[0][1] = arrayTab[1];
					tabArrayGlobal[0][2] = arrayTab[2];
					tabArrayGlobal[0][0] = arrayTab[0];
					tabArrayGlobal[0][9] = arrayTab[3];
					
					loadWithListing();
					
										
			},
	        onError: function(obj){
	            alert('Error in function showOffertsListing, error code: '+obj.status);
	          }
	        });
	
}

function lookingFor(){
	
	clearOptions();
	
	objectImg = ''; 
	onlyOne = ''; 
	setSelect = ''; 
	noSelect = '';
		
	advAJAX.get({
	          url: '/pressitonestate.php/mainproject/lookingFor',
			parameters: {
				"input": document.getElementById('quickSearch').value
			},												
	        onSuccess: function(obj){
					
					try{
						document.getElementById('main-offers-search-Dv').style.display = 'none';
					}catch(err){}
					try{
						document.getElementById('main-offers-search-ReDv').style.display = 'none';
					}catch(err){}
					try{
						document.getElementById('main-offers-search-CP').style.display = 'none';
					}catch(err){}
					try{
						document.getElementById('main-offers-search-IL').style.display = 'none';
					}catch(err){}
					try{
						document.getElementById('main-offers-search-RP').style.display = 'none';
					}catch(err){}
					try{
						document.getElementById('mainPageServiceCommercial').style.display = 'none';
					}catch(err){}
					
					var arrayInfo = obj.responseText.split("|");
					kontSet = arrayInfo[0];
					panstwoSet = arrayInfo[1];
					miastoSet = arrayInfo[2];
					globalZoomType = 'city';
					rodzaj = 'city';				
					showListingAjax(0);
															
			},
	        onError: function(obj){
	            alert('Error in function showOffertsListing, error code: '+obj.status);
	          }
	        });
}

function countNewDataResult(id){

	var idInput = id;
    if(typeof(idInput) == 'object') idInput = undefined;

	if(idInput!=undefined){
		document.getElementById('distressedTab'+idInput).value = document.getElementById('regularTab'+idInput).value;
	}
	
	if(idInput==21){
		document.getElementById('distressedTab37').value = document.getElementById('regularTab'+idInput).value;
		document.getElementById('regularTab37').value = document.getElementById('regularTab'+idInput).value;
	}
	
	tmp = document.getElementById('regularTab2').value;
	tmp = tmp.replace(/\,/gi,'.');
		
	var feetSQ = parseFloat(document.getElementById('regularTab3').value);
	if(isNaN(feetSQ)){
		//feetSQ = parseFloat(document.getElementById('regularTab1').value)*parseFloat(tmp);	
	}
	
	//var feetSQMet = Math.round(parseFloat(document.getElementById('regularTab3').value)/parseFloat(tmp)*100)/100;
	var priceSQ = (parseInt(document.getElementById('regularTab4').value)*parseInt(document.getElementById('regularTab1').value))/feetSQ;
	
	try{
		var idCategory = document.getElementById('idCategory').value;
		}catch(err){}
	
	advAJAX.get({
	          url: '/pressitonestate.php/mainproject/getInfoResult',
			parameters: {
				//"CONF_STORED_CUR": '';
				//"CONF_STORED_SQ": '';
				"SIZE_SQ": feetSQ,
				"PRICE_MAIN_PER_SQ": priceSQ,
				"PRICE": document.getElementById('regularTab6').value,
				"DISTRESS_PROPERTY": document.getElementById('regularTab7').value,
				"DISTRESS_PROPERTY2": document.getElementById('distressedTab7').value,
				"UNOCUPIENT_TIME": document.getElementById('regularTab10').value,
				"AVG_MONNTLY_RENTAL": document.getElementById('regularTab12').value,
				"DOWN_PAYMNET": document.getElementById('regularTab15').value,
				"AMOUNT_OF_LOAN_END": document.getElementById('regularTab18').value,
				"INTEREST_PER_YEAR": document.getElementById('regularTab19').value,
				"LOAN_PERIOD": document.getElementById('regularTab21').value,
				"INSURANCE_COST": document.getElementById('regularTab25').value,
				"AVG_TAX": document.getElementById('regularTab26').value,
				"REPAIR_BUDGET": document.getElementById('regularTab28').value,
				"MANAGED_COST_PER_SQ_MNTH": document.getElementById('regularTab29').value,
				"INFLATION_RATE": document.getElementById('regularTab39').value,
				"ANNUAL_VALUE_INCREASE": document.getElementById('regularTab36').value,
				"ANNUAL_VALUE_INCREASE2": document.getElementById('distressedTab36').value,
				"idCategory": idCategory,
				"orginalPrice": orginalPrice
			},												
	        onSuccess: function(obj){

					var t = eval('('+obj.responseText+')');
					
					document.getElementById('regularTab3').value = t[0][0];
					
					if(orginalPrice!=undefined){
						document.getElementById('regularTab5').value = Math.round(parseFloat(orginalPrice)/parseFloat(feetSQ)*100/100);
						document.getElementById('regularTab5').value = t[0][1];
						document.getElementById('regularTab4').value = Math.round(parseFloat(t[0][2])/parseFloat(document.getElementById('regularTab1').value)*100/100);
					}else{
						document.getElementById('regularTab5').value = t[0][1];
					}
					
					document.getElementById('regularTab6').value = t[0][2];					
					document.getElementById('regularTab8').value = t[0][3];
					document.getElementById('regularTab9').value = t[0][4];					
					document.getElementById('regularTab13').value = t[0][5];
					document.getElementById('regularTab14').value = t[0][6];							
					document.getElementById('regularTab16').value = t[0][7];
					document.getElementById('regularTab17').value = t[0][8];							
					document.getElementById('regularTab20').value = Math.round(parseFloat(t[0][9])*100*100)/100;
					document.getElementById('regularTab22').value = t[0][10];					
					document.getElementById('regularTab23').value = t[0][11];
					document.getElementById('regularTab24').value = t[0][12];					
					document.getElementById('regularTab27').value = t[0][13];
					document.getElementById('regularTab30').value = t[0][14];					
					document.getElementById('regularTab31').value = t[0][15];
					document.getElementById('regularTab32').value = t[0][16];
					
					if(t[0][16]<0){
						document.getElementById('regularTab32').style.color = '#FF0000';
					}
										
					document.getElementById('regularTab33').value = Math.round(parseFloat(t[0][17])*100*100/100);
					document.getElementById('regularTab34').value = t[0][18];					
					document.getElementById('regularTab35').value = Math.round(parseFloat(t[0][19])*100*100/100);
					
					document.getElementById('regularTab38').value = t[0][20];
					document.getElementById('regularTab40').value = t[0][21];
					document.getElementById('regularTab41').value = t[0][22];				
										
					if(t[0][22]<0){
						document.getElementById('regularTab41').style.color = '#FF0000';
					}
										
					document.getElementById('regularTab42').value = t[0][23];					
					document.getElementById('regularTab43').value = Math.round(parseFloat(t[0][24])*100*100)/100;
					document.getElementById('regularTab44').value = Math.round(parseFloat(t[0][25])*100*100/100);
					
					document.getElementById('distressedTab3').value = t[1][0];
					
					if(orginalPrice!=undefined){
						document.getElementById('distressedTab5').value = Math.round(parseFloat(orginalPrice)/parseFloat(feetSQ)*100/100);		
						document.getElementById('distressedTab5').value = t[0][1];
						document.getElementById('distressedTab4').value = Math.round(parseFloat(t[0][2])/parseFloat(document.getElementById('regularTab1').value)*100/100);
					}else{
						document.getElementById('distressedTab5').value = t[1][1];
					}
					
					document.getElementById('distressedTab6').value = t[1][2];					
					document.getElementById('distressedTab8').value = t[1][3];
					document.getElementById('distressedTab9').value = t[1][4];					
					document.getElementById('distressedTab13').value = t[1][5];
					document.getElementById('distressedTab14').value = t[1][6];							
					document.getElementById('distressedTab16').value = t[1][7];
					document.getElementById('distressedTab17').value = t[1][8];							
					document.getElementById('distressedTab20').value = Math.round(parseFloat(t[1][9])*100*100)/100;
					document.getElementById('distressedTab22').value = t[1][10];					
					document.getElementById('distressedTab23').value = t[1][11];
					document.getElementById('distressedTab24').value = t[1][12];					
					document.getElementById('distressedTab27').value = t[1][13];
					document.getElementById('distressedTab30').value = t[1][14];					
					document.getElementById('distressedTab31').value = t[1][15];
					document.getElementById('distressedTab32').value = t[1][16];					
					
					if(t[1][16]<0){
						document.getElementById('distressedTab32').style.color = '#FF0000';
					}
					
					document.getElementById('distressedTab33').value = Math.round(parseFloat(t[1][17])*100*100/100);
					document.getElementById('distressedTab34').value = t[1][18];					
					document.getElementById('distressedTab35').value = Math.round(parseFloat(t[1][19])*100*100/100);
					
					document.getElementById('distressedTab38').value = t[1][20];
					document.getElementById('distressedTab40').value = t[1][21];
					document.getElementById('distressedTab41').value = t[1][22];				
							
					if(t[1][22]<0){
						document.getElementById('distressedTab41').style.color = '#FF0000';
					}
									
					document.getElementById('distressedTab42').value = t[1][23];					
					document.getElementById('distressedTab43').value = Math.round(parseFloat(t[1][24])*100*100)/100;
					document.getElementById('distressedTab44').value = Math.round((parseFloat(t[1][25])*100*100)/100);
					
					/*
					document.getElementById('regularTab3').value = Math.round(t['SIZE_SQ']*100)/100;
					document.getElementById('regularTab5').value = Math.round(t['PRICE_MAIN_PER_SQ']*100)/100;
					document.getElementById('regularTab6').value = Math.round(t['PRP_ACQUISITION_COST']*100)/100;					
					document.getElementById('regularTab8').value = Math.round(t['PRP_PRICE_AFTER_DISCOUNT']*100)/100;
					document.getElementById('regularTab9').value = Math.round(t['DFR_PRICE_AFTER_DISCOUNT']*100)/100;					
					document.getElementById('regularTab13').value = Math.round(t['RENTAL_AMOUNT_PER_MONTH']*100)/100;
					document.getElementById('regularTab14').value = Math.round(t['RENTAL_PER_YEAR_CASH_IN']*100)/100;							
					document.getElementById('regularTab16').value = Math.round(t['DOWN_PAYMENT_CASH_IN']*100)/100;
					document.getElementById('regularTab17').value = t['AMOUNT_OF_LOAN_BEGINNING'];							
					document.getElementById('regularTab20').value = Math.round(t['INTEREST_PER_MONTH']*100)/100;
					document.getElementById('regularTab22').value = t['LOAN_PERIOD_IN_MONTHS'];					
					document.getElementById('regularTab23').value = Math.round(t['MONTHLY_PRINCIPAL_INTEREST']*100)/100;
					document.getElementById('regularTab24').value = t['ANNUALLY_PRINCIPAL_INTEREST'];					
					document.getElementById('regularTab27').value = Math.round(t['TAX_ANNUAL']*100)/100;
					document.getElementById('regularTab30').value = Math.round(t['ANNUAL_MANAGEMENT']*100)/100;					
					document.getElementById('regularTab31').value = Math.round(t['TOTAL_ANNUAL_COST']*100)/100;
					document.getElementById('regularTab32').value = Math.round(t['INCOME_BEFORE_DIS']*100)/100;					
					document.getElementById('regularTab33').value = Math.round(t['CASH_ON_CASH_BEFORE_DIS']*100)/100;
					document.getElementById('regularTab34').value = Math.round(t['INCOME_AFTER_DIS']*100)/100;					
					document.getElementById('regularTab35').value = Math.round(t['CASH_ON_CASH_AFTER_DIS']*100)/100;
					
					document.getElementById('regularTab38').value = Math.round(t['SELL_PRICE']*100)/100;
					document.getElementById('regularTab40').value = Math.round(t['REAL_VALUE_OF_RESALE']*100)/100;					
					document.getElementById('regularTab41').value = Math.round(t['REAL_VALUE_OF_INCOME']*100)/100;
					document.getElementById('regularTab42').value = Math.round(t['TOTAL_CASH_AFTER_SELL']*100)/100;					
					document.getElementById('regularTab43').value = Math.round(t['ROI']*100)/100;
					document.getElementById('regularTab44').value = Math.round(t['ROI_ANNUAL']*100)/100;
					*/				
			},
	        onError: function(obj){
	            alert('Error in function countNewDataResult, error code: '+obj.status);
	          }
	        });

}
/**
* Ustawia mape oraz listing wzgledem formularza na stronie
**/
function searchQueryForm(arrayQuery){
	
	if(arrayQuery['type'] == undefined) arrayQuery['type']= 42;
	if(arrayQuery['typeTransaction'] == undefined) arrayQuery['typeTransaction']= 44;
	if(arrayQuery['searchClick']=='yes'){
		whatShow = 'yes';
		document.getElementById('searchClick').value='';
	}

	miastoSet = arrayQuery['idCity'];
	zipCode = arrayQuery['zipCode'];
	objectImg = arrayQuery['idCategory'];
	panel_typeAdv = arrayQuery['type'];
	panel_transaction = arrayQuery['typeTransaction'];
	panel_area = arrayQuery['area'];
	panel_areamin = arrayQuery['areamin'];
	panel_areamax = arrayQuery['areamax'];
	panel_price = arrayQuery['price']
	panel_pricemin = arrayQuery['pricemin']
	panel_pricemax = arrayQuery['pricemax']
	panel_bedroommin = arrayQuery['bedroommin'];
	panel_bedroommax = arrayQuery['bedroommax'];
	panel_bathroommin = arrayQuery['bathroommin'];
	panel_bathroommax = arrayQuery['bathroommax'];
	panel_swimmingpool = arrayQuery['swimmingpool'];
	panel_waterfront = arrayQuery['waterfront'];
	panel_nrRef = arrayQuery['nrRef'];
	
	panel_pages = arrayQuery['pages'];

	if(arrayQuery['latLngArchive']==undefined) arrayQuery['latLngArchive']='undefined';
	if(arrayQuery['latLngArchive']!='' && arrayQuery['latLngArchive']!='undefined'){
		var a = arrayQuery['latLngArchive'].split(",");
		copylatLngArchive.push(new Array(a[0],a[1],a[2],a[3]));
		latMin = a[0];
		latMax = a[1];
		longMin= a[2];
		longMax= a[3];
		sectorFlag = 'true';
		
	}
	
}

function savenrRef(){
	document.getElementById('searchClick').value = 'yes';
	document.getElementById('idOffer').value = document.getElementById('nrRef').value;
	document.getElementById('idShowOffer').value = document.getElementById('nrRef').value;
}

function saveContact(){
	
		advAJAX.get({
	          url: '/pressitonestate.php/popupWindow/offerDetailsSave',
			parameters: {
				"id": document.getElementById('id').value,
				"email": document.getElementById('email').value,
				"askOffert": document.getElementById('askOffert').value
			},												
	        onSuccess: function(obj){
					document.getElementById('infoMessage').style.display = 'block';		
			},
	        onError: function(obj){
	            alert('Error in function saveContact, error code: '+obj.status);
	          }
	        });
	
}

function countNewData(){
	
	var poz1 = document.getElementById('offertTab1').value;
	var poz2 = document.getElementById('offertTab2').value;
	var poz3 = document.getElementById('offertTab3').value;
	var poz4 = document.getElementById('offertTab4').value;
	var poz5 = document.getElementById('offertTab5').value;
	var poz6 = document.getElementById('offertTab6').value;
	var poz7 = document.getElementById('offertTab7').value;
	var poz8 = document.getElementById('offertTab8').value;
	var poz9 = document.getElementById('offertTab9').value;
	var poz10 = document.getElementById('offertTab10').value;
	var poz11 = document.getElementById('offertTab11').value;
	var poz12 = document.getElementById('offertTab12').value;
	var poz13 = document.getElementById('offertTab13').value;
	var poz14 = document.getElementById('offertTab14').value;
	var poz15 = document.getElementById('offertTab15').value;
	var poz16 = document.getElementById('offertTab16').value;
	var poz17 = document.getElementById('offertTab17').value;
	var poz18 = document.getElementById('offertTab18').value;
	var poz19 = document.getElementById('offertTab19').value;
	var poz20 = document.getElementById('offertTab20').value;
	var poz21 = document.getElementById('offertTab21').value;
	var poz22 = document.getElementById('offertTab22').value;
	var poz23 = document.getElementById('offertTab23').value;
	
	tmp = poz1.replace(/%/gi,'');
	tmp = tmp.replace(/\,/gi,'.');

	poz4 = (parseInt(poz3)*parseInt(poz2))*((1-parseInt(tmp)/100));
	document.getElementById('offertTab4').value = Math.round(parseInt(poz4)*100)/100;
	
	poz7 = (parseInt(-poz5)*parseInt(poz6))/100;
	document.getElementById('offertTab7').value = Math.round(parseInt(poz7)*100)/100;
	
	poz8 = parseInt(poz5)+parseInt(poz7);
	document.getElementById('offertTab8').value = Math.round(parseFloat(poz8)*100)/100;
	
	tmp = poz10.replace(/%/gi,'');
	tmp = tmp.replace(/\,/gi,'.');

	poz11 = (parseFloat(tmp))/parseFloat(poz2);
	document.getElementById('offertTab11').value = Math.round(parseFloat(poz11)*100)/100;
	
	poz13 = parseInt(poz12)*parseInt(poz2);
	document.getElementById('offertTab13').value = parseInt(poz13);
	
	poz14a = ((parseFloat(tmp)/parseInt(poz2))/100)*parseInt(poz8);
	poz14b = Math.pow(1+((parseFloat(tmp)/parseInt(poz2))/100),-120);
	poz14 = poz14a/(1-poz14b);
	document.getElementById('offertTab14').value = Math.round(poz14*100)/100;
	
	poz15 = parseFloat(poz14)*parseInt(poz2);
	document.getElementById('offertTab15').value = Math.round(parseFloat(poz15)*100)/100;
	
	tmp = poz19.replace(/%/gi,'');
	tmp = tmp.replace(/\,/gi,'.');

	poz20 = -(parseFloat(tmp)/100)*parseFloat(poz4);
	document.getElementById('offertTab20').value = Math.round(parseFloat(poz20)*100)/100;
	
	poz21 = parseInt(poz15)+parseInt(poz16)+parseInt(poz17)+parseInt(poz18)+parseInt(poz20);
	document.getElementById('offertTab21').value = Math.round(parseInt(poz21)*100)/100;
	
	poz22 = parseInt(poz4)+parseInt(poz21);
	document.getElementById('offertTab22').value = Math.round(parseInt(poz22)*100)/100;
	
	poz23 = (-parseFloat(poz22)/parseFloat(poz5))*100;
	document.getElementById('offertTab23').value = Math.round(parseFloat(poz23)*100)/100;
}

/**
* @desc funkcja laduje mape z dynamicznym load'erem
* @author Dariusz Pidzik <dariusz.pidzik@polconstruct.com>
*/

function loadMarkers(){
	maxNum = tabArrayGlobal.length;
  	progressBar.start(maxNum);
  	setTimeout('createMarkerSt()', 1);
}

function createMarkerSt(){
  num++;
  progressBar.updateLoader(1);
   		
			var point = new GLatLng(tabArrayGlobal[jPoz][1],tabArrayGlobal[jPoz][2]);
			var marker = new createMarker(point, tabArrayGlobal[jPoz][0], 'city', tabArrayGlobal[jPoz][3] ,tabArrayGlobal[jPoz][1], tabArrayGlobal[jPoz][2], tabArrayGlobal[jPoz][4]);			
			map.addOverlay(marker);				
			markersArray.push(marker);
			
  if (num < maxNum) {
  	jPoz++;
    setTimeout('createMarkerSt()', 1);
  } else {
    progressBar.remove();
    num = 0;
    jPoz = 0;
  }
}

function removeMarkers(){
  progressBar.start(markersArray.length);
  setTimeout("removeMarker()", 1);
}

function removeMarker(){
  progressBar.updateLoader(1);
  
  map.removeOverlay(markersArray.pop());

  if (markersArray.length > 0) {
    setTimeout("removeMarker()", 1);
  } else {
    progressBar.remove();
  }
}