//############################
// preload the nav images
//############################
if (document.images)
{
	preload_image_object = new Image();
	image_url = new Array();

	image_url[0] = "/images/home-over.gif";
	image_url[1] = "/images/pays2share-over.gif";
	image_url[2] = "/images/stores-over.gif";
	image_url[3] = "/images/submit-coupon-over.gif";
	image_url[4] = "/images/blog-over.gif";
	image_url[5] = "/images/works-over.gif";

	var i = 0;
	for(i=0; i<=5; i++) 
		preload_image_object.src = image_url[i];
}

//############################
// blur / focus on main search field
//############################
function search_toggle(field, type)
{
	if (type == 'on')
	{
		//alert( field.value );
		//if (field.value == 'e.g. target.com')
		//{
			field.value = '';
			field.setStyle({color:'#676666'});
		//}
	}
	
	else
	{
		if (field.value == '')
		{
			field.value = 'e.g. target.com';
			field.setStyle({color:''});
		}
	}
}

//############################
// handle the facebook icon click event
//############################
function fbs_click(coupon_id, title)
{
	u='http://www.couponchief.com/coupons/details/'+coupon_id;
	t=title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

//############################
// VALIDATE "CONTACT US" FORM
//############################
function submitContactUs()
{
	if( $F('full_name') == '' )
	{
		alert("Please enter your name.");
		$('full_name').focus();
		return false;
	}
	else if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else if( $F('comment') == '' )
	{
		alert("Please enter your comment.");
		$('comment').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_newsletter_registration').value = "Processing...";
		
		xajax_process_email(xajax.getFormValues('contact_form'));
	}
}

//############################
// VALIDATE "ADVERTISE" FORM
//############################
function submitAdvertise()
{
	if( $F('full_name') == '' )
	{
		alert("Please enter your name.");
		$('full_name').focus();
		return false;
	}
	else if( !CheckPhoneNumber($F('phone')) )
	{
		$('phone').focus();
		return false;
	}
	else if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else if( $F('objectives') == '' )
	{
		alert("Please enter your goals/objectives.");
		$('objectives').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_newsletter_registration').value = "Processing...";
		
		xajax_process_email(xajax.getFormValues('advertise_form'));
	}
}

//############################
// VALIDATE COUPON COMMENT FORM
//############################
function submitComment(coupon_id)
{
	if( $F('tb_comment_'+coupon_id).strip() == '' )
	{
		alert( "Please fill in your comment." );
		$('tb_comment_'+coupon_id).focus();
		return false;
	}
	else
	{
		// cleanse the comment of html tags
		//var orig_comment = $F('tb_comment_'+coupon_id);
		var sanitized_comment = stripHTML($F('tb_comment_'+coupon_id));
		$('tb_comment_'+coupon_id).value = sanitized_comment;
		
		//alert( orig_comment +", "+ sanitized_comment );
		//return false;
		
		//$('btn_submit_'+coupon_id).disabled = true;
		xajax_comment(xajax.getFormValues('comment_form_'+coupon_id));
	}
	
	return false;
}

//############################
// VALIDATE "LOGIN" FORM
//############################
function submitLogin()
{
	if( $F('username') == '' )
	{
		alert("Please enter your username.");
		$('username').focus();
		return false;
	}
	else if( $F('password') == '' )
	{
		alert("Please enter your password.");
		$('password').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('login_form'));
	}
}

//############################
// VALIDATE "LOGIN->OpenID" FORM
//############################
function submitOpenID()
{
	if( $F('openid_url') == '' )
	{
		alert("Please enter your OpenID.");
		$('openid_url').focus();
		return false;
	}
	else
	{
		// strip out 'http://'
		val = $F('openid_url');
		$('openid_url').value = val.replace("http://", "").replace("/", "");
	}
}

//############################
// VALIDATE "FORGOT USERNAME/PASSWORD" FORM
//############################
function submitForgotForm()
{
	if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('forgot_password_form'));
	}
}

