function donate() {

    var ck = getCookie('donate');
    if(ck === null)
    {
	alert('Please enable cookies and then try again.');
    } else if(ck == 'donate_true')
    {
	//location.href = '/?view=thankyou';
    } else if(ck == 'donate_false')
    {
	document.getElementById('donate_st').submit();
    }

}
function don()
{
	
}

/*
function captfailed() {
	var ele = document.getElementById('recaptcha');
	ele.style.display = 'block';
	ele.style.top = screen.height/2 - 129/2;
	ele.style.left = screen.width/2 - 318/2;

        var ht = ele.innerHTML;
    var h = '<div align="center" style="background-color: #ffffff; color: #cc0000;">Sorry your answer was incorrect. Please try again.<br/></div>';
        h += ht;
    ele.innerHTML = '';
    ele.innerHTML = h;


	var elee = document.getElementById('blackout');
	elee.style.display = 'block';
	elee.style.width = screen.width;
	elee.style.height = document.getElementById('top_body').offsetHeight;
	elee.style.top = 0;
	elee.style.left = 0;

}


function getCookie(name)
{ var pos
  var token = name + "=";
  var tnlen = token.length;
  var cklen = document.cookie.length;
  var i = 0;
  var j;
  while (i < cklen)
  { j = i + tnlen;
    if (document.cookie.substring(i, j) == token)
    { pos = document.cookie.indexOf (";", j);
      if (pos == -1)
        pos = document.cookie.length;
      return unescape(document.cookie.substring(j, pos));
    }
    i = document.cookie.indexOf(" ", i) + 1;
    if (i == 0) break;
  } //End While
  return null;
}


  function showSendToFriend()
  {
      document.getElementById('send_to_friend').style.display = 'block';
      var elee = document.getElementById('blackout');
      elee.style.display = 'block';
      elee.style.width = screen.width;
      elee.style.height = document.getElementById('top_body').offsetHeight;
      elee.style.top = 0;
      elee.style.left = 0;
  }
  */
function stf()
{
	var em = document.getElementById('to').value;
	if(multiEmail(em) == false)
	{
		alert('Invalid Email Address, please try again.');
		return false;
	}
	//document.getElementById('stf_form').submit();
	document.getElementById('sendDiv').style.display = 'none';
	//alert("Please send your email by clicking 'OK'. Thank you. ");
	return true;
}
/*
window.onload = function()
{
	if (location.href.indexOf(?s=0) != -1)
	{
		alert('Your message was sent. Thank you.');	
	}
	else if (location.href.indexOf(?s=1) != -1)
	{
		
	}
}
*/
function stf_cancel()
{
	document.getElementById('sendDiv').style.display = 'none';
	//document.getElementById('blackout').style.display = 'none';
}


/*  window.onload = function() {

      var li = document.getElementsByTagName('a');

      for(var i = 0; i < li.length; i++)
      {
	  var hr = li[i].href;
	  
	  if((hr.indexOf('/?view') == -1) && (hr.indexOf('Recaptcha') == -1))
	  {
	      li[i].target = '_blank';
	  }
      }

  }*/

function trim(s)
{
	return rtrim(ltrim(s));
}

function ltrim(s)
{
	var l=0;
	while(l < s.length && s[l] == ' ')
	{	l++; }
	return s.substring(l, s.length);
}

function rtrim(s)
{
	var r=s.length -1;
	while(r > 0 && s[r] == ' ')
	{	r-=1;	}
	return s.substring(0, r+1);
}

function replaceAll(OldString, FindString, ReplaceString) {
	var SearchIndex = 0;
	var NewString = ""; 
	while (OldString.indexOf(FindString,SearchIndex) != -1)    {
		NewString += OldString.substring(SearchIndex,OldString.indexOf(FindString,SearchIndex));
	    NewString += ReplaceString;
	    SearchIndex = (OldString.indexOf(FindString,SearchIndex) + FindString.length);         
	}
	NewString += OldString.substring(SearchIndex,OldString.length);
	return NewString;
}

function multiEmail(email_field) {
	var email = replaceAll(email_field, ",", " ");
	email = replaceAll(email, ";", " ");
	email = replaceAll(email, "\n", " ");
	email = trim(email);
	if(email == '') {
		return false;
	}
	email = email.split(' ');
	for (var i = 0; i < email.length; i++) {
		var temp = trim(email[i]);
		if (temp != '' && !checkEmail(temp)) {
			return false;
		}
	}
	return true;
}

function checkEmail(str) {
    if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(str)){
	return (true);
    }
    return (false);
}

// prepare the form when the DOM is ready 
$(document).ready(function() { 
    var options = { 
        //target:        '#output1',   // target element(s) to be updated with server response 
        beforeSubmit:  showRequest,  // pre-submit callback 
        success:       showResponse  // post-submit callback 
 
        // other available options: 
        //url:       url         // override for form's 'action' attribute 
        //type:      type        // 'get' or 'post', override for form's 'method' attribute 
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
        //clearForm: true        // clear all form fields after successful submit 
        //resetForm: true        // reset the form after successful submit 
 
        // $.ajax options can be used here too, for example: 
        //timeout:   3000 
    }; 
 
    // bind form using 'ajaxForm' 
    $('#stf_form').ajaxForm(options); 
}); 
 
// pre-submit callback 
function showRequest(formData, jqForm, options) { 
    // formData is an array; here we use $.param to convert it to a string to display it 
    // but the form plugin does this for you automatically when it submits the data 
    var queryString = $.param(formData); 
 
    // jqForm is a jQuery object encapsulating the form element.  To access the 
    // DOM element for the form do this: 
    // var formElement = jqForm[0]; 
 
   // alert('About to submit: \n\n' + queryString); 
 
    // here we could return false to prevent the form from being submitted; 
    // returning anything other than false will allow the form submit to continue 
    return true; 
} 
 
// post-submit callback 
function showResponse(responseText, statusText)  { 
    // for normal html responses, the first argument to the success callback 
    // is the XMLHttpRequest object's responseText property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'xml' then the first argument to the success callback 
    // is the XMLHttpRequest object's responseXML property 
 
    // if the ajaxForm method was passed an Options Object with the dataType 
    // property set to 'json' then the first argument to the success callback 
    // is the json data object returned by the server 
 
    //alert('status: ' + statusText + '\n\nresponseText: \n' + responseText + '\n\nThe output div should have already been updated with the responseText.'); 
} 