function navTo(obj) {
 var opt = document.getElementById(obj);  
 if(opt.selectedIndex === false) return false;
 
 if (opt.options[opt.selectedIndex].value == "Select a blog") {
  window.location = 'http://www.newstatesman.com/blogs';
 }
 else if (opt.options[opt.selectedIndex].value == "Select a column") {
  window.location = 'http://www.newstatesman.com/columns';
 }
 else {
  var loc = opt.options[opt.selectedIndex].value;
  window.location = loc;
 }
 return false;
}


function validate() {
	var frm = document.getElementById('pollform');
	var valid = false;
	
	for(i=0;i<frm.length;i++) {
		if (frm[i].checked) {
			frm.submit();
			valid = true;
		}
	}
	if(valid != true) {
		alert('Please select a poll option.');
		return false;
	} else {
		return true;
	}
}

function printable(url) {
	var newwindow=window.open('/print/'+url,'printable','resizable=yes,scrollbars=yes,height=450,width=600');
	if (window.focus) {newwindow.focus()}
	return false;
}

function textCounter(field, countfield, maxlimit) {
  if (field.value.length > maxlimit) // if too long...trim it!
  field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
  else 
  countfield.value = maxlimit - field.value.length;
}

function recommend_cp_comment(aResourceID){
	jQuery(document).ready(function () { 
		//jQuery('#recomendations_container_' + aResourceID).fadeOut('slow');
		jQuery.ajax({
		  type: "POST",
		  data: "resourceID="+aResourceID,
		  url: '/script/addCPResourceRecomendation.php',
		  success: function(data) {
			jQuery('#recomendations_container_' + aResourceID).fadeOut('slow');
			setTimeout(function(){
				jQuery('#recomendations_container_' + aResourceID).fadeIn('slow');
				jQuery('#recomendations_container_' + aResourceID).html(data);
			}, 1000)
			
		  }
		});
	});
}