window.addEvent('domready',function() {
	setupTabs();
	if($$('.sociable').length){ setupSocialBookmarks(); }
	
	setup_external_links();

});

function setup_external_links(){
	$$('a').each(function(el){

		slash = hoklife = el.get('href').indexOf("/");
		hoklife = el.get('href').indexOf("hoklife.com");
		mailto = el.get('href').indexOf("mailto");
		rel = el.rel.test(/^mediabox/i);
		
		if(!rel && slash > 1 && hoklife == -1 || hoklife > 15 && mailto != 0){
			// Open in new window
			el.addEvent('click', function(){
				window.open(el,'hoklife_new')
				return false;
			});
		}
	});
}

function setupTabs(){
	$$('#tabNav a').each(function(el){
		el.addEvent('click', function(){
			activateTab(this);
		});
	});
	
	$$('#opportunities a').each(function(el){
		el.addEvent('click', function(){
			
			winHeight = 790;
			winWidth = 560;
			_POPUP_FEATURES = 'location=0,statusbar=0,menubar=0,scrollBars=1,resizable, width='+winWidth+',height='+winHeight;
			
			target = 'searchPopUp';
			var theWindow =	window.open(this, target, _POPUP_FEATURES);

			if(theWindow){
				theWindow.focus();
			}
			
			return false;
		});
	});
}

function activateTab(el){
	
	$$('#tabNav li').each(function(li){
		li.removeClass('active');
	});
	
	$$('#tabbed div').each(function(div){
		div.removeClass('active');
	});

	parentID = el.getParent().get('id');
	$(parentID).addClass('active');
	
	blockID = parentID.replace(/tab/, "block");
	$(blockID).addClass('active');

}

function setupSocialBookmarks(){
	$$('.sociable a').each(function(el){
		el.setStyle("opacity", .5);
				
		el.addEvents({
			'mouseover': function(){
				this.setStyle("opacity", 1);
			},
			'mouseout': function(){
				this.setStyle("opacity", .5);
			}
		});
	});

}