// JavaScript Document



window.addEvent('domready', function() {
									 
	// make each div panel clickable (only possible to do this with javascript)
	$$('.portfolio_item_panel').each(function(el){
											  
		// get href of first link
		var anchors = el.getElements('a');
		if (anchors.length > 0) {
			// apply this link to whole element
			var href = anchors[0].href;
			
			//work out if links needs to be open in new window
			if (anchors[0].getAttribute('target') == '_blank'){
				el.addEvent('click', function(e){
					//open in new window
					window.open(href);
					e.stop();
				});	
			} else {
				el.addEvent('click', function(e){
					//open in same window 
					window.location.href = href;
					e.stop();
				});	
			}
			
			
			// javascript is working, so set cursor to pointer for the whole panel
			el.setStyle('cursor', 'pointer');
		}
		
	});
});
