
<SCRIPT language=JavaScript>
/**************************************************************************************************************/
// Create malt object based on browsertype
function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
	  xmlhttp.overrideMimeType("text/xml");
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}
/**************************************************************************************************************/
// Define global variables to be used throughout
var tableBusy = false;
var tableHttp = getHTTPObject();
/**************************************************************************************************************/

function submitTellaFriend(recipients,first_name,sendurl,message,sendtitle)
{
	if (!tableBusy)
	{
		var url = "tellafriend.php";
		document.getElementById("submitTellaFriend").innerHTML = "Processing...";

		var recipients = document.getElementById("recipients").value;
		var params = "mode=submitTellaFriend&recipients="+recipients+"&first_name="+first_name+"&sendurl="+sendurl+"&message="+message+"&sendtitle="+sendtitle;

		tableHttp.open("POST", url, true);

		//Send the proper header infomation along with the request
		tableHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		tableHttp.setRequestHeader("Content-length", params.length);
		tableHttp.setRequestHeader("Connection", "close");

		tableHttp.onreadystatechange = submitTellaFriendResponse;

		tableBusy = true;
		tableHttp.send(params);
	}
}

function submitTellaFriendResponse()
{
	if (tableHttp.readyState == 4)
	{
		if (tableHttp.responseText.indexOf('invalid') == -1)
		{
			try
			{
				var output = tableHttp.responseText;

				document.getElementById("submitTellaFriend").innerHTML = output;

				// Draw Record status and nav buttons
				tableBusy = false;

			} // end try
			catch(e)
			{
				alert("Error: " + e) ;
			} // end try catch
		} // end if response index -1
	} // end if readystate 4
} // end tableresponse function

function validateTellaFriend()
{
  var recipients= document.getElementById("recipients").value;
  var first_name = document.getElementById("first_name").value;
  var sendurl = document.getElementById("sendurl").value;
  var sendtitle = document.getElementById("sendtitle").value;
  var message = document.getElementById("message").value;

	if(recipients == "")
	{
		alert("Please mention recipients email address.");
		return;
	}

	if(first_name == "")
	{
		alert("Please mention your name.");
		return;
	}

	if(sendurl == "")
	{
		alert("Invalid Post URL. Please try again.");
		return;
	}

	submitTellaFriend(recipients,first_name,sendurl,message,sendtitle);
}
</script>
<table cellpadding=2 cellspacing=2 border=0 width=450 style='font-family:verdana;font-size:11px;'>
<tr bgcolor=#EFEFEF><td colspan='2' style="padding:5px"><span style='color:#000000'>Отправь другу ссылку: Коктейли ShapeWorks на Евровидении!</span></td>
</tr>
<tr><td colspan="2" style="padding-top:10px;background-color:#FFFFFF" >
			<table width='450' cellspacing='1' cellpadding='0' align='left' border='0' style='font-family:verdana;font-size:11px;'>
			<tr>
			<td width="450" valign="top">
			<strong><nobr>Email адресата:</nobr></strong><br />
			<textarea id="recipients" name="recipients" rows="4" cols="45" value=""></textarea>
			<br /><br />
			<strong><nobr>Твое имя</nobr>:</strong><br>
			<input type=text id="first_name" name="first_name" value="" maxlength="100" style="width :380px;">
			<br /><br />
			<strong><nobr>Твое сообщение:</nobr></strong> (не обязательно)<br>
			<textarea wrap="virtual" id="message" name="message" rows="4" cols="45">Прочти, отличная статья!</textarea>
			<br />
			<input type="hidden" id="sendurl" name="sendurl" value="/koktejli-shapeworks-na-evrovidenii">
			<input type="hidden" id="sendtitle" name="sendtitle" value="Коктейли ShapeWorks на Евровидении!">
			<input type="button" name="action_send" value="Отправить" onClick='validateTellaFriend();'>
			</td>
			</tr>
			<tr><td width="450" valign="top" id="submitTellaFriend" style='font-family:verdana;font-size:11px;font-weight:bold;'></td></tr>
			</table>
 </td></tr>
</table>