﻿					
function refresh_captcha(){                           
   var randomnumber=Math.floor(Math.random()*101)
   $('#captchaImg').attr('src', '../script/captchaImage.php?v='+randomnumber);
}

function sendContact(){	
	var error = '';
	var focus = '';
													
		//add user data
		var dataString = jQuery('#contact-us').serialize();
				
		//alert(dataString);
	
		jQuery.ajax({
		  type: 'POST',
		  url: '/script/action/sendContact.php',
		  data: dataString,
		  dataType: 'json',
		  success: function(data) {
	      if (data.error != ''){
	      	refresh_captcha()
	      	jQuery('#errMsg').html(data.error);
	      	jQuery('#'+data.focus).focus();
	      }else{
	      	jQuery('#form').hide();
	      	jQuery('#errMsg').hide();
	      	jQuery('#successMsg').html('Thank you for contacting us. We will get back to you as soon as possible.');
	      }
		  }
		});		
}

function sendPreorder(){	
	var error = '';
	var focus = '';
													
		//add user data
		var dataString = jQuery('#preorder').serialize();
					
		jQuery.ajax({
		  type: 'POST',
		  url: '/script/action/sendPreorder.php',
		  data: dataString,
		  dataType: 'json',
		  success: function(data) {
	      if (data.error != ''){
	      	refresh_captcha()
	      	jQuery('#errMsg').html(data.error);
	      	jQuery('#'+data.focus).focus();
	      }else{
	      	jQuery('#form').hide();
	      	jQuery('#errMsg').hide();
	      	jQuery('#successMsg').html('Thank you for your preorder. We will get back to you as soon as possible.');
	      }
		  }
		});		
}
		
