// JavaScript Document
function submitIt() {

  var str = document.email_form.comments.value.toLowerCase();
  if (!document.email_form.comments.value 
    || document.email_form.comments.value == '') 
     { 
	   alert('Please type something in the email text.') 
		RecordInteraction('blank');
	   //    RecordInteraction('blank-email');
	   return; 
	 }
  if (readCookie('fail') == 'yes')
    { 
	 rimage = new Image(); rimage.src = "/cgi-bin/folj.pl?action=email&solution=fail";	
     alert('Your privileges have been revoked. Please try again later.');
	 return;
    }
/*  if (readCookie('Comments') == document.email_form.comments.value)
    { 
//		RecordInteraction('insanity');	
//     alert('You appear to have hit the send button twice.');
	   //    RecordInteraction('same-email-twice');
	 return;
    }*/
if (str.length < 250) 
{

eimage = new Image(); eimage.src = "/cgi-bin/folj.pl?action=emailbody&flex250="+document.email_form.comments.value;
    if (str.match('great')
	 || str.match('excellent')
	 || str.match('amazing')
	 || str.match('good')
	 || str.match('love')
	 || str.match('fantastic')
		)
     { 
		document.email_form.redirect.value = 'http://www.folj.com/feedback/thanks.htm';
	   	 }

	 else if (str.match('hard')
	 || str.match('difficult')
		)
     { 
		document.email_form.redirect.value = 'http://www.folj.com/feedback/hard.htm';
	 }

	 else if (str.match('email me')
	 || str.match('more')
		)
     { 
		document.email_form.redirect.value = 'http://www.folj.com/feedback/more.htm';
	 }

	 else if (str.match('easy')
		)
     { 
		document.email_form.redirect.value = 'http://www.folj.com/feedback/easy.htm';
	 }

    else if (str.match('suck')
	 || str.match('sux')
	 || str.match('rubbish')
     || str.match('wtf')
	 || str.match('shit')
		)
     { 
    rimage = new Image(); rimage.src = "/cgi-bin/folj.pl?action=email&solution=this%20sucks";
		document.email_form.redirect.value = 'http://www.folj.com/feedback/insult.htm';
      document.cookie='fail=yes';	
//	 return;
	 }
	 
/*
    else if (str.match('wtf')
		)
     { 
    rimage = new Image(); rimage.src = "/cgi-bin/folj.pl?action=email&solution=wtf";
	   alert('wtf with wtf?') 
       document.cookie='fail=yes';	
	 return;
	 }


	 else if (str.match('fuck')
	 || str.match('shit')
	 || str.match('asshole')
		)
     { 
    rimage = new Image(); rimage.src = "/cgi-bin/folj.pl?action=email&solution=swearing";
	   alert('Try again, this time without the swearing') 
	   return; 
	 }
	 */
}

//   document.cookie='Comments='+document.email_form.comments.value;	


   if (!document.email_form.email.value  || document.email_form.email.value == '') 
     { document.email_form.subject.value = 'Website: Feedback from ' + ipAddress }
		  document.email_form.drilldown.value = document.cookie; // 'http://www.folj.com/cgi-bin/query.pl?condition=ipaddress&conditional=like&table=folj&value='+ ipAddress;
		 document.email_form.recipient.value = '@';
	     document.email_form.recipient.value = 'foljer'+document.email_form.recipient.value;
         document.email_form.recipient.value = document.email_form.recipient.value+'gmail.com';

         //document.email_form.tracker.value = document.cookie;

	     document.email_form.submit();
  }

function readCookie(cookieName){
   var searchName = cookieName + '='
   var cookies = document.cookie
    var start = cookies.indexOf(cookieName)
   if (start == -1){ // cookie not found 
     return ''
     }
   start += searchName.length //start of the cookie data
   var end = cookies.indexOf(';', start)
   if (end == -1){
     end = cookies.length
     }
   return cookies.substring(start, end)
   }
 /*  
   function flashtest()
{

var flashinstalled = 0;
var flashversion = 0;
MSDetect = "false";
if (navigator.plugins && navigator.plugins.length)
{
	x = navigator.plugins["Shockwave Flash"];
	if (x)
	{
		flashinstalled = 2;
		if (x.description)
		{
			y = x.description;
			flashversion = y.charAt(y.indexOf('.')-1);
		}
	}
	else
		flashinstalled = 1;
	if (navigator.plugins["Shockwave Flash 2.0"])
	{
		flashinstalled = 2;
		flashversion = 2;
	}
}
else if (navigator.mimeTypes && navigator.mimeTypes.length)
{
	x = navigator.mimeTypes['application/x-shockwave-flash'];
	if (x && x.enabledPlugin)
		flashinstalled = 2;
	else
		flashinstalled = 1;
}
else
	MSDetect = "true";

if (flashinstalled == 1)
    {
	rimage = new Image();
	rimage.src = '/cgi-bin/folj.pl?action=flash%20detection&flex25=yes&flex250='+flashversion+randomnumber+temp+ipNumber;
	}
if (flashinstalled == 2)
    {
	rimage = new Image();
	rimage.src = '/cgi-bin/folj.pl?action=flash%20detection&flex25=yes&flex250='+flashversion+randomnumber+temp+ipNumber;
	}
else
    {
	rimage = new Image();
	rimage.src = '/cgi-bin/folj.pl?action=flash%20detection&flex25=no'+randomnumber+temp+ipNumber;
	}
}
*/
