
function fontSizeModification(array,direction){
    /* possible ehtml tags inside a tag*/
    var innerElements = ['span','div','p','h2','h3','h4','b','i']; 
    var increseLimit = 10;// x times
    var decreaseLimit = 1;
       
    $.each(array, function(key, value) {     
        var currentSize = $(key).css('font-size');
        var currentHeight = $(key).css('line-height');
        var currentSize = parseFloat(currentSize, 10);
        var currentHeight = parseFloat(currentHeight, 10);
       
        switch(direction)
        {
            case "increase":
                if(currentSize < parseFloat(value, 10)+increseLimit){
                    var newSize = currentSize+1;
                    var newHeight = currentHeight+1;
                }
                break;
            case "decrease":
                if(currentSize > parseFloat(value, 10)-decreaseLimit){
                    var newSize = currentSize-1;
                    var newHeight = currentHeight-1;
                }
                break;
            case "normal":
                var newSize = value;
                var newHeight = (parseFloat(value, 10)+4);

                break;
        }
       
      
        $(key).css('font-size', newSize);
        $(key).css('line-height', newHeight+"px");
        
        $.each(innerElements, function(ikey, ivalue) {
            $(key+" > "+ivalue).css('font-size', newSize);
            $(key+" > "+ivalue).css('line-height', newHeight+"px");
        });
    });
}

function LoadAjax(url,input){
    //$(input).html("inc/images/loading.gif");
    $.get(url, function(data) {
        $(input).html(data);
        
    });
}
function LoadCalendar(url){
    LoadAjax(url,".calendar-wrapper");
}
function LoadNewsPaper(url,daynr){
    $(".calendar table tr td").removeClass("active");
    $("td#row_"+daynr).addClass("active");
    LoadAjax(url,".newspapper-wrapper");
}
function SubmitPoll(){
    var voted = false;
    $('#poll-form input').each(function(index) {
        if($('#'+$(this).attr("id")).is(':checked')){
            url = $("#poll-form").attr("action")+"&vote="+$(this).val();
            LoadAjax(url,"#poll-results");
        }
    });
    return false;
}
function postComment(){
    $.post($(".comment-form").attr("reference"), {
        submit_comment: "1", 
        name: $("#name").val(), 
        email: $("#email").val(), 
        place: $("#place").val(), 
        text: $("#text").val(), 
        verif: $("#verif").val(),
        verif_code: $("#verif_code").val()
    },
    function(data) {
        $('.comment-form').html(data);
    });
    return false;
}

function calculateTimeout(currElement, nextElement, opts, isForward) { 
    var timeout = $(currElement).find('div:first').attr('class');
    if(timeout == 0){
        timeout = 10;
    }
    return timeout*1000; 
}
