
//Validate search forms for articles and discussions
function validateSearch(form){
	var val = form.keywords.value;
	if (val=="" || val=="Search Discussion Topics" || val=="Enter search phrase" || val=="Search Related Articles"){
		alert("Please enter a key word or phrases to search with");
		return false;
	}
	return true;
}


//Validate user poll input
function validatePoll(form){			
	var url = "/poll.do?poll=";
	var url1 = "/viewPollResults.do";
	var value=0;			

	for (i=0;i < 4 ; i++){
		if (form.poll[i].checked) value = form.poll[i].value;
	}
	
	if (value==0){
		alert("Please Select An Option Before Your Vote.");
		return false;
	}
	popUp(url+value);
	return false;	
}


//Validate newsletter submission
function validateNewsletter(form){
	StrObj = new String(form.email.value); 
  	if (!(StrObj.length >=5 && StrObj.match("@") && StrObj.match("."))){
   		alert("Sorry, this is not a valid email address.");
   		return false;
  	}else{
		//TODO: check channel flags here
  	}
	return true;
}


//Validate a user comment input
function validateComment(form){
	if(form.entry.value.indexOf("http://")>=0){
		alert("Warning - Do not include website URLs in your introduction. Sorry but we must be diligent in fighting SPAM!");
		return false;				
	}else if (form.entry.value.length<16 || form.entry.value.length>1024){		
		alert("Please enter a paragraph between 16-1024 chatacters in length.");
		return false;	
	}else if (!validName(form.commentBy.value)){
		alert("Please enter a valid  name.");
		return false;			
	}				
}
		
			
/* Limit text input to the specified limit amount. */
function limitText(field){
	limit = 255;
	if (field.value.length>limit){
		field.value = field.value.substr(0,limit-1);
	}
}
	
			
/* Specify status of textarea */
function entryStatus(field,statusSpan){			
	limit = 1024;
	iRemaining = limit - field.value.length;				
	document.getElementById(statusSpan).innerHTML = iRemaining + " Chars Remaining";
}

/* Used by bookmarking/sociable module */		
function shareme(preurl){
	url = preurl + location;
	location.href = url;
}		
