function open_invite_group_popup()
	{
		w = window.open("group_invite_popup.php", 'invite', 'width=450, height=600, scrollbars=1');
		w.focus();
		return false;
		
	}


	function move_group(fbox, tbox) 
	{
	
	

	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;

	if(tbox.options.length == 100 && tbox == document.inviteForm.invitedfriends) {
		alert("Se pot trimite maxim 100 de invitatii.");
	} else {
		for (i = 0; i < tbox.options.length; i++) {
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		
		var fLength = 0;
		var tLength = arrTbox.length;

		for(i = 0; i < fbox.options.length; i++) {
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
			} else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
			}
		}

		//arrFbox.sort();
		//arrTbox.sort();
		fbox.length = 0;
		tbox.length = 0;

		var c;

		for(c = 0; c < arrFbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrFbox[c]];
			no.text = arrFbox[c];
			fbox[c] = no;
		}

		for(c = 0; c < arrTbox.length; c++) {
			var no = new Option();
			no.value = arrLookup[arrTbox[c]];
			no.text = arrTbox[c];
			tbox[c] = no;
		}
	}
		
	}

	function addOption_group(text, value) 
	{
					
				var no = new Option();
				no.value = value;
				no.text = text;
				document.invitation.invitedfriends.options[document.invitation.invitedfriends.options.length] = no;
		
	}

	function processEvent_group()	
	{
		hiddenFriends = "";
		for(var i=0; i< document.invitation.invitedfriends.options.length; i++)	{
			if(hiddenFriends != "") {
				hiddenFriends += ",";
			}
			hiddenFriends += document.invitation.invitedfriends.options[i].value;
		}
		document.invitation.hiddenFriends.value = hiddenFriends;
		document.invitation.submit();
	}
/*
	function showFriendPic_group() 
	{
		f = document.invitation.listfriends;
		
		var numberSelected = 0;
		for (i = 0; i < f.options.length; i++) {
			if (f.options[i].selected) {
				numberSelected++;
			}
		}
		
		if (numberSelected == 1) {
			objectSelected = f.selectedIndex;
			
			document.getElementById('friendpic').src = 'groups_invite_member_pic.php?idmember=' + f.options[objectSelected].value;
		}
		
	}

*/
	//Functii ajax pentru selectarea profilului


var xmlHttpFriendPic

function FriendPicChanged_group() 
{ 

	if (xmlHttpFriendPic.readyState==4 || xmlHttpFriendPic.readyState=="complete")
	{ 
		document.getElementById("friendpic").innerHTML=xmlHttpFriendPic.responseText 
	} 
} 


function GetXmlHttpObject_group(handler)
{ 
	var objXmlHttp=null

	if (navigator.userAgent.indexOf("Opera")>=0)
	{
		alert("This example doesn't work in Opera") 
		return 
	}
	if (navigator.userAgent.indexOf("MSIE")>=0)
	{ 
		var strName="Msxml2.XMLHTTP"
		if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
		{
		strName="Microsoft.XMLHTTP"
		} 
		try
		{ 
			objXmlHttp=new ActiveXObject(strName)
			objXmlHttp.onreadystatechange=handler 
			return objXmlHttp
		} 
		catch(e)
		{ 
			alert("Error. Scripting for ActiveX might be disabled") 
			return 
		} 
	} 
	
	if (navigator.userAgent.indexOf("Mozilla")>=0)
	{
		objXmlHttp=new XMLHttpRequest()
		objXmlHttp.onload=handler
		objXmlHttp.onerror=handler 
		return objXmlHttp
	}
} 


function showFriendPic_group() 
	{
		
		f = document.invitation.listfriends;
		
		var numberSelected = 0;
		for (i = 0; i < f.options.length; i++) {
			if (f.options[i].selected) {
				numberSelected++;
			}
		}
		
		if (numberSelected == 1) 
		{
			objectSelected = f.selectedIndex;
			
			document.getElementById('friendpic').src = 'groups_invite_member_pic.php?idmember=' + f.options[objectSelected].value;

			url = 'groups_invite_member_pic.php?idmember=' + f.options[objectSelected].value;

			xmlHttpFriendPic=GetXmlHttpObject_group(FriendPicChanged_group); 
			xmlHttpFriendPic.open("GET", url , true); 
			xmlHttpFriendPic.send(null); 

		}


		return false;
		
	}


	function move_group_moderator(fbox, tbox) 
	{
	
	

	var arrFbox = new Array();
	var arrTbox = new Array();
	var arrLookup = new Array();
	var i;
	

	if(tbox.options.length >= 2 && tbox.name == "invitedfriends") {
		alert("Puteti alege maxim 2 moderatori.");
	} else {
		for (i = 0; i < tbox.options.length; i++) {
			arrLookup[tbox.options[i].text] = tbox.options[i].value;
			arrTbox[i] = tbox.options[i].text;
		}
		
		var fLength = 0;
		var tLength = arrTbox.length;

		for(i = 0; i < fbox.options.length; i++) {
			arrLookup[fbox.options[i].text] = fbox.options[i].value;
			if (fbox.options[i].selected && fbox.options[i].value != "") {
				arrTbox[tLength] = fbox.options[i].text;
				tLength++;
				
			} else {
				arrFbox[fLength] = fbox.options[i].text;
				fLength++;
			}
		}

	

		if(tLength > 2 && tbox.name == "invitedfriends")
		{
			alert("Puteti alege maxim 2 moderatori.");
		}
		else
		{

			//arrFbox.sort();
			//arrTbox.sort();
			fbox.length = 0;
			tbox.length = 0;

			var c;

			for(c = 0; c < arrFbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrFbox[c]];
				no.text = arrFbox[c];
				fbox[c] = no;
			}

			for(c = 0; c < arrTbox.length; c++) {
				var no = new Option();
				no.value = arrLookup[arrTbox[c]];
				no.text = arrTbox[c];
				tbox[c] = no;
			}
		}
	}
		
	}

