function validateTheEdgeSignUp()
{
	var subscriber_name	  = $('#the_edge_subscriber_name').val();
	var subscriber_email  = $('#the_edge_subscriber_email').val();
	var subscriber_region = $('#the_edge_IP_region').val();
	var errorMsg = '';
	
	if (subscriber_name.length <= 0 || subscriber_name == 'your name')
		errorMsg += 'Please enter your name. \n';

	if (subscriber_email.length <= 0 || subscriber_email == 'email')
	 	errorMsg += 'Please enter email. \n';

	if (errorMsg.length)
		alert(errorMsg);
	else
	{	
		$('#the_edge_signup_message').hide();
		$('#the_edge_signup_wait').show();
		$('#the_edge_subscriber_name').attr("disabled",true);
		$('#the_edge_subscriber_email').attr("disabled",true);
		$('#the_edge_submit').attr("disabled",true);
	
		theEdgeSignUp(subscriber_name, subscriber_email, subscriber_region);
	}
}

function theEdgeSignUp(subscriber_name, subscriber_email, subscriber_region)
{
	var cfArgs = new Object();
	var myArgs = new Object();
	
	cfArgs.cfc		= 'prioritycollection.cfcs.utils';
	cfArgs.method	= 'the_edge_sign_up';

	myArgs.subscriber_name	 = subscriber_name;
	myArgs.subscriber_email	 = subscriber_email;
	myArgs.subscriber_region = subscriber_region;

	cfArgs.args = myArgs;

	jsonFormatVariable = JSON.stringify(cfArgs);
	$.get(ajax_path + '/Ajax.cfc?method=gateway', {jsonargs: jsonFormatVariable}, function(data){theEdgeSignUpResult(data);}, "json");
}

function theEdgeSignUpResult(data)
{
	$('#the_edge_signup_message').show();
	$('#the_edge_signup_message').html(data.MESSAGE);
	$('#the_edge_signup_wait').hide();
	$('#the_edge_subscriber_name').attr("disabled",false);
	$('#the_edge_subscriber_email').attr("disabled",false);
	$('#the_edge_submit').attr("disabled",false);

	if (data.SUCCESS)
	{
		$('#the_edge_form')[0].reset();
		$('#the_edge_signup_message').css({'color':'green'});
	}
	else
		$('#the_edge_signup_message').css({'color':'red'});
}

function validateContactUs()
{
	var your_name				= $('#your_name').val();
	var contact_number			= $('#contact_number').val();
	var email					= $('#email').val();
	var interest_area			= 0;
	var message					= $('#message').val();

	var job_title				= $('#job_title').val();
	var company					= $('#company').val();
	var country_of_residence	= $('#country_of_residence').val();
	var IP_region				= $('#IP_region').val();

	var errorMsg	= '';
	

	if (your_name.length <= 0)
		errorMsg += 'Please enter your name. \n';
	
	if (contact_number.length <= 0 && email.length <= 0)
		errorMsg += 'Please enter either contact number or email. \n';
	else
		interest_area	= $("input[@id='interest_area']:checked").val();
	
	if (! (interest_area > 0))
		errorMsg += 'Please select primary area of interest. \n';

	if (message.length <= 0)
		errorMsg += 'Please enter your message. \n';

	if (errorMsg.length)
		alert(errorMsg);
	else
	{
		$('#contact_us_message').hide();
		$('#contact_us_wait').show();
		
		contactUs(your_name, job_title, company, contact_number, email, country_of_residence, interest_area, message, IP_region);
	}
}

function contactUs(your_name, job_title, company, contact_number, email, country_of_residence, interest_area, message, IP_region)
{
	var cfArgs = new Object();
	var myArgs = new Object();
	
	cfArgs.cfc = 'prioritycollection.cfcs.utils';
	cfArgs.method = 'contact_us';

	myArgs.name					= your_name;
	myArgs.job_title			= job_title;
	myArgs.company				= company;
	myArgs.contact_no			= contact_number;
	myArgs.email				= email;
	myArgs.country_of_residence	= country_of_residence;
	myArgs.area_of_interest		= interest_area;
	myArgs.message				= message;
	myArgs.IP_region			= IP_region;

	cfArgs.args = myArgs;

	jsonFormatVariable = JSON.stringify(cfArgs);
	$.get(ajax_path + '/Ajax.cfc?method=gateway', {jsonargs: jsonFormatVariable}, function(data){contactUsResult(data);}, "json");
}

function contactUsResult(data)
{
	$('#contact_us_message').show();
	$('#contact_us_message').html(data.MESSAGE);
	$('#contact_us_wait').hide();


	if (data.SUCCESS)
	{
		$('#contact_us_form')[0].reset();
		$('#contact_us_message').css({'color':'green'});
	}
	else
		$('#contact_us_message').css({'color':'red'});
}



