function createRequestObject() { 
    var ro; 
    var browser = navigator.appName; 
    if(browser == "Microsoft Internet Explorer"){ 
        ro = new ActiveXObject("Microsoft.XMLHTTP"); 
    }else{ 
        ro = new XMLHttpRequest(); 
		//ro = XMLHttcodequest();
    } 
    return ro; 
} 

var http = createRequestObject(); 
var http1 = createRequestObject(); 
var http2 = createRequestObject(); 
var http3= createRequestObject(); 

function startUpload(id) {    
	document.getElementById('dispPreloader'+id).style.display = 'block';    
	return true;
}

function stopUpload(id, success, error) {      
	if (error == "") {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		document.getElementById('dispFormId'+id).style.display = 'none';
		document.getElementById('dispPhotoId'+id).innerHTML = success;
		document.getElementById('dispPhotoId'+id).style.display = 'block';		
	} else {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		var mess = error.split('|');
		var str = "";
		for (var i =0; i < mess.length; i++)
			str = str + mess[i] + '\n';
		
		alert(str);
	}
	return true;   
}

function startUploadAvatar(id) {    
	document.getElementById('dispPreloader'+id).style.display = 'block';    
	return true;
}

function stopUploadAvatar(id, success, error) {      
	if (error == "") {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		document.getElementById('dispPhotoId'+id).innerHTML = success;
		document.getElementById('dispPhotoId'+id).style.display = 'block';		
	} else {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		var mess = error.split('|');
		var str = "";
		for (var i =0; i < mess.length; i++)
			str = str + mess[i] + '\n';
		
		alert(str);
	}
	return true;   
}

function startUploadRelation(id) {    
	document.getElementById('dispPreloader'+id).style.display = 'block';    
	return true;
}

function stopUploadRelation(id, success, error) {      
	if (error == "") {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		document.getElementById('dispFormId'+id).style.display = 'none';
		document.getElementById('uploaded').innerHTML = document.getElementById('uploaded').innerHTML + success;
	} else {
		document.getElementById('dispPreloader'+id).style.display = 'none';
		var mess = error.split('|');
		var str = "";
		for (var i =0; i < mess.length; i++)
			str = str + mess[i] + '\n';
		
		alert(str);
	}
	return true;   
}


function ajaxPhotoDelete(pid) {
  if (confirm("Napewno chcesz usunąć zdjęcie?")) {
	  http.abort();
	  http.open("GET", "ajaxPhotoDelete.php?pid=" + pid, true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
		   if (http.responseText == "ok") {
				location.reload(true);
		  } 
		} 
	  }
	  http.send(null);	  
  }
}

function ajaxVideoDelete(vid) {
  if (confirm("Napewno chcesz usunąć film?")) {
	  http.abort();
	  http.open("GET", "ajaxVideoDelete.php?vid=" + vid, true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
		   if (http.responseText == "ok") {
				location.reload(true);
		  } 
		} 
	  }
	  http.send(null);	  
  }
}

function ajaxRelationDelete(rid) {
  if (confirm("Napewno chcesz usunąć relację?")) {
	  http.abort();
	  http.open("GET", "ajaxRelationDelete.php?rid=" + rid, true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
		   if (http.responseText == "ok") {
				location.reload(true);
		  } 
		} 
	  }
	  http.send(null);	  
  }
}

function ajaxProfilComment(p, uid) {
  var field = document.getElementById('ajaxProfilCommentField');

  http.abort();
  http.open("GET", "ajaxProfilComment.php?uid=" + uid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxProfilCommentAdd(uid) {
  var content = document.commentForm.profil_comment.value;

if (content == '') 
  	alert("Wpisz treść kometnarza");
 else if (logged == false)
 	alert("Dodawanie komentarzy wymaga zalogowania");
 else {
	  http.abort();
	  http.open("GET", "ajaxProfilCommentAdd.php?uid=" + uid + "&comment=" + escape(content), true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
			ajaxProfilComment("0", uid);
		} 
	  }
	  http.send(null);	 
 }
}

function ajaxRelationDelComment(cid, rid) {
  http.abort();
  http.open("GET", "ajaxRelationDelComment.php?cid=" + cid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			if (http.responseText == "ok") {
				ajaxRelationComments(rid, "0");
				//document.getElementById('s' + cid).innerHTML = "";
			}
	  } 
	} 
  }
  http.send(null);
}

