/**
 * Created by IOAN on 11/26/2015.
 */
$(document).ready(function(){

    var click_links = click_count_paths;
    $('.click-link').each(function(){
        var click_link_id = $(this).data('rel');
        var extra_class = $(this).data('extra_class');
        var sub_content = '<a href="' + click_links[click_link_id] + '" class="' + extra_class + '" target="_blank">' + $(this).html() + '</a>';
        $(this).replaceWith(sub_content);
    });

    $('.adv_linkage').each(function(){
        var $lnk = $(this);
        $lnk.on('click', function(ev){
            ev.preventDefault();
            window.open($lnk.data('link'));
            return false;
        });
    });

    /*$('a.click-count').each(function(i){
        var field = "cc";
        var href = $(this).attr('href');
        var cc_type = -1;


        if(href.indexOf('?' + field + '=') != -1) {
            cc_type = 1;
        }
        else if(href.indexOf('&amp;' + field + '=') != -1) {
            cc_type = 2;
        }
        else if(href.indexOf('?') != -1) {
            cc_type = 0;
            $(this).attr('href', href + '&amp;cc=1');
        }
        else {
            cc_type = -1;
            $(this).attr('href', href + '?cc=1');
        }
    });*/

    $('a.mailto').each(function(){
        var email = $(this).data('rel');
        email = email.replace('[ at ]', '@');
        $(this).attr('href', 'mailto:' + email);
        $(this).text(email);
    });

});