function Chmurka(T,t){
 T.title=''
 T.parentNode.lastChild.style.display=t?'block':'none'
}


function emoticon(text) {
// funkcja do komentarzy
//text = ' ' + text +  ' ';
if (document.post.message.createTextRange && document.post.message.caretPos) {			
	var caretPos = document.post.message.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	document.post.message.focus();				
} else if (document.post.message.selectionStart != undefined) {			
	document.post.message.value = document.post.message.value.substring(0, document.post.message.selectionStart) + text + document.post.message.value.substring(document.post.message.selectionStart);
	document.post.message.focus();				
} else {
	document.post.message.value += text;
document.post.message.focus();
}
}

function emoticon_shoutbox(text) {
// funkcja do wykopania na shoutbox
//text = ' ' + text +  ' ';
if (document.post.message2.createTextRange && document.post.message2.caretPos) {			
	var caretPos = document.post.message2.caretPos;
	caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text + ' ' : text;
	document.post.message2.focus();				
} else if (document.post.message2.selectionStart != undefined) {			
	document.post.message2.value = document.post.message2.value.substring(0, document.post.message2.selectionStart) + text + document.post.message2.value.substring(document.post.message2.selectionStart);
	document.post.message2.focus();				
} else {
	document.post.message2.value += text;
document.post.message2.focus();
}
}
	
				
function showHide(id) {      
    obj = document.getElementById(id);
	obj.style.display = (obj.style.display == "block" ? "none" : "block");
}		


function ostatnio_ogladane() {
advAJAX.get({
    url: "ajax/ostatnio_ogladane.php",
    onLoading : function(obj) {
		document.getElementById('ostatnio_ogladane_obrazek').innerHTML = '<img src="images/load.gif">';
		document.getElementById('ostatnio_ogladane_link').innerHTML = '<div class="tresc_mini">each 20 seconds reload</div>';
	},
    onSuccess : function(obj) { 
    	document.getElementById('ostatnio_ogladane_obrazek').innerHTML = '';	 
		document.getElementById('ostatnio_ogladane').innerHTML = obj.responseText;
		    
    }
});
setTimeout("ostatnio_ogladane()",20000);
}

function dodaj_do_ulubionych(id) {
advAJAX.get({
    url: "ajax_ulubione.php?cmd=dodaj&id="+id,
    onLoading : function(obj) {
		document.getElementById('ulubione').innerHTML = '<img src="images/load.gif"> adding to favourite';
	},
    onSuccess : function(obj) {     		 
		document.getElementById('ulubione').innerHTML = obj.responseText;
		document.getElementById('ulubione_ads').innerHTML = document.getElementById('ulubione_ads').innerHTML;    
    }
});
}

function usun_z_ulubionych(id) {
advAJAX.get({
    url: "ajax_ulubione.php?cmd=usun&id="+id,
    onLoading : function(obj) {
		document.getElementById('ulubione').innerHTML = '<img src="images/load.gif"> deleting from favourite';
	},
    onSuccess : function(obj) {     		 
		document.getElementById('ulubione').innerHTML = obj.responseText;
		document.getElementById('ulubione_ads').innerHTML = document.getElementById('ulubione_ads').innerHTML;    
    }
});
}

function fotagi(kat,id) {
advAJAX.get({
    url: "ajax/fotagi.php?kat="+kat+"&id="+id,
    onLoading : function(obj) {
		document.getElementById('fotagi').innerHTML = '<center><table border="0" height="126" cellpadding="0" cellspacing="0" class="tresc"><tr><td><img src="images/load.gif"> loading</td></tr></table></center>';
	},
    onSuccess : function(obj) {     
    	document.getElementById('fotagi').innerHTML = obj.responseText;
    	document.getElementById('fotagi_ads').innerHTML = document.getElementById('fotagi_ads').innerHTML;    
    }
});
}

