/**
 * Silent Strength Javascript
 * Michael Ortali 2009
 */
var silent = new Silent();
$(document).ready(silent.initiate);

/**
 * I use mostly javascript to add links
 * and to enhance the user experience :)
 */
function Silent() {    
    /**
     * Adding the links on the homepage
     * images for the blog section.
     */
    this.initHomepage = function() {
        $("div#carnet-homepage li").each(function() {
            var link = $(this).find('a').attr('href');
            $(this).find('img').click(function() { 
                window.location.href = link; 
            });
        });
    };
    
    /**
     * Adding the links on the images
     */
    this.initCarnet = function() {
        $("div#article div.post").each(function() {
            var link = $(this).find('h2 a').attr('href');
            $(this).find('p.preview img').click(function() { 
                window.location.href = link; 
            });
        });
    };

    this.initPortfolio = function() {
        $("div#portfolio div.separator").each(function() {
            var link = $(this).find('div.infos a:eq(0)').attr('href');
            if(link != undefined) {
                $(this).find('p.creative img').click(function() { 
                    window.open(link); 
                });
            }
            else {
                $(this).find('p.creative img').css('cursor','default');
            }
        });
    };
    
    this.initResume = function() {
        $("div#cv div.c2").each(function() {
            var link = $(this).find('div.infos a:eq(0)').attr('href');
            if(link != undefined) {            
                $(this).find('div.infos img').click(function() { 
                    window.open(link); 
                });
            }
            else {
                $(this).find('div.infos img').css('cursor','default');
            }
        });
    };
    
    /**
     * Public static method used with 
     * JQuery.
     */
    this.initiate = function() {
        silent.initHomepage();
        silent.initPortfolio();
        silent.initCarnet();
        silent.initResume();
    };
}
