function check_invite()
{
	if (document.getElementById("name").value == "")
	{
		alert("Va rugam sa va introduceti numele");
		return false;
	}
	if (document.getElementById("friend").value == "")
	{
		alert("Va rugam sa introduceti numele prietenului");
		return false;
	}
	if (document.getElementById("email").value == "")
	{
		alert("Va rugam sa introduceti emailul prietenului");
		return false;
	}
	return true;
}


function getPageSize() 
{
	        
	     var xScroll, yScroll;
		
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		
		//alert(xScroll+' '+yScroll);
		
		var windowWidth, windowHeight;
		
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
	
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}

		return [pageWidth,pageHeight];
	}
	
function modify_title(id)
{
	var d = document.getElementById("outerdiv");
	var di = document.getElementById("innerdiv");
	var dim = getPageSize();
	d.style.width = dim[0] + 'px';
	d.style.height = dim[1] + 'px';
	
	di.style.position = "absolute";
	di.style.top = ((dim[1] / 2) - 100) + 'px';
	di.style.left = ((dim[0] / 2) - 150) + 'px';
	
	var f = document.createElement("form");
	var url = document.location.href;
	var t = url.split("/");
	f.action = t.pop();
	f.method = "post";
	
	var e = document.createElement("input");
	e.type = "text";
	e.name="title";
	e.value = document.getElementById("title"+id).innerHTML;
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "submit";
	e.value = "Salveaza";
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "mode";
	e.value = "title";
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "m_id";
	e.value = id;
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "action";
	e.value = "edit";
	
	f.appendChild(e);
	
	e = document.createElement("button");
	e.innerHTML = "Anuleaza";
	e.onclick = function (){d.innerHTML = ""; d.style.display = "none"};
	
	f.appendChild(e);
	
	di.appendChild(f);
	
	d.style.display = "block";
	
	/*var div = document.createElement("div");
	d.style.backgroundColor = "#FFFFFF";
	d.style.height = "200px";
	d.style.width = "300px";
	d.style.position = "*/
	
}

function modify_message(id)
{
	var d = document.getElementById("outerdiv");
	var di = document.getElementById("innerdiv");
	var dim = getPageSize();
	d.style.width = dim[0] + 'px';
	d.style.height = dim[1] + 'px';
	
	di.style.position = "absolute";
	di.style.top = ((dim[1] / 2) - 100) + 'px';
	di.style.left = ((dim[0] / 2) - 150) + 'px';
	
	var f = document.createElement("form");
	var url = document.location.href;
	var t = url.split("/");
	f.action = t.pop();
	f.method = "post";
	
	var e = document.createElement("textarea");
	e.name="message";
	e.value = document.getElementById("message"+id).innerHTML;
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "submit";
	e.value = "Salveaza";
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "mode";
	e.value = "message";
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "m_id";
	e.value = id;
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "action";
	e.value = "edit";
	
	f.appendChild(e);
	
	e = document.createElement("button");
	e.innerHTML = "Anuleaza";
	e.onclick = function (){d.innerHTML = ""; d.style.display = "none"};
	
	f.appendChild(e);
	
	di.appendChild(f);
	
	d.style.display = "block";
	
	/*var div = document.createElement("div");
	d.style.backgroundColor = "#FFFFFF";
	d.style.height = "200px";
	d.style.width = "300px";
	d.style.position = "*/
	
}

function delete_message(id)
{
	if (confirm("Sunteti sigur ca vreti sa stergeti mesajul?") == false)
	{
		return false;
	}
	var f = document.createElement("form");
	var url = document.location.href;
	var t = url.split("/");
	f.action = t.pop();
	f.method = "post";
	
	var e = document.createElement("input");
	e.type = "hidden";
	e.name = "mode";
	e.value = "del";
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "m_id";
	e.value = id;
	
	f.appendChild(e);
	
	e = document.createElement("input");
	e.type = "hidden";
	e.name = "action";
	e.value = "edit";
	
	f.appendChild(e);
	
	var d = document.getElementById("outerdiv");
	d.appendChild(f);
	
	f.submit();
}

function showForm()
{
	if (document.getElementById("commf").style.display == "block")
		document.getElementById("commf").style.display = "none";
	else
		document.getElementById("commf").style.display = "block";
}

function checkform()
{
	if ((document.getElementById("name")) && (document.getElementById("name").value == ""))
	{
		alert("Va rugam sa completati numele");
		return false;
	}
	if (document.getElementById("title").value == "")
	{
		alert("Va rugam sa completati titlul");
		return false;
	}
	if (document.getElementById("message").value == "")
	{
		alert("Va rugam sa completati mesajul");
		return false;
	}
	if ((document.getElementById("code")) && (document.getElementById("code").value == ""))
	{
		alert("Va rugam sa completati codul de securitate");
		return false;
	}
	return true;
}