function CheckPhoneandCode(){      
	//check if altleast one option is selected (wallpaper/ringtone/alerts)      
	if ($('#check_wallpaper:checked').val() == undefined && $('#check_ringtone:checked').val() == undefined && $('#check_alerts:checked').val() == undefined) {          
		$('#message_box').html('Please select atleast one option (Wallpaper / Ringtone / Alerts)');          
		return false;      
	}      
	//checking if valid phone number      
	if (checkInternationalPhone($('#mobile_number').val()) == false) {          
		$('#mobile_number').focus();          
		$('#message_box').html('Invalid phone number')          
		return false;      
	}      
	//check blank authorization code      
	if (jQuery.trim($('#authorization_code').val()) == '') {          
		$('#authorization_code').focus();          
		$('#message_box').html('Invalid authorization code')          
		return false;      
	}            
	//check if terms box selected      
	if ($('#check_terms:checked').val() == undefined) {          
		$('#check_terms').focus();          
		$('#message_box').html('Please agree to terms and conditions')          
		return false;      
	}            
	//send check authorization code, for that mobile number.      
	QueryAuthorizationCode($('#authorization_code').val(), $('#mobile_number').val());              
	}    
	function QueryAuthorizationCode(code, mobile_number){      
		$.post('/services/check_authorization_code', {          
			id: code,          
			mobile_number: '1' + unformatPhone(mobile_number)      
		}, 
		function(data){          
			Register(eval(data));      
		});  
	}    
	
	function Register(data){      
		//1 is when code is used on a different phone number.      
		if (data == 1) {          
			$('#message_box').html('Code has already been used on a different mobile number');          
			$('#authorization_code').focus();      
		}      
		//code does not exist in the db.      
		if (data == 2) {          
			$('#message_box').html('Invalid authorization code');          
			$('#authorization_code').focus();      
		}     
		//code has not been used or used on the same mobile number      
		if (data == 0) {                
			var mobile_number = $('#mobile_number').val();          
			//register for alerts if selected          
			if ($('#check_alerts:checked').val() != undefined) {              
				RegisterForAlerts(1795, unformatPhone(mobile_number));          
		}          
		
		//request wallpaper if selected          
		if ($('#check_wallpaper:checked').val() != undefined) {              
			RequestContent(2200, unformatPhone(mobile_number));          
		}          
		//request ringtone if selected          
		if ($('#check_ringtone:checked').val() != undefined) {              
			RequestContent(2201, unformatPhone(mobile_number));          
		}                    
		$('#phone_info_box').fadeOut('slow', function(){              
			$('#result_box').html('Thank You! You will now receive a separate text message to confirm each of your requests. Please reply YES to each message to complete your order!');              
			$('#message_box').html('');              
			$('#submit_span').fadeIn('slow');          
		});                    
		//Mark the authorization code as used for that phone number.          
		$.post('/services/mark_authorization_code_as_used/', {              
			id: $('#authorization_code').val(),              
			mobile_number: "+1" + unformatPhone($('#mobile_number').val())          
			});      
		}  
	}    
	
	$(document).ready(function(){      
		$('#phone_info_box').hide('fast');      
		$('#submit_image').bind("click", function(){          
			$('#phone_info_box').show('slow');          
			$('#submit_span').hide('slow');          
			$('#result_box').html('');      
			});      
		$('#close_phone_info').bind("click", function(){          
			$('#phone_info_box').hide('slow');          
			$('#message_box').html('');          
			$('#submit_span').fadeIn('slow');          
			$('#check_terms').attr("checked", false);      
		});      
		
		$('#submit_phone_info').bind("click", CheckPhoneandCode);      
		$('#submit_phone_info').bind("ajaxStart", function(){          
			$('#message_box').html('Verifying your validation code');      
		});      
		
		PlayFile('player', 'play', 'pause');  
	});    
	function unformatPhone(strPhone){      strPhone = remove(strPhone, "-");      strPhone = remove(strPhone, ".");      strPhone = remove(strPhone, "(");      strPhone = remove(strPhone, ")");   strPhone = remove(strPhone, " ");      return strPhone;  }    function removeAll(str, charsToRemove){      for (i = 0; i < charsToRemove.length; i++) {          str = remove(str, charsToRemove[i]);      }      return str;  }    function remove(s, t){      i = s.indexOf(t);      r = "";      if (i == -1)           return s;      r += s.substring(0, i) + remove(s.substring(i + t.length), t);      return r;  }    function PlayFile(player, play, pause){      $('#' + player).jPlayer({          ready: function(){              
		//$(this).setFile("http://www.g8wave.com/client/linkinpark/2009/2201.mp3");              
		$(this).setFile("/mp3/2201.mp3");          
		},          oggSupport: false      });      $('#' + player).jPlayerId('play', play);      $('#' + player).jPlayerId('pause', pause);  }  