function CheckFormProfile ()
{
	var result = 1;
	if (document.getElementById('image').value)
	{
		image = document.getElementById('image').value.split (".");
		image_type = image[image.length - 1];
		if (image_type.toLowerCase() !== "gif" && image_type.toLowerCase() !== "jpg" && image_type.toLowerCase() !== "png")
		{
			document.getElementById('fregistration_CheckImage').innerHTML = "<span class=\"message_warrning\">Podporovány jsou obrázky s formátem gif, jpg, png!</span>";
			result = 0;
		}
	}
	
	if (result)
	{
		return true;
	}
	else
	{
		return false;
	}
}

function AInit ()
{
	var ajax = (window.XMLHttpRequest ? new XMLHttpRequest() : (window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : false));
	if (!ajax)
		alert ("Je nám líto, ale na Vašem počítačni není možné tuto funkci používat!");
	return ajax;
}

function ASendMessage ()
{
	SendMessage = AInit ();
	SendMessage.onreadystatechange = function ()
	{
		ASendMessageProcess (SendMessage);
	}
	
	SendMessage.open ("POST", URL_ADMIN + "user_profile/user_profile_ajax.php", true);
	SendMessage.setRequestHeader ("Content-Type", "application/x-www-form-urlencoded");
	SendMessage.send ("action=SendEmail&id=" + document.form_send_message.user_id.value + "&from=" + document.form_send_message.from.value + "&mail=" + document.form_send_message.mail.value + "&message=" + document.form_send_message.message.value);
}

function ASendMessageProcess (SendMessage)
{
	var responseText;
	if (SendMessage.readyState == 4)
	{
		if(SendMessage.status == 200 || SendMessage.status==0)
		{
			tdiscussion = new Array ();
			txtResponse = SendMessage.responseText;
			eval (txtResponse);
			if (sendmail)
			{
				document.form_send_message.reset();
				document.getElementById('div_send-message').innerHTML += "<div class=\"message_sacessful\">Vaše zpráva byla úspěšně odeslána.</div>";
			}
			else
			{
				document.getElementById('div_send-message').innerHTML += "<div class=\"message_warrning\">Při odeslání vaší zprávy došlo k chybě.</div>";
			}
		}
		else
		{
			alert("Chyba: "+ CheckTitle.status +"\n"+ CheckTitle.statusText);
		}
	}
}

