// JavaScript Document
function setSub()
	{
		var mylist=document.getElementById("recip");
		document.getElementById("autosub").value=mylist.options[mylist.selectedIndex].text;
		document.getElementById("who").value=mylist.options[mylist.selectedIndex].value;
	}
	
function setFocus()
	{
		document.getElementById("recip").focus();
	}

function rot( t, u, v ) 
	{
 		return String.fromCharCode( ( ( t - u + v ) % ( v * 2 ) ) + u );
	}
function rot13( s ) 
	{
 	var b = [], c, i = s.length,
  	a = 'a'.charCodeAt(), z = a + 26,
  	A = 'A'.charCodeAt(), Z = A + 26;
 	while(i--) 
		{
  			c = s.charCodeAt( i );
  			if( c>=a && c<z ) 
				{ 
					b[i] = rot( c, a, 13 ); 
				}
  			else if( c>=A && c<Z ) 
				{ 
					b[i] = rot( c, A, 13 ); 
				}
  			else 
				{
					b[i] = s.charAt( i );
				}
		}
 		return b.join( '' );
	}

function sausage( s )
	{
		var b=[], i=1;
		while(i<s.length) 
			{
				b[i]=s.charAt( i )
				i=i+2;
			}
		return b.join('');
	}

function contact (u,s,f) 
	{
	address=rot13(u);
	url='@hawk-eye.com'; 
	addy=sausage(address)+url;
	if(s=='')
		{
			s='Website%20Inquiry';
		}
	else 
		{
			subj=s;
		}	
	if (f==0)
		{
			addy='mailto:'+addy+'?subject='+subj+'';
			return (addy);
		}
	else
		{
			return (addy);
		}
}

function emailform_onsubmit()
	{
		var returnValue = false;
		if (document.emailform.subject.value == "")
			{
				alert("Please provide a subject for your message");
				document.emailform.recip.focus();
			}
		else if(document.emailform.name.value == "")
			{
				alert("Please provide us with your name");
				document.emailform.name.focus();
			}
		else if (document.emailform.recipient.value == "")
			{
				alert("Please provide a destination for your message");
				document.emailform.recip.focus();
			}
		else if (document.emailform.email.value == "")
			{
				alert("Please provide us with your e-mail address");
				document.emailform.email.focus();
			}
		else if (document.emailform.company.value == "")
			{
				alert("Please tell us who you work for");
				document.emailform.company.focus();
			}
		else if (document.emailform.message.value == "")
			{
				alert("Please provide a message");
				document.emailform.message.focus();
			}
		else
			{
			//alert ("from:"+document.emailform.name.value+" at:"+document.emailform.company.value+", "+document.emailform.email.value+" to:"+document.emailform.recipient.value+" re:"+document.emailform.subject.value+" text:"+document.emailform.message.value);
			returnValue = true;
			}
		return returnValue;
	}
