	/**
		* @Copyright Copyright (C) 2010- SP
		* @license GNU/GPL http://www.gnu.org/copyleft/gpl.html
	**/


	/* javascript file */
	jQuery.noConflict();	
	
	/*
	*	Remove email fields and labels from form
	*/
	function removeEmail(field){
		jQuery(field).parent().remove();
	}

	/*
	*	Show email Hint in the email address fields
	*/	
	function emailHint(field){
		if(jQuery(field).val() == ""){
			jQuery(field).addClass('lightText');
			jQuery(field).val('email-address');
		}		
	}
	
	/*
	*	remove email Hint when user click on email field
	*/
	function clearEmail(field){
		if(jQuery(field).val() == "email-address"){
			jQuery(field).removeClass('lightText');			
			jQuery(field).val('');
		}
	}

	/*
	*	validate form
	*/
	function validate(f) {

	   if (document.formvalidator.isValid(f)) {

		  f.check.value='<?php echo JUtility::getToken(); ?>'; //send token
		  return true; 
	   }
	   else {
		  alert('Some values are not acceptable.  Please check the form again.');
	   }
	   return false;
	}

	/*	
	*	jquery wrapper 
	*/
	(function($){

		$(function(){
			
			/*	
			*	toggleFormLink click event handler
			*/
			$('#toggleFormLink').click(function(){

				if($('#addMoreButton').is(':visible')){
					$(this).text('Show Form');					
				}
				else{
					$(this).text('Hide');					
				}
				
				$('.hiddenDiv').slideToggle('slow');
			});		// end toggleFormLink click event hander


			/*	
			*	addMore click event handler
			*/
			$('#addMoreButton').click(function(){
				
				$('<div class="spField"><input type="text" id="txtRecipients[]" name="txtRecipients[]" value="email-address" onFocus="javascript:clearEmail(this)" onBlur="javascript:emailHint(this)" class="required lightText inputField validate-email" /><input type="button" value="X" onclick="removeEmail(this	)" class="actionButton" /></div>').appendTo('.hiddenDiv');
				
			}); 	// end addMore click event handler
			
		}); 		// 	end onload
	})(jQuery);		//	end jquery wrapper

