/* author: greghoole@hotmail.com */
/* Generated by AceHTML Freeware http://freeware.acehtml.com */
/* Creation date: 11/16/2004 */

function checkMailList(){
	var tOK = 1;
	var msg = "";

	if (document.maillist.email.value==""){
		msg += " Please enter your email address.";
		tOK = 0;
	}

	if (!tOK) {
		alert(msg);
		return false;
	}
	return true;
}

function validateAddComment(){
	var tOK = 1;
	var msg = "";

	if (document.commentform.name.value == ""){
		msg += " Please enter your name.\n";
		tOK = 0;
	}
	if (document.commentform.email.value == ""){
		msg += " Please enter your email address.\n";
		tOK = 0;
	}
	if (document.commentform.comment.value == ""){
		msg += " Please enter your comment.";
		tOK = 0;
	}

	if (!tOK) {
		alert(msg);
		return false;
	}
	return true;
}

function validateLogin(){
	var tOK = 1;
	var msg = "";

	if (document.login.user.value == ""){
		msg += " Please enter a username.\n";
		tOK = 0;
	}
	if (document.login.pass.value == ""){
		msg += " Please enter a password.\n";
		tOK = 0;
	}
	if (!tOK) {
		alert(msg);
		return false;
	}
	return true;
}

function validateAddArticle(){
	var tOK = 1;
	var msg = "";

	if (document.addArticle.title.value == ""){
		msg += " Please enter a title.\n";
		tOK = 0;
	}
	if (document.addArticle.article.value == ""){
		msg += " Please enter the article.\n";
		tOK = 0;
	}
	if (document.addArticle.month.value == ""){
		msg += " Please select a Month.\n";
		tOK = 0;
	}
	if (document.addArticle.day.value == ""){
		msg += " Please select a Day.\n";
		tOK = 0;
	}
	if (document.addArticle.year.value == ""){
		msg += " Please select a Year.\n";
		tOK = 0;
	}
	if (!tOK) {
		alert(msg);
		return false;
	}
	return true;
}

function validateEditArticle(){
	var tOK = 1;
	var msg = "";

	if (document.editArticle.title.value == ""){
		msg += " Please enter a title.\n";
		tOK = 0;
	}
	if (document.editArticle.article.value == ""){
		msg += " Please enter the article.\n";
		tOK = 0;
	}
	if (document.editArticle.month.value == ""){
		msg += " Please select a Month.\n";
		tOK = 0;
	}
	if (document.editArticle.day.value == ""){
		msg += " Please select a Day.\n";
		tOK = 0;
	}
	if (document.editArticle.year.value == ""){
		msg += " Please select a Year.\n";
		tOK = 0;
	}
	if (!tOK) {
		alert(msg);
		return false;
	}
	return true;
}

function viewPollResults(id){
	var t = (screen.height/2)-150;
	var l = (screen.width/2)-300;
	var props = 'width=600,height=300,top='+t+',left='+l+',scrollbars=1,toolbar=0,menubar=0';
	window.open('viewPollComments.php?id='+id, 'pollresults', props);
}

function viewPollResultsA(id){
	var t = (screen.height/2)-150;
	var l = (screen.width/2)-300;
	var props = 'width=600,height=300,top='+t+',left='+l+',scrollbars=1,toolbar=0,menubar=0';
	window.open('../viewPollResults.php?id='+id, 'pollresults', props);
}

function addPollComment(id){
	var t = (screen.height/2)-200;
	var l = (screen.width/2)-250;
	var props = 'width=500,height=400,top='+t+',left='+l+',scrollbars=1,toolbar=0,menubar=0';
	window.open('addPollComment.php?id='+id, 'pollcomment', props);
}

function validateAddPoll(){
	var tOK = 1;
	var msg = "";
	if(document.addPoll.question.value == ""){
		tOK = 0;
		msg += " - Please enter a poll question\n";
	}
	if(document.addPoll.choices.value == ""){
		tOK = 0;
		msg += " - Please select a number of choices\n";
	}
	if(!tOK){
		alert(msg);
		return false;
	}
	return true;
}

