// JavaScript Document
function clearField(obj) {
	if (obj.defaultValue==obj.value) obj.value = '';
}

function validate_form () {
	
		// validate
    if ( document.registerForm.username.value == "" ) {
        alert ( "Please enter your username." );
		document.registerForm.username.focus();
        return false;
    }
   
   	// validate
    if ( document.registerForm.first_name.value == "" ) {
        alert ( "Please enter your first name." );
		document.registerForm.first_name.focus();
        return false;
    }
	
	// validate
	if ( document.registerForm.last_name.value == "" ) {
        alert ( "Please enter your last name." );
		document.registerForm.last_name.focus();
        return false;
    }
	
	// validate
	if ( document.registerForm.email.value == "" ) {
        alert ( "Please enter your email." );
		document.registerForm.email.focus();
        return false;
    }

	// validate
	if ( document.registerForm.zip.value == "" ) {
        alert ( "Please enter your zip." );
		document.registerForm.zip.focus();
        return false;
    }		
	
	if (true) {
		var toSubmit = confirm("do you really want to submit?");
	}
	
	return toSubmit;
	
	
}
function validate_contribute_form ( ) {
   
   	// make sure the headline has been filled in
    if ( document.headline_form.headline.value == "" ) {
        alert ( "Please enter a headline." );
		document.headline_form.headline.focus();
        return false;
    }
	
	// make sure the the link has been added
	if ( document.headline_form.link.value == "" ) {
        alert ( "Please enter a link." );
		document.headline_form.link.focus();
        return false;
    }
	
	// make sure that the link has http:// at the beginging
	var theLink = document.headline_form.link.value;
	var http = "http://";
	var firstSeven = theLink.substr(0, 7);
	
	// if it's doesn't have http:... it will add it automatically.
	if (firstSeven != http) {
		var newLink = http + theLink;
		document.headline_form.link.value = newLink;
	}
	
	// check to see if they selected a source 
	if (document.headline_form.source.selectedIndex == 0) {
		alert("Please select a source.");
		document.headline_form.source.focus();
		return false;
	}
	
	// check to see if they selected a category 
	if (document.headline_form.category.selectedIndex == 0) {
		alert("Please select a category.");
		document.headline_form.category.focus();
		return false;
	}
	
			
	
	if (true) {
		var toSubmit = confirm("do you really want to submit?");
	}
	
	return toSubmit;
	
	
}

function toggleLayerOff (whichLayer) {

	if (document.getElementById) {
		
		// the way standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"none";
		
	} else if (document.all) {
	
		// the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"none";
		
	} else if (document.layers) {
	
		// the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"none";
		
	}

}

function toggleLayer (whichLayer) {

	if (document.getElementById) {
		
		// the way standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
		
	} else if (document.all) {
	
		// the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
		
	} else if (document.layers) {
	
		// the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
		
	}

}

var maxLength; 
maxLength = 500; 
function setCharsLeft(){ 
  document.commentForm.CharsLeft.value = maxLength; 
} 
function charsLeft(){ 
  var myForm, comment, returnValue; 
  myForm = document.commentForm; 
  commentLength = myForm.comment.value.length; 
  if(commentLength > maxLength) { 
    myForm.comment.value = 
myForm.frmComment.value.substring(0,maxLength); 
    myForm.comment.blur(); 
    errorMessage = "Maximum number of allowed characters (" + 
maxLength + ") has been reached"; 
    alert(errorMessage); 
    returnValue = false; 
  } else { 
    returnValue = true; 
  } 
  myForm.CharsLeft.value = maxLength - commentLength; 
} 