//############################
// VALIDATE "SIGN UP" FORM
//############################
function submitSignUp()
{
	 // check for letters, numbers and underscores
	var legalUsernameChars = /^[_0-9a-zA-Zs]+$/;

	if( $F('fname') == '' )
	{
		alert("Please enter your first name.");
		$('fname').focus();
		return false;
	}
	else if( $F('lname') == '' )
	{
		alert("Please enter your last name.");
		$('lname').focus();
		return false;
	}
	else if( $F('username') == '' )
	{
		alert("Please enter your username.");
		$('username').focus();
		return false;
	}
	else if( !legalUsernameChars.test($F('username')) )
	{
		alert("Your username can consist of only letters, numbers and underscores.");
		$('username').focus();
		return false;
	}
	else if( !valid_username )
	{
		alert("You must enter an available username.");
		$('username').focus();
		return false;
	}
	else if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	/*
	else if( !CheckZip($F('zip'), 'zip code') )
	{
		$('zip').focus();
		return false;
	}
	*/
	else if( $F('pass') == '' )
	{
		alert("Please enter your password.");
		$('pass').focus();
		return false;
	}
	else if( $F('pass2') == '' )
	{
		alert("Please re-enter your password.");
		$('pass2').focus();
		return false;
	}
	else if( $F('pass') != $F('pass2') )
	{
		alert("The two passwords you entered do not match. Please try again.");
		$('pass').value = '';
		$('pass2').value = '';
		$('pass').focus();
		return false;
	}
	else
	{
		if( $F('openid') != "" )
		{
			// strip out 'http://'
			val = $F('openid');
			$('openid').value = val.replace("http://", "").replace("/", "");
		}

		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('signup_form'));
	}
}

function submitMerchantSignUp()
{
	 // check for letters, numbers and underscores
	var legalUsernameChars = /^[_0-9a-zA-Zs]+$/;

	if( $F('tb_store') == 'example.com' )
	{
		alert("Please enter a domain.");
		$('tb_store').focus();
		return false;
	}
	else if( $F('tb_store') == '' )
	{
		alert("Please enter a domain.");
		$('tb_store').focus();
		return false;
	}
	else if( $('fname') && $F('fname') == '' )
	{alert($F('tb_store'));
		alert("Please enter your first name.");
		$('fname').focus();
		return false;
	}
	else if( $('lname') && $F('lname') == '' )
	{
		alert("Please enter your last name.");
		$('lname').focus();
		return false;
	}
	else if( $('username') && $F('username') == '' )
	{
		alert("Please enter your username.");
		$('username').focus();
		return false;
	}
	else if( $('username') && !legalUsernameChars.test($F('username')) )
	{
		alert("Your username can consist of only letters, numbers and underscores.");
		$('username').focus();
		return false;
	}
	else if( $('username') && !valid_username )
	{
		alert("You must enter an available username.");
		$('username').focus();
		return false;
	}
	else if( $('email') && !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else if( $('email') && !valid_email )
	{
		alert("The email address you entered is already in use. Either enter another email address or log in.");
		$('email').focus();
		return false;
	}
	else if( $('pass') && $F('pass') == '' )
	{
		alert("Please enter your password.");
		$('pass').focus();
		return false;
	}
	else if( $('pass2') && $F('pass2') == '' )
	{
		alert("Please re-enter your password.");
		$('pass2').focus();
		return false;
	}
	else if( $('pass') && $F('pass') != $F('pass2') )
	{
		alert("The two passwords you entered do not match. Please try again.");
		$('pass').value = '';
		$('pass2').value = '';
		$('pass').focus();
		return false;
	}
	else if( !$('terms').checked )
	{
		alert("Please agree to the terms of use.");
		$('terms').focus();
		return false;
	}
	else
	{

		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('signup_form'));
	}
}

