$(document).ready(function(){
	//function for contact form dropdown
	



   //submission scripts
	//Send To Friend Form
  $('#frm_sendtofriend').submit( function(){
		//statements to validate the form	
		var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
		var txt_email = document.getElementById('txt_email');
		var txt_friends_email = document.getElementById('txt_friends_email');
		
		if (document.frm_sendtofriend.txt_name.value == "") {
			$('.name-missing').show();
		} else {$('.name-missing').hide();}
		
		if (!filter.test(txt_email.value)) {
			$('.email-missing').show();
		} else {$('.email-missing').hide();}
		
		if (document.frm_sendtofriend.txt_friends_name.value == "") {
			$('.friendsname-missing').show();
		} else {$('.friendsname-missing').hide();}
		
		if (!filter.test(txt_friends_email.value)) {
			$('.friendsemail-missing').show();
		} else {$('.friendsemail-missing').hide();}
		
		
		
		if ((document.frm_sendtofriend.txt_name.value == "") || (!filter.test(txt_email.value)) || (document.frm_sendtofriend.txt_friends_name.value == "") || (!filter.test(txt_friends_email.value))) {
			$('.msg_invalid').show();
			return false;
		} 
		if ((document.frm_sendtofriend.txt_name.value != "") && (filter.test(txt_email.value)) && (document.frm_sendtofriend.txt_friends_name.value != "") && (filter.test(txt_friends_email.value))) {
			//hide the form
			$('#frm_sendtofriend').hide();
		
			//show the loading bar
			$('.loader').css({display:'block'});
			$('.loader').append($('.bar'));
			$('.bar').css({display:'block'});
		
			//send the ajax request
			$.get('/v2/act_sendtofriend.asp', {txt_name:$('#txt_name').val(), txt_email:$('#txt_email').val(),	txt_friends_name:$('#txt_friends_name').val(), txt_friends_email:$('#txt_friends_email').val()
					},
		
		
			//return the data
			function(data){
			  //hide the graphic
			  $('.bar').css({display:'none'});
			  $('.loader').append(data);
			  $("#frm_sendtofriend").hide();
			});
			
			//waits 2000, then closes the form and fades out
			setTimeout('$(".modal").hide(); $(".loader").css({display:"none"}); $("#frm_sendtofriend").show(); document.getElementById("frm_sendtofriend").reset();', 6000);
			
			//stay on the page
			return false;
		} // end if values are present
		
		
		
  });//sendtofriend.submit function
  
  
}); //document.ready function
