function Submenu(btn) {
	
	var submenu;
	submenu = 'btn_'+btn+'_menu';
	
	document.getElementById("btn_se_menu").style.display = 'none';
	document.getElementById("btn_ne_menu").style.display = 'none';
	document.getElementById("btn_ar_menu").style.display = 'none';
	document.getElementById("btn_me_menu").style.display = 'none';
	document.getElementById("btn_bl_menu").style.display = 'none';
	
	if (btn!='null')
	document.getElementById(submenu).style.display = 'block';
	
	xmlHttp=GetXmlHttpObject();

	var url="ajax/sesje.php";
		url=url+"?btn="+btn;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function ScreamUserBox(i) {
	if(i==1) {
		document.getElementById("screambox").style.background = "url(grafika/screambox_active.png)";
		document.getElementById("panel").style.background = "url(grafika/panel.png)";
		document.getElementById("bScreambox").style.display = "block";
		document.getElementById("bPanel").style.display = "none";
	}
	else {
		document.getElementById("screambox").style.background = "url(grafika/screambox.png)";
		document.getElementById("panel").style.background = "url(grafika/panel_active.png)";
		document.getElementById("bScreambox").style.display = "none";
		document.getElementById("bPanel").style.display = "block";
	}
}
function NajSondaBox(i) {
	if(i==1) {
		document.getElementById("najlepiej").style.background = "url(grafika/najlepiej_active.png)";
		document.getElementById("sonda").style.background = "url(grafika/sonda.png)";
		document.getElementById("bNaj").style.display = "block";
		document.getElementById("bSonda").style.display = "none";
	}
	else {
		document.getElementById("najlepiej").style.background = "url(grafika/najlepiej.png)";
		document.getElementById("sonda").style.background = "url(grafika/sonda_active.png)";
		document.getElementById("bNaj").style.display = "none";
		document.getElementById("bSonda").style.display = "block";
	}
}
function LosowaGrafikaFilmik(i) {
	if(i==1) {
		document.getElementById("grafika").style.background = "url(grafika/grafika_active.png)";
		document.getElementById("filmik").style.background = "url(grafika/filmik.png)";
		document.getElementById("losowa_grafika").style.display = "block";
		document.getElementById("losowy_filmik").style.display = "none";
	}
	else {
		document.getElementById("grafika").style.background = "url(grafika/grafika.png)";
		document.getElementById("filmik").style.background = "url(grafika/filmik_active.png)";
		document.getElementById("losowa_grafika").style.display = "none";
		document.getElementById("losowy_filmik").style.display = "block";
	}
}
function Statystyki(i) {
	if(i==1) {
		document.getElementById("widziani").style.background = "url(grafika/widziani_active.png)";
		document.getElementById("statystyki").style.background = "url(grafika/statystyki.png)";
		document.getElementById("bottom_widziani").style.display = "block";
		document.getElementById("bottom_statystyki").style.display = "none";
	}
	else {
		document.getElementById("widziani").style.background = "url(grafika/widziani.png)";
		document.getElementById("statystyki").style.background = "url(grafika/statystyki_active.png)";
		document.getElementById("bottom_widziani").style.display = "none";
		document.getElementById("bottom_statystyki").style.display = "block";
	}
}
function Download(i) {
	if(i==1) {
		document.getElementById("najnowsze").style.background = "url(grafika/najnowsze_active.png)";
		document.getElementById("najpopularniejsze").style.background = "url(grafika/najpopularniejsze.png)";
	}
	else {
		document.getElementById("najnowsze").style.background = "url(grafika/najnowsze.png)";
		document.getElementById("najpopularniejsze").style.background = "url(grafika/najpopularniejsze_active.png)";
	}
}

function Newsletter(type) {
	
	xmlHttp=GetXmlHttpObject();
	
		var email;
		email = document.getElementById("NewsletterEmail").value;
		
	var url="ajax/newsletter.php";
		url=url+"?email="+email;
		url=url+"&type="+type;
		url=url+"&sid="+Math.random();
		xmlHttp.onreadystatechange=function tmp(){
			if (xmlHttp.readyState==4){ 
			if(type == 1) {
				if(xmlHttp.responseText == 1) {
					document.getElementById("NewsletterEmail").value = 'Podano błędny email';
				} else if(xmlHttp.responseText == 2) {
					document.getElementById("NewsletterEmail").value = 'Email istnieje w bazie';
				} else {
					document.getElementById("NewsletterEmail").value = 'Email został dodany';
				}
			} else if(type == 2) {
				document.getElementById("NewsletterEmail").value = 'Email został usunięty';
			}
 		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
function bottom_change(type, tab) {
	
	xmlHttp=GetXmlHttpObject();
	
	var url="ajax/bottom.php";
		url=url+"?type="+type;
		url=url+"&tab="+tab;
		xmlHttp.onreadystatechange=function tmp(){
			if (xmlHttp.readyState==4 ){
				var where = "bottom_"+tab;
				document.getElementById(where).innerHTML=xmlHttp.responseText;
 		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function last_comments(tab) {
	
	xmlHttp=GetXmlHttpObject();
	
	var url="ajax/komentarze.php";
		url=url+"?tab="+tab;
		xmlHttp.onreadystatechange=function tmp(){
			if (xmlHttp.readyState==4 ){
				var where = "ostatnie_komenty";
				document.getElementById(where).innerHTML=xmlHttp.responseText;
 		}
	};
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function Show(id) {
	document.getElementById(id).style.display = 'block';
}
function Hide(id) {
	document.getElementById(id).style.display = 'none';
}
function Options(id) {
	if(document.getElementById(id).style.display == 'block') {
		Hide(id);
	} else {
		Show(id);
	}
}
function AddFriend(friend) {
	
	xmlHttp=GetXmlHttpObject();
	
	var url="ajax/friend.php";
		url=url+"?friend="+friend;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	AddedFriend(friend);
}

function AddedFriend(friend) {
  jQuery.blockUI({ 
            message: '<b>Zaproszenie do użytkownika '+friend+' zostało wysłane. Poczekaj na akceptację zaproszenia.</b>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .8, 
            color: '#000' 
            } 
        }); 
 
   setTimeout(jQuery.unblockUI, 4000);

}

function RemoveFriend(friend) {
	
	xmlHttp=GetXmlHttpObject();
	
	var url="ajax/rfriend.php";
		url=url+"?friend="+friend;

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	RemovedFriend(friend);
}

function RemovedFriend(friend) {
  jQuery.blockUI({ 
            message: '<b>Użytkownik '+friend+' został usunięty z listy Twoich znajomych.</b>', 
            css: { 
            border: 'none', 
            padding: '15px', 
            backgroundColor: '#fff', 
            '-webkit-border-radius': '10px', 
            '-moz-border-radius': '10px', 
            opacity: .8, 
            color: '#000' 
            } 
        }); 
 
   setTimeout(jQuery.unblockUI, 4000);

}

function Odznacz() {
	
	xmlHttp=GetXmlHttpObject();
	
	var url="ajax/odznacz.php";

	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function confirmation() {
	var agree = confirm("Czy na pewno chcesz usunąć?");
	if(agree) {
  		return true;
	} else {
		return false;
	}
}


		