//############################
// VALIDATE "PAYS2SHARE SIGN UP" FORM
//############################
function submitPays2ShareSignUp()
{
	 // check for letters, numbers and underscores
	var legalUsernameChars = /^[_0-9a-zA-Zs]+$/;
	var legalZipChars = /(^\d{5}$)|(^\d{5}-\d{4}$)/;

	if( $('fname') && $F('fname') == '' )
	{
		alert("Please enter your first name.");
		$('fname').focus();
		return false;
	}
	else if( $('lname') && $F('lname') == '' )
	{
		alert("Please enter your last name.");
		$('lname').focus();
		return false;
	}
	else if( $('username') && $F('username') == '' )
	{
		alert("Please enter your username.");
		$('username').focus();
		return false;
	}
	else if( $('username') && !legalUsernameChars.test($F('username')) )
	{
		alert("Your username can consist of only letters, numbers and underscores.");
		$('username').focus();
		return false;
	}
	else if( $('username') && !valid_username )
	{
		alert("You must enter an available username.");
		$('username').focus();
		return false;
	}
	else if( $('email') && !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else if( $('email') && !valid_email )
	{
		alert("The email address you entered is already in use. Either enter another email address or log in.");
		$('email').focus();
		return false;
	}
	else if( $('pass') && $F('pass') == '' )
	{
		alert("Please enter your password.");
		$('pass').focus();
		return false;
	}
	else if( $('pass2') && $F('pass2') == '' )
	{
		alert("Please re-enter your password.");
		$('pass2').focus();
		return false;
	}
	else if( $('pass') && $F('pass') != $F('pass2') )
	{
		alert("The two passwords you entered do not match. Please try again.");
		$('pass').value = '';
		$('pass2').value = '';
		$('pass').focus();
		return false;
	}
	else if( !$('payment_check').checked && !$('payment_paypal').checked )
	{
		alert("Please select a default payment method.");
		$('payment_check').focus();
		return false;
	}
	else if( !$('address1').disabled && $F('address1') == '' )
	{
		alert("Please enter your address.");
		$('address1').focus();
		return false;
	}
	else if( !$('city').disabled && $F('city') == '' )
	{
		alert("Please enter your city.");
		$('city').focus();
		return false;
	}
	else if( !$('state').disabled && $F('state') == '' )
	{
		alert("Please select your state.");
		$('state').focus();
		return false;
	}
	else if( !$('zip').disabled && $F('zip') == "" )
	{
		alert( "Please enter your zip code" );
		$('zip').focus();
		return false;
	}
	else if( !$('zip').disabled && !legalZipChars.test($F('zip')) )
	{
		alert( "Please enter your correct zip code" );
		$('zip').focus();
		return false;
	}
	/*
	else if( $F('social1') == '' || $F('social2') == '' || $F('social3') == '' )
	{
		alert("Please enter your social security number.");
		$('social1').focus();
		return false;
	}
	else if( $F('social1').length != 3 || $F('social2').length != 2 || $F('social3').length != 4 )
	{
		alert("Please enter your full social security number.");
		$('social1').focus();
		return false;
	}
	else if( $F('birth_month') == "" || $F('birth_day') == "" || $F('birth_year') == "" )
	{
		alert( "Please select your birthdate" );
		$('birth_month').focus();
		return false;
	}
	*/
	else if( !$('paypal').disabled && $F('paypal') == "" )
	{
		alert( "Please enter your PayPal Email" );
		$('paypal').focus();
		return false;
	}
	else if( !$('terms').checked )
	{
		alert("Please agree to the terms of use.");
		$('terms').focus();
		return false;
	}
	else
	{
		//$('btn_submit').disabled = true;
		xajax_process(xajax.getFormValues('signup_form'));
	}
}

// process the small, "Sign up" form on the myprofile settings page
function submitSettingsSignUp()
{
	if( $('updates') && !$('updates').checked && !$('newsletter').checked && !$('cancel').checked )
	{
		alert("Please select one or more options and click 'Submit' again.");
		$('terms').focus();
		return false;
	}
	else
	{
		//$('btn_submit2').disabled = true;
		xajax_sign_up(xajax.getFormValues('profile_signup_form'));
	}
}

//############################
// CHECK SIGN UP FORM USERNAME FIELD
//############################
var email = '';
var valid_email = false;
function checkEmailAvailability(val)
{
	if( val != email && val.strip() != '' )
	{
		$('email_check').style.color = 'yellow';
		//$('email_check').innerHTML = "Processing...";
		xajax_check_email(val);
	}

	email = val;
}

//############################
// CHECK SIGN UP FORM USERNAME FIELD
//############################
var username = '';
var valid_username = false;
function checkUsername(val)
{
	if( val != username && val.strip() != '' ) //&& $('username_check').innerHTML != "Username available!")
	{
		$('username_check').style.color = 'yellow';
		//$('username_check').innerHTML = "Processing...";
		xajax_check_username(val);
	}

	username = val;
}

function checkNewsletterRegistration()
{
	if( !CheckEmail($F('tb_newsletter_email'), 'email address') )
	{
		$('tb_newsletter_email').focus();
		return false;
	}
	else
	{
		$('btn_newsletter_registration').disabled = true;		
		xajax_newsletter_signup($F('tb_newsletter_email'));
	}
}

// Shows the user photo upload when the user clicks the edit button.
function showProfilePhotoForm()
{
	//$('user_photo_link').hide();
	//$('user_photo_title').update('Edit user photo');
	
	var temp_height = $$('div.profile').first().getHeight() - 20;
	
	$$('div.profile').first().setStyle({'height':temp_height + 'px'});
		
	$('err_msg').update(' ');
	
	var new_field = new Element('input', { type:'file', id:'profile_photo', name:'profile_photo' });
	var temp_div = $('profile_photo').up();
	temp_div.update(' ');
	temp_div.update(new_field);
	
	$('edit_form').show();	
	
	return false;
}

// used on /myprofile to manage the submission of the users' photo
function submitProfilePhoto()
{
	if( $F('profile_photo') == '' )
	{
		alert("Please select an image to upload.");
		$('profile_photo').focus();

		return false;
	}
	else if( $F('profile_photo').toLowerCase().indexOf('jpg') == -1 && $F('profile_photo').toLowerCase().indexOf('gif') == -1 && $F('profile_photo').toLowerCase().indexOf('png') == -1)
	{
		alert("Please select either a JPG, GIF or PNG image to upload.");
		$('profile_photo').focus();

		return false;
	}
	else
	{
		//$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";

		$('form_profile_photo').target = 'upload_target';
	}
}

// update the user's profile information
function submitProfile()
{
	var legalZipChars = /(^\d{5}$)|(^\d{5}-\d{4}$)/;
	
	if( $F('fname') == '' )
	{
		alert("Please enter your first name.");
		$('fname').focus();
		return false;
	}
	else if( $F('lname') == '' )
	{
		alert("Please enter your last name.");
		$('lname').focus();
		return false;
	}
	else if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else if( $('address1') && !$('address1').disabled && $F('address1') == "" )
	{
		alert('Please enter your address');
		$('address1').focus();
		return false;
	}
	else if( $('city') && !$('city').disabled && $F('city') == "" )
	{
		alert('Please enter your city');
		$('city').focus();
		return false;
	}
	else if( $('state') && !$('state').disabled && $F('state') == "" )
	{
		alert('Please select your state');
		$('state').focus();
		return false;
	}
	else if( $('zip') && !$('zip').disabled && $F('zip') == "" )
	{
		alert( "Please enter your zip code" );
		$('zip').focus();
		return false;
	}
	else if( $('zip') && !$('zip').disabled && !legalZipChars.test($F('zip')) )
	{
		alert( "Please enter your correct zip code" );
		$('zip').focus();
		return false;
	}
	/*
	else if( $('social1') && ($F('social1') == '' || $F('social2') == '' || $F('social3') == '') )
	{
		alert("Please enter your social security number.");
		$('social1').focus();
		return false;
	}
	else if( $('social1') && ($F('social1').length != 3 || $F('social2').length != 2 || $F('social3').length != 4) )
	{
		alert("Please enter your full social security number.");
		$('social1').focus();
		return false;
	}
	else if( $('birth_month') && ($F('birth_month') == "" || $F('birth_day') == "" || $F('birth_year') == "") )
	{
		alert( "Please select your birthdate" );
		$('birth_month').focus();
		return false;
	}
	*/
	else if( $('paypal') && !$('paypal').disabled && $F('paypal') == "" )
	{
		alert( "Please enter your PayPal Email" );
		$('paypal').focus();
		return false;
	}
	else if( $F('pass') == '' && $F('new_password') != '' )
	{
		alert("Please enter your current password.");
		$('pass').focus();
		return false;
	}
	else if( $F('new_password') != '' && $F('new_password1') == '' )
	{
		alert("Please verify your new password.");
		$('new_password1').focus();
		return false;
	}
	else if( $F('new_password') != $F('new_password1') )
	{
		alert("The two passwords you entered do not match. Please try again.");
		$('new_password').value = '';
		$('new_password1').value = '';
		$('new_password').focus();
		return false;
	}
	else
	{
		if( $F('openid') != "" )
		{
			// strip out 'http://'
			val = $F('openid');
			$('openid').value = val.replace("http://", "").replace("/", "");
		}

		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_update(xajax.getFormValues('profile_form'));
	}
}

//################################
// VALIDATE "SEND TO FRIEND" FORM
//################################
function submitSendToFriend()
{
	if( $F('tb_name') == '' )
	{
		alert("Please enter your name.");
		$('tb_name').focus();
		return false;
	}
	else if( !CheckEmail($F('tb_email'), 'email address') )
	{
		$('tb_email').focus();
		return false;
	}
	else if( $F('tb_friend_name') == '' )
	{
		alert("Please enter your friend's name.");
		$('tb_friend_name').focus();
		return false;
	}
	else if( !CheckEmail($F('tb_friend_email'), 'friend\'s email address') )
	{
		$('tb_friend_email').focus();
		return false;
	}
	else if( $F('tb_note') == '' )
	{
		alert("Please enter a note.");
		$('tb_note').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('sendtofriend_form'));
	}
}

