/* Javascript for the Krimson-Extra template
*/

// enable no-conflict-mode and register jq() as shortcut for jquery()
var jq = jQuery.noConflict();
















/*###################################*/
/* individual modifications put here */
/*-----------------------------------*/

/**
 *  all links that starts with "http://" are external links
 *  
 *  set target="_blank" to these links by script
 */     
function setTargetForExternalLinks() {
    var links = jq('#content-wrap a[href^=http:], #footer-wrap a[href^=http:]');
    jq('#content-wrap a[href^=http:], #footer-wrap a[href^=http:]').each( function() {
        jq(this).attr('target', '_blank');
    });
}


function wrapImage() {
    var bigPic = jq(this).attr('src').replace('_thumb.jpg', '.png');
    jq(this).wrap('<a class="lightbox" rel="lightbox[group]" href="' + pageURL + '/' + bigPic + '"></a>');
}


function wrapReferenceImages() {
    if (jq("#main .headline").html().indexOf('Referenzen') != -1) {
        jq("#content img").each(wrapImage);
        jq('#content a.lightbox').lightBox();
    }
}


function initUserScripts() {
    setTargetForExternalLinks();
    wrapReferenceImages();
}



/*#####################*/
/* global jQuery init */
/*--------------------*/
jq(document).ready( function() {
    // add all automatic called scripts here
    
    
    initUserScripts();
});
