function otworz(url, width, height, scrollbars) {
noweOkno = window.open(url, 'windowup', 'menubar=no, toolbar=no, location=no, scrollbars='+scrollbars+', resizable=no, status=no, width='+width+', height='+height+',top=100,left=300')
}

function update(){
if (window.XMLHttpRequest){
http_request = new XMLHttpRequest();
}else if(window.ActiveXObject){ 
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
http_request.onreadystatechange = function() { check_and_retry(); };
http_request.open('GET', 'http://www.erofun.pl/func/online.func.php', true);
http_request.send(null);
}


function check_and_retry(){
if(http_request.readyState == 4){
if(http_request.status == 200){
setTimeout("update()", 30000);
}else{
update();
}}}


function report(comment_id, user_id){
if (window.XMLHttpRequest){
http_request = new XMLHttpRequest();
}else if(window.ActiveXObject){ 
http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
http_request.onreadystatechange = function() { check_and_do(comment_id, user_id); };
if(confirm('Napewno chcesz zglosic ten komentarz do moderacji? (nieuzasadnione zglaszanie komentarzy, bedzie odpowiednio karane.)')){
http_request.open('GET', 'http://www.erofun.pl/report.php?comment_id='+comment_id+'&user_id='+user_id, true);
}
http_request.send(null);
}

function check_and_do(comment_id, user_id){
if(http_request.readyState == 4){
if(http_request.status == 200){
document.getElementById("c"+comment_id).innerHTML += '<br /><br /><span style="font-size:12px; color:#FF0000; font-weight:bold;">Dziekujemy! Komentarz zostal zgloszony do moderacji.</span>';
}else{
report(comment_id, user_id);
}}}



function connect(){
	if (window.XMLHttpRequest){
		http_request = new XMLHttpRequest();
}
else if(window.ActiveXObject){ 
	http_request = new ActiveXObject("Microsoft.XMLHTTP");
}
}


function moderate(mode, comment_id, target_id, user_id, qst){
connect();

http_request.onreadystatechange = function(){ 	

if(http_request.readyState == 4){
		if(http_request.status == 200){
			
			switch(mode){
		
			case 'comment_delete':
				document.getElementById("c"+comment_id).innerHTML = '<span style="font-size:14px; color:#FF0000; font-weight:bold;">Komentarz zostal usuniety.</span>';
			break;
		
			case 'user_warning':
				document.getElementById("c"+comment_id).innerHTML += '<br /><br /><span style="font-size:12px; color:#FF0000; font-weight:bold;">Uzytkownik otrzymal ostrzezenie.</span>';
			break;
		
			case 'user_ban':
				document.getElementById("c"+comment_id).innerHTML += '<br /><br /><span style="font-size:12px; color:#FF0000; font-weight:bold;">Uzytkownik zostal zbanowany.</span>';
			break;
	
			}				
		}
		else
		{
			moderate(mode, comment_id, target_id, user_id, '0');
		}
}
}

if (qst == 1){
	if(confirm('Czy jestes pewien?')){
		http_request.open('GET', 'http://www.erofun.pl/modules/moderate.module.php?mode='+mode+'&comment_id='+comment_id+'&target_id='+target_id+'&user_id='+user_id, true);	
		http_request.send(null);
}} else {
	http_request.open('GET', 'http://www.erofun.pl/modules/moderate.module.php?mode='+mode+'&comment_id='+comment_id+'&target_id='+target_id+'&user_id='+user_id, true);	
	http_request.send(null);
}
}

function ChangeThumb(hash, i, y){
i++;
if(i>y) i=1;
document.getElementById("thumb"+hash).innerHTML='<img class="thumb" src="http://thumbs.erofun.pl/'+hash+'/thumb_'+i+'.jpg" />';
setTimeout(function() { document.getElementById("thumb"+hash).innerHTML='<img class="thumb" src="http://thumbs.erofun.pl/'+hash+'/thumb_'+i+'.jpg" onmouseover="javascript:ChangeThumb(\''+hash+'\',\''+i+'\',\''+y+'\');" />'; }, 1000);
}


function ChangePopVote(id){
	
	document.getElementById("PopVote").src = '/gfx/pop/'+id+'.gif';
	
	switch(id){
		
		case '1':
        var info = 'Dno!';
		break;
		
		case '2':
        var info = 'S'+String.fromCharCode(322)+'abe';
		break;
		
		case '3':
        var info = String.fromCharCode(346)+'rednie';
		break;
		
		case '4':
        var info = 'Fajne';
		break;
		
		case '5':
        var info = 'Zajebiste!';
		break;
	}
	
	document.getElementById("PopInfo").innerHTML=info;

}

function adultCheck(check){
		if(check==0){
document.getElementById('mainDiv').innerHTML='<div style="width:475px; margin-left:auto; margin-right:auto; margin-top:70px; text-align:center; color:black;"><div id="logointro"></div><div style="background-color:#504C78; margin:0px; margin-top:20px; padding:2px; padding-bottom:20px; color:#000000;"><font style="font-weight:bold; font-size:12px;">UWAGA!</font> Serwis <font style="font-weight:bold; font-size:18px; color:#ffffff;">EroFun.pl</font> zawiera tre&#347;ci o tematyce erotycznej i jest przeznaczony <u>tylko i wy&#322;&#261;cznie</u> dla os&oacute;b powy&#380;ej <font style="font-weight:bold; color:#000000;">18 roku &#380;ycia</font>.<p style="border:1px #000000 dashed; background-color:#333333; color:#FFFFFF;">Je&#347;li nie uko&#324;czy&#322;e&#347; <font style="font-weight:bold;">18 roku &#380;ycia</font>, nie chcesz ogl&#261;da&#263; tego typu tre&#347;ci lub jest to niezgodne z prawem Twojego kraju, nie wolno Ci wchodzi&#263; dalej!</p><p style="margin-bottom:0px;">Wchodz&#261;c dalej <u>o&#347;wiadczasz</u>, &#380;e jeste&#347; osob&#261; pe&#322;noletni&#261;, chcesz ogl&#261;da&#263; tre&#347;ci o tematyce erotycznej z w&#322;asnej, nie przymuszonej woli oraz odbi&oacute;r tych tre&#347;ci nie zosta&#322; Ci w &#380;aden spos&oacute;b narzucony.</p></div><div style="height:30px; padding-top:15px; font-size:22px; font-weight:bold; clear:both;"><a href="?enter" style="color:#ffffff; border:1px solid #504C78; padding-right:30px; padding-left:30px; padding-top:5px; padding-bottom:5px; background-color:#504C78;">WCHODZ&#280;</a> <a href="http://pajacyk.pl" style="color:#504C78; border:1px solid #504C78; padding-right:30px; padding-left:30px; padding-top:5px; padding-bottom:5px; background-color:#333333;">NIE WCHODZ&#280;</a></div></div>';
}}

function vote(target_id, ayes){
	
	connect();
	
	http_request.onreadystatechange = function(){ 	

		if(http_request.readyState == 4){
			if(http_request.status == 200){
			
			document.getElementById("PopValue").innerHTML='';
			document.getElementById("PopInfo").innerHTML='Dzi'+String.fromCharCode(281)+'kujemy! G'+String.fromCharCode(322)+'os zosta'+String.fromCharCode(322)+' oddany.';	
		
			}else vote(target_id, ayes);			
		}}
	
	http_request.open('GET', 'http://www.erofun.pl/votePop.php?target_id='+target_id+'&ayes='+ayes, true);	
	http_request.send(null);

}

function add2favorites(target_id){
	
	connect();
	
	http_request.onreadystatechange = function(){ 	

		if(http_request.readyState == 4){
			if(http_request.status == 200){
			
			document.getElementById("AddFavorites").innerHTML='Gra zostala dodana do Twojej listy ulubionych.';
		
			}else add2favorites(target_id);			
		}}
	
	http_request.open('GET', 'http://www.erofun.pl/add2favorites.php?target_id='+target_id, true);	
	http_request.send(null);

}

function url(order){
var gourl = order.options[order.selectedIndex].value; 
window.self.location.href = gourl;
}

function show(id)
{
	document.getElementById(id).style.display = 'block';
	return 1;
}


function hide(id)
{
	document.getElementById(id).style.display = 'none';
	return 1;
}


function show_hide(id)
{
	obj = document.getElementById(id);
	
	if (obj.style.display == 'none')
		document.getElementById(id).style.display = 'block';
	else
		document.getElementById(id).style.display = 'none';
		
	return 1;
}