//################################
// SUBMIT A COUPON
//################################
// strip any superfluous characters from the provided store value
function cleanseStore()
{
	// pull the value of the field and trim it
	var val = $F('tb_store').strip();

	// check for http{s}://
	var re = new RegExp('^(http(s?)):\/?\/?');
	if (val.match(re))
	{
		$('tb_store').value = val.replace(re, '');
		val = $F('tb_store');
	}

	// check for www.
	re = new RegExp('w{3}\.');
	if (val.match(re))
		$('tb_store').value = val.replace(re, '');

	// check the TLD/SLD
	var tld = val.split(".");
	re = new RegExp('[a-z]{2,6}$');
	if (tld.length == 1 || !tld[tld.length-1].match(re))
	{
		alert("Please enter valid store domain name, e.g. 'example.com'.");
		$('tb_store').value = 'example.com';
	}
	
	// strip out anything after the TLD/SLD
	$('tb_store').value = $F('tb_store').replace(new RegExp(/\/(.*)/), '');

	// if we're left with an empty field, fill it with the default text
	if( $F('tb_store') == '' )
		$('tb_store').value = 'example.com';
	else
	{
		// the user has entered a valid domain so check that it accepts coupons
		// allow_user_contributions = 'yes'
		if( $F('tb_store') != 'example.com' )
			xajax_check_accepts_coupons($F('tb_store'));
	}
}
// For the merchant portal signup page
function cleanseMerchantSignupStore()
{
	// pull the value of the field and trim it
	var val = $F('tb_store').strip();

	// check for http{s}://
	var re = new RegExp('^(http(s?)):\/?\/?');
	if (val.match(re))
	{
		$('tb_store').value = val.replace(re, '');
		val = $F('tb_store');
	}

	// check for www.
	re = new RegExp('w{3}\.');
	if (val.match(re))
		$('tb_store').value = val.replace(re, '');

	// check the TLD/SLD
	var tld = val.split(".");
	re = new RegExp('[a-z]{2,6}$');
	if (tld.length == 1 || !tld[tld.length-1].match(re))
	{
		alert("Please enter valid store domain name, e.g. 'example.com'.");
		$('tb_store').value = 'example.com';
	}
	
	// strip out anything after the TLD/SLD
	$('tb_store').value = $F('tb_store').replace(new RegExp(/\/(.*)/), '');

	// if we're left with an empty field, fill it with the default text
	if( $F('tb_store') == '' )
		$('tb_store').value = 'example.com';
	else
	{
	}
}

