String.prototype.removeSpaces = function() {
	return this.replace(/\s/g,'');
}
function isValidEmail(str) {
		var filter = /^([a-zA-Z0-9_.-/+])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,6})$/;
		return (filter.test(str));
	}
	
	function validate_emailForm() {
		var toEmail	= document.emailForm.recEmail.value.removeSpaces(); 
		var yourEmail = document.emailForm.email.value;
		var comment	= document.emailForm.comments.value;
		var commentLength = 500;
		valid = true;

	        if ( toEmail != "" && yourEmail != "") { 
	                if (!(isValidEmail(toEmail))) {
						document.getElementById("sendInst").innerHTML = "Please enter a valid Email Address.";					
						document.emailForm.recEmail.focus();						
						valid = false;
					}
	                if (!(isValidEmail(yourEmail))) {
						document.getElementById("sendInst").innerHTML = "Please enter a valid Email Address.";					
						document.emailForm.email.focus();
						valid = false; 
					}
					if ((isValidEmail(toEmail)) && (isValidEmail(yourEmail))) {
						if (comment.length > commentLength) {
							document.getElementById("sendInst").innerHTML = "Comments should be less than 500 characters";					
							valid = false;
						} else {
									if ( document.emailForm.copy.checked == true ) {
									document.emailForm.recEmail.value=toEmail+","+yourEmail;
									}
							valid = true;
						}
						
					} else {
						valid = false;
					}
			}
			else {
					document.getElementById("sendInst").innerHTML = "Please fill out all of the fields above.";					
	                valid = false;
			}
			return valid;
	}

function addSourceCode(src) {
	var timeSrcVal = '';
	var timeSrc = document.registration.TIME_SOURCE;
	for (var i=0; i < document.registration.sub.length; i++) {
		var subVal = document.registration.sub[i];
        if (subVal.checked) {
			if (subVal.value == '1315847256')
			{
				if (src == 'emailPg')
				{
				timeSrc.value = 'ED';
				}
				else if (src == 'photosPg')
				{
				timeSrc.value = 'PD';
				}
				else if (src == "cartoonsPg")
				{
				timeSrc.value = 'CD';
				}				
				else
				{
					timeSrc.value = '';
				}				
			}
			else if (subVal.value == '1315847303')
			{
				if (src == 'emailPg')
				{
				timeSrc.value = 'EW';
				}
				else if (src == 'photosPg')
				{
				timeSrc.value = 'PW';
				}
				else if (src == 'cartoonsPg')
				{
				timeSrc.value = 'CW';
				}				
				else
				{
					timeSrc.value = '';
				}				
			}
			else if (subVal.value == '2068173695')
			{
				if (src == 'emailPg')
				{
				timeSrc.value = 'EPO';
				}
				else if (src == 'photosPg')
				{
				timeSrc.value = 'PPO';
				}
				else if (src == 'cartoonsPg')
				{
				timeSrc.value = 'CPO';
				}
				else
				{
					timeSrc.value = '';
				}
			}
			else
				{
					timeSrc.value = '';
					
				}	
	timeSrcVal = timeSrcVal + timeSrc.value + '&';				
	  }
   }
	var timeSrcLen = timeSrcVal.length;
	timeSrcVal = timeSrcVal.slice(0,timeSrcLen-1);   
	if (timeSrcVal == '')
		{
			timeSrcVal = timeSrc.value;
		}
	timeSrc.value = timeSrcVal;
}

	function validate_registerform() {
		var email 	= document.registration.email.value;
		var country 	= document.registration.country.selectedIndex;
		valid = true;
	        if (email != "" && country != 0) {
	                if (isValidEmail(email))
				{
							valid = true;
				}
				else {
						document.getElementById("errMsg").innerHTML = "Please enter a valid Email Address.";
						document.getElementById("errMsg").style.display = "block";
						valid = false;
				}
	        }
			else if (email == "" && country != 0) {
					document.getElementById("errMsg").innerHTML = "Please fill in your email.";			
					document.getElementById("errMsg").style.display = "block";					
	                valid = false;
			}
			else if (country == 0 && email != "") {
					document.getElementById("errMsg").innerHTML = "Please select your country.";			
					document.getElementById("errMsg").style.display = "block";					
	                valid = false;
			}			
			else {
					document.getElementById("errMsg").innerHTML = "Please fill in your email and select your country.";			
					document.getElementById("errMsg").style.display = "block";					
	                valid = false;
			}			
	        return valid;
	}
	

