﻿$(document).ready(function($){
	$(function(){
		$('div.two-columns > div.fixed-left-column, div.three-columns > div.fixed-left-column').each(function(){
			$('div.elastic-column', this.parentNode).css('margin-left', $(this).css('width'))
		});
		
		$('div.two-columns > div.fixed-right-column, div.three-columns > div.fixed-right-column').each(function(){
			$('div.elastic-column', this.parentNode).css('margin-right', $(this).css('width'))
		});
		
		$('div.same-height').each(function(){
			var height = $(this).outerHeight(true) - ( $(this).outerHeight(true) - $(this).height() );
			$('> div', this).each(function(){
				$(this).css('height', height);
			});
		});
		
		$('div.full-height').each(function(){
			$(this).css('height', $(this.parentNode).height() - ( $(this).outerHeight(true) - $(this).height() ));
		});
	});
});

//Tooltip
$(document).ready(function($){
    $(function(){
	    $('[rel*="tooltipText"]').tooltip({ 
            track: true, 
            delay: 0, 
            showURL: false, 
            showBody: " - ", 
            fade: 250 
        })
        
        $('[rel*="tooltipImg"]').tooltip({ 
            delay: 0, 
            showURL: false, 
            bodyHandler: function() { 
                return $("<img/>").attr("src", $(this).attr("rel").replace('tooltipImg,', '')); 
            } 
        })
    });
});

//limit text area length
function limitChars(textid, limit, infodiv, language)
{
    var text = $('#'+textid).val();	
    var textlength = text.length;
    if(textlength > limit)
    {
        switch(language)
        {
            case 'fr':
                $('#' + infodiv).html('Maximum ' + limit + ' caractères!');
                break;
            case 'nl':
                $('#' + infodiv).html('Maximaal tekens ' + limit + ' !');
                break;
            case 'en':
                $('#' + infodiv).html('Maximum ' + limit + ' characters!');
                break;
            case 'de':
                $('#' + infodiv).html('Maximum ' + limit + ' Zeichen!');
                break;
            case 'es':
                $('#' + infodiv).html('Maximum ' + limit + ' characters!');
                break;
            default:
                $('#' + infodiv).html('Maximum ' + limit + ' characters!');
                break;
        }        
        $('#'+textid).val(text.substr(0,limit));
        return false;
    }
    else
    {
        switch(language)
        {
            case 'fr':
                $('#' + infodiv).html('Il vous reste ' + (limit - textlength) + ' caractères.');
                break;
            case 'nl':
                $('#' + infodiv).html('U heeft ' + (limit - textlength) + ' tekens.');
                break;
            case 'en':
                $('#' + infodiv).html('You have ' + (limit - textlength) + ' characters left.');
                break;
            case 'de':
                $('#' + infodiv).html('Sie haben noch ' + (limit - textlength) + ' Zeichen.');
                break;
            case 'es':
                $('#' + infodiv).html('You have ' + (limit - textlength) + ' characters left.');
                break;
             default:
                $('#' + infodiv).html('You have '+ (limit - textlength) +' characters left.');
                break;
        }       
        return true;
    }
}