// validate "Submit a coupon" form
function submitCoupon()
{
	if( $F('tb_store') == '' || $F('tb_store') == 'example.com' )
	{
		alert("Please enter the Store (example.com).");
		$('tb_store').focus();
		return false;
	}
	else if( $F('tb_discount').length < 5 )
	{
		alert("Please enter a Discount of 5 characters or more.");
		$('tb_discount').focus();
		return false;
	}
	else if( !CheckDate($F('tb_expiration')) )
	{
		$('tb_expiration').focus();
		return false;
	}
	else if( $F('tb_code').strip().length == 0 )
	{
		alert("Please enter a Coupon Code.");
		$('tb_code').focus();
		return false;
	}
	else
	{
		//$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('coupon_form'));
	}

}

//################################
// FLAG A COMMENT
//################################
function submitCommentFlag()
{
	if( $F('tb_notes') == '' )
	{
		alert("Please enter your reason for flagging the chosen comment");
		$('tb_notes').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		//$('btn_submit').value = "Processing...";
		xajax_process(xajax.getFormValues('flag_form'));
	}
}

//################################
// UNSUBSCRIBE A USER
//################################
function submitUnsubscribe()
{
	if( !CheckEmail($F('email'), 'email address') )
	{
		$('email').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		xajax_process(xajax.getFormValues('unsubscribe_form'));
	}
}