function ajaxRelationFriend(stat, fid) {
  http.abort();
  http.open("GET", "ajaxRelationFriend.php?stat=" + stat + "&fid=" + fid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert(http.responseText);
	  } 
	} 
  }
  http.send(null);
}

function ajaxRelationFriend2(stat, fid) {
  http.abort();
  http.open("GET", "ajaxRelationFriend2.php?stat=" + stat + "&fid=" + fid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			if (http.responseText == "ok")
				document.getElementById('s' + fid).innerHTML = "";
	  } 
	} 
  }
  http.send(null);
}

function ajaxInvite(stat, fid) {
  http.abort();
  http.open("GET", "ajaxInvite.php?stat=" + stat + "&fid=" + fid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert(http.responseText);
	  } 
	} 
  }
  http.send(null);
}

function ajaxVideoDelComment(cid, vid) {
  http.abort();
  http.open("GET", "ajaxVideoDelComment.php?cid=" + cid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			if (http.responseText == "ok") {
				ajaxVideoComments(vid, "0");
				//document.getElementById('s' + cid).innerHTML = "";
			}
	  } 
	} 
  }
  http.send(null);
}

function ajaxPhotoDelComment(cid, pid) {
  http.abort();
  http.open("GET", "ajaxPhotoDelComment.php?cid=" + cid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			if (http.responseText == "ok") {
				ajaxPhotoComments(pid, "0");
				//document.getElementById('s' + cid).innerHTML = "";
			}
	  } 
	} 
  }
  http.send(null);
}

function ajaxGetAktualnosci(p) {
  var field = document.getElementById('ajaxAktualnosciField');

  http.abort();
  http.open("GET", "ajaxGetAktualnosci.php?p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxGetPomoc(p) {
  var field = document.getElementById('ajaxPomocField');

  http.abort();
  http.open("GET", "ajaxGetPomoc.php?p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxAddFriend(uid) {
  var field = document.getElementById('ajaxAddFriendField');

  http.abort();
  http.open("GET", "ajaxAddFriend.php?uid=" + uid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxAddRelationFriend(rid) {

	http.abort();
  http.open("GET", "ajaxAddRelationFriend.php?rid=" + rid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert(http.responseText);
	  } 
	} 
  }
  http.send(null);
}

function ajaxGetOffice(id) {
	var field = document.getElementById('bid');	
	field.options.length = 0;
	
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetOffice.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}

function checkOfficeForm() {
	
	var form = document.forms['officeForm'];
	
	if (form.name.value == '' || form.street.value == '' || form.city.value == '' || form.phone.value == '') {
		alert("Wypelnij wszystkie wymagane pola (oznaczone '*')");
	} else {
		  http.abort();
		  http.open("GET", "ajaxOfficeAdd.php?name=" + form.name.value + "&street=" + form.street.value + "&city=" + form.city.value + "&phone=" + form.phone.value + "&fax=" + form.fax.value + "&email=" + form.email.value + "&www=" + form.www.value + "&logo_url=" + form.logo_url.value, true);
		  http.onreadystatechange=function() {
			if(http.readyState == 4) {
			   if (http.responseText != "") {
				   var string=http.responseText.split("|"); 				
				   
				   var ctemp = false;
				   
				   for (i=0; i < document.getElementById('b_city').length; i++) {
				   		if 	(document.getElementById('b_city').options[i].value == string[0]) {
							ctemp = true;
							document.getElementById('b_city').options[i].selected = true;
							ajaxGetOffice(string[0]);
						}
				   }
				   if (ctemp == false) {
						document.getElementById('b_city').options[document.getElementById('b_city').length] = new Option(form.city.value, string[0]);
						document.getElementById('b_city').options[document.getElementById('b_city').length - 1].selected = true;
						document.getElementById('bid').options.length = 0;
				   }
				   
				   
				   if (ctemp == false)
					   document.getElementById('bid').options[document.getElementById('bid').length] = new Option(form.name.value, string[1]);
					else					   
					   for (var i=0; i < document.getElementById('bid').length; i++) {
							if 	(document.getElementById('bid').options[i].text == form.name.value) {
								document.getElementById('bid').options[i].selected = true;
							}
					   }					   
			  } 
			} 
		  }
		  http.send(null);		
		  
		  tb_remove();
	}	
	
	return false;
}


function checkOfficeForm2() {
	
	var form = document.forms['officeForm'];
	
	if (form.name.value == '' || form.street.value == '' || form.city.value == '' || form.phone.value == '') {
		alert("Wypelnij wszystkie wymagane pola (oznaczone '*')");
	} else {
		  http.abort();
		  http.open("GET", "ajaxOfficeAdd2.php?name=" + form.name.value + "&street=" + form.street.value + "&city=" + form.city.value + "&phone=" + form.phone.value + "&fax=" + form.fax.value + "&email=" + form.email.value + "&www=" + form.www.value + "&logo_url=" + form.logo_url.value, true);
		  http.onreadystatechange=function() {
			if(http.readyState == 4) {
			   if (http.responseText == "ok") {
					alert("Nowe biuro zostało dodane");
			   } 
			} 
		  }
		  http.send(null);		
		  
		  tb_remove();
	}	
	
	return false;
}

function ajaxDelFriend(id) {
	
  http.abort();
  http.open("GET", "ajaxDelFriend.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText == "ok") {
			document.getElementById('f'+id).style.display='none'; 	
	  } 
	} 
  }
  http.send(null);	
}

