function ChangeDialog(radio)
{
    var id_user=radio.value;
    try{
	parent.dialog_iframe.location="dialog.php?id_to_user="+id_user+"#end";
	}catch(e){}


     try{
	parent.input_iframe.location="input_field.php?id_to_user="+id_user+"#end";
	}catch(e){}
}


function ZalogujSie()
{

	var forma=document.forma;
	if(forma.nick.value!="")
	{
		forma.action="log_me.php?chat_regulamin=1";
		forma.submit();
	}
	else
	{
		alert("wpisz swój nick");
		forma.nick.focus();
	}
	
}

function WylogujSie()
{
	window.location="logout.php?chat_regulamin=1";
}

function Wejdz()
{
	var forma=document.forma;
	
	if(forma.nick.value!="")
	{
		forma.action="log_me.php?chat_regulamin=1&enter=1";
		forma.submit();
	}
	else
	{
		alert("wpisz swój nick");
		forma.nick.focus();
	}
}

function NowyPokoj()
{
	
	var forma=document.forma;
	var expert="";
	
	if(my_status==3)
		if(forma.expert.selectedIndex>0)
			expert=forma.expert.options[forma.expert.selectedIndex].text;
	
	
	
	if(forma.new_room.value!="")
	{
		if(expert!="")
		{
			if(confirm("czy na pewno chcesz stworzyć pokój '"+forma.new_room.value+"' dla wróżki '"+expert+"' ?"))
			{
				forma.action="new_room.php";
				forma.submit();
			}
		}
		else
		{
			forma.action="new_room.php";
			forma.submit();
		
		}
	}
	else
	{
		alert("podaj nazwę nowego pokoju");
		forma.new_room.focus();
	}
}
/*
function NowyExpert()
{
	var forma=document.forma;
	if(forma.new_expert.value!="")
	{
		forma.action="new_expert.php";
		forma.submit();
	}
	else
	{
		alert("podaj nazwę nowej wróżki");
		forma.new_expert.focus();
	}
}
*/

function DodajExperta()
{
	var kontener=new Object();		
	var src="edit_expert.php?";	
	var zrodlo="iframe.php?src="+escape(src);		
	
	var window_top=50
	var window_left=50
	var window_width=400
	var window_height=400

	kontener.dokument=window.document;						
	var parameters="dialogWidth:"+window_width +"px;dialogHeight:"+window_height+"px;dialogTop:"+window_top+";dialogLeft:"+window_left+";edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:no";			   
	var wynik=showModalDialog(zrodlo,kontener,parameters);		
	window.location=window.location;

}

function EdytujExperta()
{
	var forma=document.forma;
	var expert=forma.expert.options[forma.expert.selectedIndex].value;
	
	EdytMe(expert)

}


function EdytMe(id)
{
	
	if(id>0)
	{
		var kontener=new Object();		
		var src="edit_expert.php?id_user="+id;	
		var zrodlo="iframe.php?src="+escape(src);		
		
		var window_top=50
		var window_left=50
		var window_width=400
		var window_height=400
	
		kontener.dokument=window.document;						
		var parameters="dialogWidth:"+window_width +"px;dialogHeight:"+window_height+"px;dialogTop:"+window_top+";dialogLeft:"+window_left+";edge: Raised; center: Yes; help: No; resizable: No; status: No;scroll:no";			   
		var wynik=showModalDialog(zrodlo,kontener,parameters);	
		window.location=window.location;
	}	
	else
	{
		alert("wybierz wrózkę");
		forma.expert.focus();
	}

}


function KasujPokoj()
{
	var forma=document.forma;
	var room=forma.room.options[forma.room.selectedIndex].value;

	if(room!="")
		if(confirm("czy na pewno chcesz skasować pokój '"+room+"'?"))
		{
			forma.action="delete_room.php";
			forma.submit();
		
		}

}

function KasujExperta()
{
	var forma=document.forma;
	var expert=forma.expert.options[forma.expert.selectedIndex].text;
	var id_user=forma.expert.options[forma.expert.selectedIndex].value;
	if(id_user>0)
		if(confirm("czy na pewno chcesz skasować wróżkę '"+expert+"'?"))
		{
			forma.action="delete_expert.php";
			forma.submit();
		
		}

}


function KickOut2(user)
	{
		
		if(user==nick)
		{
			alert("nie możesz usunąć samego/samej siebie");
			
		}
		else
		if(user!="")
		{		
			if(confirm("czy na pewno usunąć użytkownika ["+user+"] z pokoju ["+room+"]?"))
			{
				//users_iframe.location="kickout_user.php?user="+user;
				LoadElementWithAjax("users_div","kickout_user.php?user="+user,"");	
			}
		}
		else
		{
			alert("kliknij lub wpisz nazwę użytkownika");
		}
	}
	
	
	function Ban2(user)
	{
		if(user==nick)
		{
			alert("nie możesz zablokować samego/samej siebie");
			
		}
		else
		if(user!="")
		{		
			if(confirm("czy na pewno zablokować użytkownika ["+user+"] z pokoju ["+room+"]?"))
			{
				//users_iframe.location="kickout_user.php?ban=1&user="+user;
				LoadElementWithAjax("users_div","kickout_user.php?ban=1&user="+user,"");	

			}
		}
		else
		{
			alert("kliknij lub wpisz nazwę użytkownika");
		}
	}
	function DeleteRoom(room)
	{
		if(room!="")
		if(confirm("czy na pewno skasować pokój ["+room+"] ?"))
		{
			document.forma.room.value=room;
			forma.action="delete_room.php";
			forma.submit();
		}
	}
	
	function CleanDialog(room)
	{
		if(room!="")
		if(confirm("czy na pewno wyczyścić cały dialog w pokoju ["+room+"] ?"))
		{
			dialog_iframe.location="delete_dialog.php?room="+room;
			
		}
	}

