jQuery(function() {
	jQuery('#header .inner-nav a:first').css("background","none");
	jQuery('#header .inner-banner .nav a.big:first').css("backgroundImage","none");
	jQuery('#header .inner-banner .nav a.small:first').css("background","none");
	jQuery('#research .content-left li:last').css("background","none");
	jQuery('#footer .inner a:last').css("background","none");
	jQuery('#footer .inner a:first').css("paddingLeft","0px");
	jQuery('#office-nav li:last').css("border","none");
	
	jQuery('.doc').find('.data:odd').css('background','#f8f8f8');
	
	//build content image wrapper
	jQuery('#generic-content img').each(function() {
		var title=jQuery(this).attr('alt');
		jQuery(this).addClass('built');
		if(title) {
			var wrapper=jQuery("<div class='img'>");
			var iWidth=jQuery(this).width();
			var iHeight=jQuery(this).height();
			
			var capBgTop=iHeight-40;
			var capTop=capBgTop+5;
			
			jQuery(this).wrap(wrapper);			
			jQuery("<div class='caption-bg' style='width:"+iWidth+"px;top:"+capBgTop+"px'></div><div class='caption' style='top:"+capTop+"px;'>"+title+"</div>").insertAfter(jQuery(this));			
		}		
	});
	
	//make sure column alignment
	//var leftHeight=jQuery('.content-left').height();
	//var rightHeight=jQuery('.content-right').height();
	
	//if(leftHeight>rightHeight) 
	    //jQuery('.content-right').height(leftHeight);
		
		
	  //Stupid float for dropdown menu
	  //jQuery('.dropdown-menu .left').smartFloat({
        //  noPerRow:2,
		 // boxWidth:310
       //});
		
	//dropdown
	//make sure column alignment
	jQuery('.dropdown-menu').each(function() {
		
		
	    var leftHeight=jQuery(this).height();		
	
	     if(leftHeight>395) 
	         jQuery(this).find('.right').height(leftHeight-65);		
		
	});
	
	
	jQuery('.collapsible').slideBox({
		//firstOpen:true,
		//Trigger:"mouseover"
	});
	
	
	jQuery('#breadcrumbs').html("<a href=''>Home</a> &raquo; "+jQuery('#breadcrumbs').html());
	
	//Subscribe email
	jQuery('#subscribe-email').click(function() {
		
		jQuery(this).select();
	});
    

});

function subscribeEmail(contactEmail) {
	var email=jQuery('#subscribe-email').val();
	if(email=="" || !isEmail(email)) {		
	    jQuery('#thanks-message').hide();
	  	jQuery('#no-email-message').show();
	}
	else {
		jQuery.get("subscribe.ajax.php?email="+email+"&contact="+contactEmail,function() {
			jQuery('#no-email-message').hide();
			jQuery('#thanks-message').show();
			jQuery('#subscribe-email').empty().val("Email address");
		});
	}
}

  
function isEmail(s) {
   return (s.toString().search(/^[^@][0-9a-zA-Z\._]+@[^@][0-9a-zA-Z-]+\.[a-zA-Z]{2}/)==0);
}

function goTo(news_id,url) {
 jQuery.get("news.feed.ajax.php?news_id="+news_id+"&n="+Math.random(),function() {
    window.open(url); 
 });
}