function ajaxChangeSkin(sid) {
  http.abort();
  http.open("GET", "ajaxChangeSkin.php?sid=" + sid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			if ( http.responseText == "ok")	
				location.reload(true);
	  } 
	} 
  }
  http.send(null);
}


function ajaxGetCountry(id) {
	var field = document.getElementById('country');	
	field.options.length = 0;
	//ajaxGetCity2(0);
	//ajaxGetHotel2(0);
	
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetCountry.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}

function ajaxGetCity(id) {
	var field = document.getElementById('city');	
	field.options.length = 0;
	ajaxGetHotel2(0);
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetCity.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}

function ajaxGetHotel(id) {
	var field = document.getElementById('hotel');	
	field.options.length = 0;
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetHotel.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}


function ajaxGetOffice2(id, cid) {
	var field = document.getElementById('bid');	
	field.options.length = 0;
	
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetOffice.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			var cur = 0;
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
				
				if (tmp1 == cid)
					cur = tmp1;
			}
			
			field.selectedIndex = cur;
	  } 
	} 
  }
  http.send(null);	
}



function ajaxGetCountry2(id, cid) {
	var field = document.getElementById('country');	
	field.options.length = 0;
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http1.abort();
  http1.open("GET", "ajaxGetCountry.php?id=" + id, true);
  http1.onreadystatechange=function() {
    if(http1.readyState == 4) {
	   if (http1.responseText != "") {
			var myArray = eval(http1.responseText);
			var cur = 0;
			var t = 0;

			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
				
				t++;
				
				if (tmp1 == cid)
					cur = t;
			}
			
			field.selectedIndex = cur;
	  } 
	} 
  }
  http1.send(null);	
}

function ajaxGetCity2(id, cid) {
	var field = document.getElementById('city');	
	field.options.length = 0;
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http2.abort();
  http2.open("GET", "ajaxGetCity.php?id=" + id, true);
  http2.onreadystatechange=function() {
    if(http2.readyState == 4) {
	   if (http2.responseText != "") {
			var myArray = eval(http2.responseText);
			var cur = 0;
			var t = 0;
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<=myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				if (tmp1 != "" && tmp2 != "")
				field.options[field.options.length] = new Option(tmp2, tmp1);
				
				t++;
				
				if (tmp1 == cid)
					cur = t;
			}
			
			field.selectedIndex = cur;
	  } 
	} 
  }
  http2.send(null);	
}

