

function clearField(obj)
{
	if(obj.value == 'Your Full Name') obj.value = ''; 
	else if(obj.value == 'Your Email Address') obj.value = '';
	else if(obj.value == 'Your Message Here') obj.value = '';
}

function contactUs()
{
	var fullName = $('fullName').value
	var email= $('emailAddress').value;
	var message = $('message').value;
	
	if(fullName.blank() || email.blank() || message.blank())
	{
		alert('All fields are required')
		return;
	}
	if(fullName == 'Your Full Name' || email == 'Your Email Address' || message == 'Your Message Here')
	{
		alert('All fields are required')
		return;		
	}
	if (!echeck(email))
	{
		alert('Please enter a valid email address');
		return;
	}

	
	$("emailResults").update('<img src="/images/contactUsAnim.gif" style="float:left;width:25px;height:25px;margin-right:10px"><div style="float:left;margin-top:5px">Please Wait.....</div>');
	new Ajax.Request('/account/contactUs',
	{
		    method:"post",
		    requestHeaders :['Cache-Control','no-cache','Expires','0','If-Modified-Since','0'],
		    parameters: {primaryEmail:email, firstName:fullName, description:message},
		    onSuccess: function(transport)
		    {	
				setTimeout('fadeInSuccess()', 2000);
		    },
		    onFailure: function()
		    { 
		    	alert('An internal error has occurred. Please try again.');
				$('emailResults').update('');
		    }
	 });	
}

function fadeInSuccess()
{
	$('emailResults').update('Thank you. Your email has been received');
	$('cuButton').hide();	
}

function showDemoVideo()
{
	myLightWindow.activateWindow({
		href: '/ResuweDemo2.swf', 
		title: 'ResuWe Preview Video', 
		width: 700,
		height: 500,
		params: 'media'
	});
}

function jobSearch()
{
	var what = $('searchWhatText').value;
	var where = $('searchWhereText').value;
	if(what.length < 2) return;
	if(what == 'Job Titles, Keywords or Company Name') return;
	if(where == 'City, State or Zip Code (optional)') where = '';
	$('centerContentLoading').show();
	new Ajax.Request('/account/jobSearch',
	{
		    method:"post",
		    requestHeaders :['Cache-Control','no-cache','Expires','0','If-Modified-Since','0'],
		    parameters: {what:what,where:where},
		    onSuccess: function(transport)
		    {	
				var data = transport.responseText;
				$('jobSearchResults').update(data);
				$('centerContentLoading').hide();
				new Effect.Appear('jobSearchResults',{duration:.5});
		    },
		    onFailure: function()
		    { 
		    	alert('An internal error has occurred. Please try again.');
		    	$('centerContentLoading').hide();
		    }
	 });		
}



function echeck(str) 
{
	var at="@";
	var dot=".";
	var lat=str.indexOf(at);
	var lstr=str.length;
	var ldot=str.indexOf(dot);
	
	if (str.indexOf(at)==-1){
	   return false;
	}

	if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
	   return false;
	}

	if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	    return false;
	}

	 if (str.indexOf(at,(lat+1))!=-1){
	    return false;
	 }

	 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
	    return false;
	 }

	 if (str.indexOf(dot,(lat+2))==-1){
	    return false;
	 }
	
	 if (str.indexOf(" ")!=-1){
	    return false;
	 }
	 
		 return true;				
}

function openBlog()
{
	window.open ("http://www.fightunemployment.com","fu","status=0,toolbar=1,location=0,menubar=0,height=800,width=995,top=10,left=10,scrollbars=1");
}