function validateChoices(n){
	var tOK = 1;
	var msg = "";

	for(i=0; i<n; i++){
		var t = "document.createPoll.choice"+i+".value";
		if(eval(t) == ""){
			tOK = 0;
			msg += " - Enter a value for choice " + (i+1) + "\n";
		}
	}
	if(!tOK){
		alert(msg);
		return false;
	}
	return true;
}

function editCat(id){
	var t = (screen.height/2)-100;
	var l = (screen.width/2)-250;
	var props = 'width=500,height=200,top='+t+',left='+l+',scrollbars=0,toolbar=0,menubar=0';
	window.open('editCat.php?id='+id, 'editcat', props);
}

function editLink(id){
	var t = (screen.height/2)-100;
	var l = (screen.width/2)-250;
	var props = 'width=500,height=200,top='+t+',left='+l+',scrollbars=0,toolbar=0,menubar=0';
	window.open('editLink.php?id='+id, 'editlink', props);
}

function addLink(id){
	var t = (screen.height/2)-125;
	var l = (screen.width/2)-250;
	var props = 'width=500,height=250,top='+t+',left='+l+',scrollbars=0,toolbar=0,menubar=0';
	window.open('addLink.php', 'addlink', props);
}

function changeImage(id){
	var t = (screen.height/2)-100;
	var l = (screen.width/2)-250;
	var props = 'width=500,height=200,top='+t+',left='+l+',scrollbars=0,toolbar=0,menubar=0';
	window.open('changeImage.php?id='+id, 'changeImage', props);
}

function validateUnsubscribe(){
	var tOK = 1;
	var msg = "";
	if(document.unsubscribe.email.value == ""){
		tOK = 0;
		msg = " Please enter your Email Address";
	}
	if(!tOK){
		alert(msg);
		return false;
	}
	return true;
}


function editArticle(id){
	var t = (screen.height/2)-300;
	var l = (screen.width/2)-365;
	var props = "width=730,height=600,top="+t+",left="+l+",scrollbars=1,toolbar=0,menubar=0";	
	window.open('editArticle.php?id='+id, '_blank', props);
	
}

function previewArticle(id){
	var t = (screen.height/2)-300;
	var l = (screen.width/2)-365;
	var props = "width=730,height=600,top="+t+",left="+l+",scrollbars=1,toolbar=0,menubar=0";	
	window.open('previewArticle.php?id='+id, '_blank', props);
	
}

function addArticle(){
	var t = (screen.height/2)-300;
	var l = (screen.width/2)-365;
	var props = "width=730,height=600,top="+t+",left="+l+",scrollbars=1,toolbar=0,menubar=0";	
	window.open('addArticle.php', '_blank', props);
	
}

function openSendSR(){
	var t = (screen.height/2)-75;
	var l = (screen.width/2)-365;
	var props = "width=730,height=150,top="+t+",left="+l+",scrollbars=1,toolbar=0,menubar=0";	
	window.open('sendSR.php', '_blank', props);
}


// JVC additions

function SR_setFirstCaps( elmnt )
{
  var input  = $(elmnt).val();
  var output = '';
  var words  = input.split( /\s+/ );

  for ( i=0; i<words.length; i++ ) {

    var word = words[i];

    if ( word.match( /^is|are|was|were$/ ) ) {
      // Uppercase first char of certain common verb forms.
      words[i] = SR_strToUpper( word );
    } else if ( word.length > 3 ) {
      // Uppercase first char of words longer than three chars.
      words[i] = SR_strToUpper( word );
    } else if ( i == words.length ) {
      // Uppercase first char of last word.
      words[i] = SR_strToUpper( word );
    }

  }

  output = words.join( ' ' );

  $(elmnt).val(output);
}

function SR_setAllCaps( elmnt )
{
  var input  = $(elmnt).val();

  $(elmnt).val( input.toUpperCase() );
}

function SR_strToUpper( str )
{
  return str.charAt(0).toUpperCase() + str.substr(1);
}