function ajaxGetHotel2(id, cid) {
	var field = document.getElementById('hotel');	
	field.options.length = 0;
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http3.abort();
  http3.open("GET", "ajaxGetHotel.php?id=" + id, true);
  http3.onreadystatechange=function() {
    if(http3.readyState == 4) {
	   if (http3.responseText != "") {
			var myArray = eval(http3.responseText);
			var cur = 0;
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				if (tmp1 != "" && tmp2 != "")
				field.options[field.options.length] = new Option(tmp2, tmp1);
			
			if (tmp1 == cid)
					cur = tmp1;
			}
			
			field.selectedIndex = cur;
	  } 
	} 
  }
  http3.send(null);	
}

function ajaxGetCountry3(id) {
	var field = document.getElementById('country');	
	field.options.length = 0;
	ajaxGetCity2(0);
	
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetCountry.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}

function ajaxGetCity3(id) {
	var field = document.getElementById('city');	
	field.options.length = 0;
		
	field.options[field.options.length] = new Option('Ladowanie...','0');
	
  http.abort();
  http.open("GET", "ajaxGetCity.php?id=" + id, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			var myArray = eval(http.responseText);
			
			field.options[0] = null;
			field.options[field.options.length] = new Option("- wybierz -", "0");
			
			for (i=1;i<myArray.length;i++) {
				var tmp1 = myArray[i];
				i++;
				var tmp2 = myArray[i];
				
				field.options[field.options.length] = new Option(tmp2, tmp1);
			}
	  } 
	} 
  }
  http.send(null);	
}

function ajaxRelationOcena(rid, oid) {
  http.abort();
  http.open("GET", "ajaxRelationOcena.php?rid=" + rid + "&oid=" + oid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
		   alert(http.responseText);
	  } 
	} 
  }
  http.send(null);	
}

function ajaxVideoOcena(vid, oid) {
  http.abort();
  http.open("GET", "ajaxVideoOcena.php?vid=" + vid + "&oid=" + oid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
		   alert(http.responseText);
	  } 
	} 
  }
  http.send(null);	
}

