$(document).ready(function(){	
	showHideContactForm();
	setExpander();
	setMinHeight();	
	externalLinks();
	hideMail("infoMail", "info", "comelio", "com");
	hideMailAddress("infoMailAdd", "info", "comelio", "com");
	hideMail("trainingMail", "training", "comelio", "com");	
});
$(window).resize(function() {setMinHeight();});
function setMinHeight()
{	
	$('.colmask').removeAttr('style');
	var wrHeight = $('#wrapper').height();
	var colHeight = $('.colmask').height();
	var diffHeight = wrHeight / colHeight;	
	if(diffHeight>1.36)
	{	
	  var he = 'height:'+Math.round(wrHeight*0.782).toFixed(2)+'px;';
	  $('.colmask').attr('style',he);
	}
}

function showHideContactForm()
{
	$("#contact").hide(0);
    $("a#kontaktlink").click(function(event){
      /*event.preventDefault();*/
      $("#contact").slideToggle(300);
    });
    $("a.kontaktref").click(function(event){      
      $("#contact").slideDown(300);
    });
    $("a#kontaktlinkjump").click(function(event){       
        $("#contact").slideDown(300);
      });
}

function externalLinks() {  
	var anchors = $("a,area");   
	if(anchors!=null)
	{
		 for (var i=0; i<anchors.length; i++) {   
		   var anchor = anchors[i];   
		   if (anchor.getAttribute("href") &&   
		   (anchor.getAttribute("rel") == "external")
		   ||anchor.getAttribute("class") == "external")
		   {
			   anchor.target = "_blank";   
		   }
		 }
	}
}
function hideMail(el, name, site, ext){
	var z='mail'+'to';
	var str = '<a href="'+z+':'+name+'@'+site+'.'+ext+'"> '+name+'@'+site+'.'+ext+'</a>';
	jQuery("."+el).html(str);
}
function hideMailAddress(el, name, site, ext){
	var str = name+'@'+site+'.'+ext;
	jQuery("."+el).html(str);
}
function setExpander(){
	$('ul.expander > li > p').expander({
		  slicePoint: 150, 
		  widow: 2,
		  afterExpand: function($thisEl) {setMinHeight();},
		  onCollapse: function($thisEl, byUser) {setMinHeight();}
		});
}