//################################
// MYPROFILE -> PAYS-2-SHARE -> DISPUTE TRANSACTION
//################################
function submitDisputeTransaction()
{
	if( $F('store_name') == "" )
	{
		alert("Please enter a store name");
		$('store_name').focus();
		return false;
	}
	else if( $F('coupon_code') == "" )
	{
		alert("Please enter a coupon code");
		$('coupon_code').focus();
		return false;
	}
	else if( $F('date') == "" )
	{
		alert("Please select a transaction date");
		$('date').focus();
		return false;
	}
	else if( $F('time') == "" )
	{
		alert("Please select a transaction time");
		$('time').focus();
		return false;
	}
	else if( $F('amount') == "" )
	{
		alert("Please enter a transaction amount");
		$('amount').focus();
		return false;
	}
	else if( $F('reason') == "" )
	{
		alert("Please enter your reason for this dispute");
		$('reason').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		xajax_process_dispute(xajax.getFormValues('dispute_form'));
	}
}

//################################
// MYPROFILE -> PAYS-2-SHARE -> DISPUTE PAYMENT
//################################
function submitDisputePayment()
{
	if( $F('date') == "" )
	{
		alert("Please select a transaction date");
		$('date').focus();
		return false;
	}
	else if( $F('amount') == "" )
	{
		alert("Please enter a transaction amount");
		$('amount').focus();
		return false;
	}
	else if( $F('method') == "" )
	{
		alert("Please select a payment method");
		$('method').focus();
		return false;
	}
	else if( $F('reason') == "" )
	{
		alert("Please enter your reason for this investigation");
		$('reason').focus();
		return false;
	}
	else
	{
		$('btn_submit').disabled = true;
		xajax_process_dispute(xajax.getFormValues('dispute_form'));
	}
}

//################################
// MYPROFILE -> PAYS-2-SHARE -> REQUEST PAYMENT
//################################
function submitRequestPayment()
{
	if( $F('amount') == "" )
	{
		alert("Please enter the amount requested");
		$('amount').focus();
		return false;
	}
	else
	{
		//$('btn_submit').disabled = true;
		xajax_process_request_payment(xajax.getFormValues('request_form'));
	}
}

//################################
// MYPROFILE -> PAYS-2-SHARE -> ACCOUNT ACTIVITY / PAYMENTS
//################################
function checkDateRange()
{
	if( $('start_date') && $F('start_date') == "" )
	{
		alert("Please select the start date");
		$('start_date').focus();
		return false;
	}
	else if( $('end_date') && $F('end_date') == "" )
	{
		alert("Please select the end date");
		$('end_date').focus();
		return false;
	}
	
	if( $('start_month') && $F('start_month') == "" )
	{
		alert("Please select the start month");
		$('start_month').focus();
		return false;
	}
	else if( $('start_year') && $F('start_year') == "" )
	{
		alert("Please select the start year");
		$('start_year').focus();
		return false;
	}
	else if( $('end_month') && $F('end_month') == "" )
	{
		alert("Please select the end month");
		$('end_month').focus();
		return false;
	}
	else if( $('end_year') && $F('end_year') == "" )
	{
		alert("Please select the end year");
		$('end_year').focus();
		return false;
	}
	
	$('date_range').submit()
}

//################################
// CONTESTS
//################################
function checkContestForm()
{
	if( $F('from_name') == "" )
	{
		alert("Please enter your name");
		$('from_name').focus();
		return false;
	}

	return true;
}