function ajaxRelationPhotos(rid, p) {
  var field = document.getElementById('relation_photos');

  http.abort();
  http.open("GET", "ajaxRelationPhotos.php?rid=" + rid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
		   //alert(http.responseText);
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxRelationVideos(rid, p) {
  var field = document.getElementById('relation_photos');

  http.abort();
  http.open("GET", "ajaxRelationVideos.php?rid=" + rid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxRelationComments(rid, p) {
  var field = document.getElementById('relation_comments');

  http.abort();
  http.open("GET", "ajaxRelationComments.php?rid=" + rid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxRelationCommentAdd(rid) {
  var content = document.commentForm.relation_comment.value;

if (content == '') 
  	alert("Wpisz treść kometnarza");
 else if (logged == false)
 	alert("Dodawanie komentarzy wymaga zalogowania");
 else {
	  http.abort();
	  http.open("GET", "ajaxRelationCommentAdd.php?rid=" + rid + "&comment=" + escape(content), true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
		
			ajaxRelationComments(rid, 0);
		} 
	  }
	  http.send(null);	 
 }
}

function ajaxVideoCommentAdd(vid) {
  var content = document.commentForm.video_comment.value;

if (content == '') 
  	alert("Wpisz treść kometnarza");
 else if (logged == false)
 	alert("Dodawanie komentarzy wymaga zalogowania");
 else {
	  http.abort();
	  http.open("GET", "ajaxVideoCommentAdd.php?vid=" + vid + "&comment=" + escape(content), true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
			ajaxVideoComments(vid, "0");
		} 
	  }
	  http.send(null);	 
 }
}

function ajaxVideoComments(vid, p) {
  var field = document.getElementById('video_comments');

  http.abort();
  http.open("GET", "ajaxVideoComments.php?vid=" + vid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxPhotoComments(pid, p) {
  var field = document.getElementById('photo_comments');

  http.abort();
  http.open("GET", "ajaxPhotoComments.php?pid=" + pid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			//alert(http.responseText);
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxPhotoCommentAdd(pid) {
  var content = document.commentForm.comment.value;

if (content == '') 
  	alert("Wpisz treść kometnarza");
 else if (logged == false)
 	alert("Dodawanie komentarzy wymaga zalogowania");
 else {
	  
	  http.abort();
	  http.open("GET", "ajaxPhotoCommentAdd.php?pid=" + pid + "&comment=" + escape(content), true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
			ajaxPhotoComments(pid, "0");
		} 
	  }
	  http.send(null);	 
 }
}

function ajaxOfficeOpinion(bid, p) {
  var field = document.getElementById('office_opinion');

  http.abort();
  http.open("GET", "ajaxOfficeOpinion.php?bid=" + bid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxOfficeComments(bid, p) {
  var field = document.getElementById('office_comments');

  http.abort();
  http.open("GET", "ajaxOfficeComments.php?bid=" + bid + "&p=" + p, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			field.innerHTML = http.responseText;
	  } 
	} 
  }
  http.send(null);
}

function ajaxOfficeCommentAdd(bid) {
  var content = document.commentForm.office_comment.value;

if (content == '') 
  	alert("Wpisz treść kometnarza");
 else {
	  http.abort();
	  http.open("GET", "ajaxOfficeCommentAdd.php?bid=" + bid + "&comment=" + escape(content), true);
	  http.onreadystatechange=function() {
		if(http.readyState == 4) {
			alert("Kometnarz został dodany");
		} 
	  }
	  http.send(null);	 
 }
}


function delProfilComment(cid) {
  var thing = document.getElementById('ajaxProfilCommentField_' + cid);
    
  http3.abort();
  http3.open("GET", "ajaxDelProfilComment.php?cid=" + cid, true);
  http3.onreadystatechange=function() {
	if(http3.readyState == 4) {
		thing.innerHTML = '';
	} 
  }
}


///////////////// NON AJAX /////////////////////////
function formSearchUserForm() {
	for (var i=0; i < document.sortType.order.length; i++) {
	   {
	   if (document.sortType.order[i].checked)
		  {
		  var o = document.sortType.order[i].value;
		  }
	   }
	}
	
	if (o != 'd' && o != 'l')
		o = 'd';
	
	for (var i=0; i < document.sortType.sortv.length; i++) {
	   {
	   if (document.sortType.sortv[i].checked)
		  {
		  var s = document.sortType.sortv[i].value;
		  }
	   }
	}	
	
	if (s != 'a' && s != 'd')
		s = 'a';

	var d = document.sortType.domena.value;	
	var u = document.getElementById('name').value;	

	var p = document.getElementById('p').value;		
	if (p == '')
		p = 0;

	window.location = 'http://'+d+'/wyszukiwarka/uzytkownik/'+u+','+p+','+o+','+s;
}


function formSearchUserForm() {
	var n = document.userForm.name.value;
	var d = document.userForm.domena.value;	

	window.location = 'http://'+d+'/wyszukiwarka/uzytkownik/'+n;
}

function formSearchRelationForm() {
	for (var i=0; i < document.relationForm.rodzaj.length; i++) {
	   {
	   if (document.relationForm.rodzaj[i].checked)
		  {
		  var k = document.relationForm.rodzaj[i].value;
		  }
	   }
	}	
		
	var con = document.relationForm.continent.value;
	var cou = document.relationForm.country.value;	
	var cit = document.relationForm.city.value;	
	var d = document.relationForm.domena.value;	
	var f = document.relationForm.fraza.value;	

	window.location = 'http://'+d+'/wyszukiwarka/media/'+f+','+con+','+cou+','+cit+','+k;
}

function ajaxNaduzycieVideo(vid) {
  http.abort();
  http.open("GET", "ajaxNaduzycieVideo.php?vid=" + vid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert("Zgłoszenie zostało przyjęte");
	  } 
	} 
  }
  http.send(null);
}

function ajaxNaduzyciePhoto(pid) {
  http.abort();
  http.open("GET", "ajaxNaduzyciePhoto.php?pid=" + pid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert("Zgłoszenie zostało przyjęte");
	  } 
	} 
  }
  http.send(null);
}

function ajaxNaduzycieRelation(rid) {
  http.abort();
  http.open("GET", "ajaxNaduzycieRelation.php?rid=" + rid, true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
	   if (http.responseText != "") {
			alert("Zgłoszenie zostało przyjęte");
	  } 
	} 
  }
  http.send(null);
}