function ocen() {
advAJAX.submit(document.getElementById("ocen_form"),{
	onLoading : function(obj) {
		document.getElementById('ocen_komunikat').innerHTML = '<img src="images/load.gif"> loading';
	},
    onSuccess : function(obj) { 
		if (obj.responseText == "no") {
			document.getElementById('ocen_komunikat').innerHTML = 'Error, doesn\'t rating file.';
		} else if(obj.responseText == "no2") {
			document.getElementById('ocen_komunikat').innerHTML = 'File doesn\'t exists.';
		} else if(obj.responseText == "no3") {
			document.getElementById('ocen_komunikat').innerHTML = 'Please choose rate.';
		} else {
			document.getElementById('ocen').innerHTML = obj.responseText;
		}    	    
    }
});
}

function wadliwy_plik(id) {
ok = confirm("Are you sure that this file doesn't work?");
if(ok) {
advAJAX.post({
    url: "ajax_wadliwy_plik.php",
    parameters : {
      "id" : id      
    },
    onLoading : function(obj) {
		document.getElementById('wadliwy_plik').innerHTML = '<img src="images/load.gif"> loading';
	},
    onSuccess : function(obj) {     		 
		document.getElementById('wadliwy_plik').innerHTML = obj.responseText;		    
    }
});
}
}

function wykop_na_shoutbox(id) {
advAJAX.get({
    url: "ajax_shoutbox.php?id="+id,
    onLoading : function(obj) {
		document.getElementById('wykop_na_shoutbox').innerHTML = '<img src="images/load.gif"> loading form';
	},
    onSuccess : function(obj) {    		 
		document.getElementById('wykop_na_shoutbox').innerHTML = obj.responseText;
		advAJAX.get({
			url: "ajax/wykop_na_shoutbox_link.php?id="+id,
			onSuccess : function(obj) {    		 
			document.getElementById('wykop_na_shoutbox_link').innerHTML = obj.responseText;				    		
		}
		});						    		
    }
});
}

function wykop_na_shoutbox_ukryj(id) {
advAJAX.get({
	url: "ajax/wykop_na_shoutbox_link.php?id="+id+"&f_do_pokaz=yes",
	onLoading : function(obj) {
		document.getElementById('wykop_na_shoutbox').innerHTML = '<img src="images/load.gif"> loading hide form';
	},
	onSuccess : function(obj) {
		document.getElementById('wykop_na_shoutbox').innerHTML = '';    		 
		document.getElementById('wykop_na_shoutbox_link').innerHTML = obj.responseText;				    		
	}
});					    		
}

function wykop_na_shoutbox_formularz() {
advAJAX.submit(document.getElementById("post_wykop"),{
	onLoading : function(obj) {
		document.getElementById('wykop_na_shoutbox').innerHTML = '<br><br><br><br><img src="images/load.gif"> throwing it on shoutbox<br><br><br><br>';
	},
    onSuccess : function(obj) { 		
		document.getElementById('wykop_na_shoutbox').innerHTML = obj.responseText;
		if(obj.responseText.match('!!') == '!!') {
			wyswietl_shoutbox(); // odswierza shoutbox jesli dodano wpis
		}
    }
});
}

function dodaj_na_shoutbox_formularz() {
advAJAX.submit(document.getElementById("post_dodaj"),{
	onLoading : function(obj) {
		document.getElementById('dodaj_na_shoutbox').innerHTML = '<br><img src="images/load.gif"> adding post';
	},
    onSuccess : function(obj) { 		
		document.getElementById('dodaj_na_shoutbox').innerHTML = obj.responseText;
		if(obj.responseText.match('added!') == 'added!') {
			wyswietl_shoutbox(); // odswierza shoutbox jesli dodano wpis
		}
    }
});
}

function wyswietl_shoutbox() {
advAJAX.get({
	url: "ajax_shoutbox.php?wyswietl=yes",
	onLoading : function(obj) {
		document.getElementById('wyswietl_shoutbox').innerHTML = '<img src="images/load.gif"> loading posts';
	},
	onSuccess : function(obj) {		   		 
		document.getElementById('wyswietl_shoutbox').innerHTML = obj.responseText;				    		
	}
});					    		
}