
var bgImgWidth;
var bgImgHeight;

var bgImgProportion;

$(document).ready(function(){
	
	bgImgWidth = $("#bgBeeld").attr('width');
	bgImgHeight = $("#bgBeeld").attr('height');
	
	bgImgProportions();
	
	$(window).resize(function(){
		bgImgProportions();
	});	
	
	
	//rollover items
	$('#porfolio').hover(
		  function () {
			$(this).append($("<span class='commingSoon'></span>").fadeIn("fast"));
		  }, 
		  function () {
			$(this).find("span:last").remove();
		  }
	);
	
	$('#photography').hover(
		  function () {
			$(this).append($("<span class='commingSoon'></span>").fadeIn("fast"));
		  }, 
		  function () {
			$(this).find("span:last").remove();
		  }
	);

	// email
	
	if ($('a.email').length > 0){
	$.getScript('assets/js/jquerymailto.js',function(){ 
		$('a.email').mailto();
	});
}
	
	
	

});


function bgImgProportions(){
	var newTop = 0;
	var newLeft = 0;
	
	bgImgProportion = $(window).width()/ bgImgWidth
	
	//alert("proportion: " + bgImgProportion);
	
	if($(window).width() > bgImgWidth || $(window).height() > bgImgHeight){
		
		$("#bgBeeld").attr('width', $("#bgBeeld").width()*bgImgProportion); 
		$("#bgBeeld").attr('height', $("#bgBeeld").height()*bgImgProportion); 
		
	}else
	{
		 $("#bgBeeld").attr('width',bgImgWidth); 
		 $("#bgBeeld").attr('height',bgImgHeight); 	
	}

}

jQuery.fn.mailto = function() {
	return this.each(function(){
		var email = $(this).html().replace(/\s*\(.+\)\s*/, "@");
		$(this).before('<a href="mailto:' + email + '" rel="nofollow" title="Get in Touch, send me an e-mail">' + email + '</a>').remove();
	});
};