jQuery(document).ready(function($){
	
	//Enable external links
	$('a[rel~=external]').attr('target','_blank');
	
	//Setup form field with default value
	function setFieldValue(id,value){
		$('#'+id).val(value).focus(function(){
			if( $(this).val() == value)
				$(this).val('');
		}).blur(function(){
			if( $(this).val() == '')
				$(this).val(value);
		});
	}
	
 /* // Load Geology.com news
  if ($('#geonews').length > 0) {
      $.getJSON("http://feedstitch.com/elivz/geology.json?callback=?",
          function(data) {
              var newsList = $('<ul/>').replaceAll('#geonews p');
              var regexp = /<("[^"]*"|'[^']*'|[^'">])*>/gi;
              
              // Build the list
              $.each(data.group.entries, function(i,item) {
                  var title = item.entry.content.replace(regexp,"")
                  $('<p><a href="'+item.entry.url+'" target="_blank">'+item.entry.title+'</a></p>').appendTo(newsList);
                  $('<li><a href="'+item.entry.url+'" title="'+title+'" target="_blank">'+item.entry.title+'</a>')
                  if ( i == 5 ) return false;
              });
          }
      );
  };*/
	
	//Drop downs
	$('#nav li').hoverIntent({
		over: function(){
			$(this).addClass('hover');
			$('ul:first',this).show();
		},
		out: function(){
			$(this).removeClass('hover');
			$('ul:first',this).hide();
		},
		timeout: 300
	});
	
});



/**
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($){$.fn.hoverIntent=function(f,g){var cfg={sensitivity:7,interval:100,timeout:0};cfg=$.extend(cfg,g?{over:f,out:g}:f);var cX,cY,pX,pY;var track=function(ev){cX=ev.pageX;cY=ev.pageY;};var compare=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);if((Math.abs(pX-cX)+Math.abs(pY-cY))<cfg.sensitivity){$(ob).unbind("mousemove",track);ob.hoverIntent_s=1;return cfg.over.apply(ob,[ev]);}else{pX=cX;pY=cY;ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}};var delay=function(ev,ob){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);ob.hoverIntent_s=0;return cfg.out.apply(ob,[ev]);};var handleHover=function(e){var p=(e.type=="mouseover"?e.fromElement:e.toElement)||e.relatedTarget;while(p&&p!=this){try{p=p.parentNode;}catch(e){p=this;}}if(p==this){return false;}var ev=jQuery.extend({},e);var ob=this;if(ob.hoverIntent_t){ob.hoverIntent_t=clearTimeout(ob.hoverIntent_t);}if(e.type=="mouseover"){pX=ev.pageX;pY=ev.pageY;$(ob).bind("mousemove",track);if(ob.hoverIntent_s!=1){ob.hoverIntent_t=setTimeout(function(){compare(ev,ob);},cfg.interval);}}else{$(ob).unbind("mousemove",track);if(ob.hoverIntent_s==1){ob.hoverIntent_t=setTimeout(function(){delay(ev,ob);},cfg.timeout);}}};return this.mouseover(handleHover).mouseout(handleHover);};})(jQuery);

//Loads Geology.com news
var __r2j_ = new Object();
__r2j_.c = 0;
__r2j_.n = 6;

function _r2j_scallback(o) {
  var ret = "";

  for (var i=0; i< o.entries.length && i < __r2j_.n; i++) {
    var e = o.entries[i];
    var cname = 'rss_item_' + (i % 2 == 0 ? "even" : "odd");
    ret += '<p><a class="' + cname + '" href="' + e.link + '">' + e.title + '</a>';
   
    if (__r2j_.c > 0) {
      var s = __r2j_.c == 1 ? e.summary : e.summary.substring(0, __r2j_.c);
      ret += s + '</p>';
    }
  }

  $('#geonews p').html(ret);
}
