function put_email(){
	a = 'accord';
	b = 'poczta.onet.pl';
	document.write('<a href="mailto:'+a+'@'+b+'" title="zapytanie ze strony">'+a+'@'+b+'</a>');
}
function send_email(){
	a = 'biuro';
	b = 'zarzadzanienieruchomosciami-accord.pl';
	document.write('<a href="mailto:'+a+'@'+b+'" title="zapytanie ze strony"><img src="administrowanie-nieruchomosciami/accord_email.gif" alt="zarządzanie nieruchomościami" class="beam"/></a>');
}

function mapa(el){
     ch = document.getElementById('mapa');     
     if(ch.style.display == 'block'){
          ch.style.display = 'none';       
     }else{
          ch.style.display = 'block';          
     }
}

function openPopUp(szerokosc,wysokosc,plik) {
wysokosc+=7;
window.open('http://www.zarzadzanienieruchomosciami-accord.pl/poka.php?wysokosc='+wysokosc+'&szerokosc='+szerokosc+'&plik='+plik,'prewiev','directories=no,location=no,menubar=no,resizable=no,scrollbars=no,status=yes,toolbar=no');
	return false;
}


replaceImages = new Array(
		'About Us|about.gif',
		'History|history.gif',
		'Contact Us|contact.gif'
	);

function firdom(){
	if(document.getElementsByTagName && document.createElement){
		for (l=1;l<=6;l++){
			h1s=document.getElementsByTagName('h'+l);
			scanandreplace(h1s,'h'+l);
		}
	}
}
function scanandreplace(h1s,tag){
	for(i=0;i<h1s.length;i++){
		for(f=0;f<replaceImages.length;f++){
			chunks=replaceImages[f].split('|');
			thish1=document.getElementsByTagName(tag)[i];
			if(thish1.firstChild.nodeValue==chunks[0]){
				newImg=document.createElement('img');			
				newImg.setAttribute('alt',chunks[0])
				newImg.setAttribute('src',chunks[1])
				// or newImg.src=chunks[1];
				thish1.replaceChild(newImg,thish1.firstChild)
			}
		}
	}
}

//window.onload=firdom;

function sendAjaxForm(str)
{
	document.getElementById("wait").style.display = 'block';
	document.getElementById("wait2").style.display = 'block';
	var xmlHttp;
	try { xmlHttp=new XMLHttpRequest(); }
	catch (e) 
	{
		try	{ xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e)
		{
			try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); }
			catch (e)
			{
				alert("Your browser does not support AJAX!");
				return false;
			}
		}
	}	
	
	//alert(document.getElementById("tok").value);
	//alert(str.token.value);

var firmname 					= str.firmname.value;
var firmfname 				= str.firmfname.value;
var firmlname 				= str.firmlname.value;
var firmaddress 			= str.firmaddress.value;
var firmphone 				= str.firmphone.value;
var firmemail 				= str.firmemail.value;

var cargokind 				= str.cargokind.value;
var cargoweight 			= str.cargoweight.value;
var cargoweightkind 	= str.cargoweightkind.value;
var cargowidth 				= str.cargowidth.value;
var cargoheight 			= str.cargoheight.value;
var cargolenght 			= str.cargolenght.value;
var cargodimkind 			= str.cargodimkind.value;

var fromaddress 			= str.fromaddress.value;
var fromday 					= str.fromday.value;
var frommonth 				= str.frommonth.value;
var fromyear 					= str.fromyear.value;
var fromhour 					= str.fromhour.value;
var fromminutes 			= str.fromminutes.value;

var today 						= str.today.value;
var tomonth 					= str.tomonth.value;
var toyear 						= str.toyear.value;
var tohour 						= str.tohour.value;

var deliveryaddress 	= str.deliveryaddress.value;
var deliveryfname 		= str.deliveryfname.value;
var deliverylname 		= str.deliverylname.value;
var deliveryphone 		= str.deliveryphone.value;

var token 						= str.token.value;

	var url="ajaxform.php";
	
	url=url+"?firmname=" +firmname+ "&firmfname=" +firmfname+ "&firmlname=" +firmlname+ "&firmaddress=" +firmaddress+ "&firmphone=" +firmphone+ "&firmemail=" +firmemail+
	"&cargokind=" +cargokind+ "&cargoweight=" +cargoweight+ "&cargoweightkind=" +cargoweightkind+ "&cargowidth=" +cargowidth+ "&cargoheight=" +cargoheight+ "&cargolenght=" +cargolenght+ "&cargodimkind=" +cargodimkind+	
	"&fromaddress=" +fromaddress+ "&fromday=" +fromday+ "&frommonth=" +frommonth+ "&fromyear=" +fromyear+ "&fromhour=" +fromhour+ "&fromminutes=" +fromminutes+	
	"&today=" +today+ "&tomonth=" +tomonth+ "&toyear=" +toyear+ "&tohour=" +tohour+	
	"&deliveryaddress=" +deliveryaddress+ "&deliveryfname=" +deliveryfname+ "&deliveryphone=" +deliveryphone +	 "&deliverylname=" +deliverylname+ 
	"&token=" +token;
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4) 
		{	
			stamp = new Date();
			document.getElementById("requ").innerHTML = xmlHttp.responseText;			
			document.getElementById("token").src = 'token.php?' +stamp.getDate()+stamp.getHours()+stamp.getMinutes()+stamp.getSeconds();
			document.getElementById("wait").style.display = 'none';
			document.getElementById("wait2").style.display = 'none';
			
			if(xmlHttp.responseText=='Dziękujemy za wysłanie formularza, Twoje uwagi zostaną przekazane właścicielowi strony.')
			{
				str.firmname.value = '';
				str.firmfname.value = '';
				str.firmlname.value = '';
				str.firmaddress.value = '';
				str.firmphone.value = '';
				str.firmemail.value = '';
				str.cargokind.value = '';
				str.cargoweight.value = '';
				str.cargoweightkind.value = '';
				str.cargowidth.value = '';
				str.cargoheight.value = '';
				str.cargolenght.value = '';
				str.cargodimkind.value = '';
				str.fromaddress.value = '';
				str.fromday.value = '';
				str.frommonth.value = '';
				str.fromyear.value = '';
				str.fromhour.value = '';
				str.fromminutes.value = '';
				str.today.value = '';
				str.tomonth.value = '';
				str.toyear.value = '';
				str.tohour.value = '';
				str.deliveryaddress.value = '';
				str.deliveryfname.value = '';
				str.deliverylname.value = '';
				str.deliveryphone.value = '';
			}
			str.token.value;

		}
	}
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}
