/**
 * @author ehandelsbureauet
 * this script is copyrighted and is not allowed to be used in any way without permission.
 *
 **/
image_url = new Array();
preLoadImgPrMenu();

function init(){
    performImgScript();
    systemCategories();
}

function systemCategories(){
    if (window.location.pathname.match(new RegExp('^/shop/news'))) {
        document.getElementById('prListHeader').innerHTML = "<h1>Nyheder</h1>";
    }
    if (window.location.pathname.match(new RegExp('^/shop/specialoffer'))) {
        document.getElementById('prListHeader').innerHTML = "<h1>Tilbud</h1>";
    }
    if (window.location.pathname.match(new RegExp('^/shop/search'))) {
        document.getElementById('prListHeader').innerHTML = "<h1>Søgeresultat</h1>";
    }
}



function preLoadImgPrMenu(){ //PRELOAD MENU
    if (document.images) {
        preload_image_object = new Image();
        // set image url        
        image_url.push = "/images/design/construction/prmenu_niv1.gif";
        image_url.push = "/images/design/construction/prmenu_niv1_h.gif";
        image_url.push = "/images/design/construction/prmenu_niv2.gif";
        image_url.push = "/images/design/construction/prmenu_niv2_h.gif";
        image_url.push = "/images/design/construction/prmenu_niv3.gif";
        image_url.push = "/images/design/construction/prmenu_niv3_h.gif";
        image_url.push = "/images/design/construction/prmenu_niv_active.gif";
        var i = 0;
        for (i = 0; i <= image_url.length; i++) 
            preload_image_object.src = image_url[i];
    }
}





function performImgScript(){
    eventImgArray = document.getElementsByTagName('A');
    for (var i = 0; i < eventImgArray.length; i++) {
        if (eventImgArray[i].className == 'eventClass') {
            addEvent(eventImgArray[i], "mouseover", processOver, false);
            addEvent(eventImgArray[i], "mouseout", processOut, false);
        }
    }
    
    //CLEANMEM
    eventImgArray = "";
}

function addEvent(elem, evtType, func, capture){
    capture = (capture) ? capture : false;
    if (elem.addEventListener) {
        elem.addEventListener(evtType, func, capture);
    }
    else 
        if (elem.attachEvent) {
            elem.attachEvent("on" + evtType, func);
        }
        else {
            elem["on" + evtType] = func;
        }
}

function processOver(evt){
    evt = (evt) ? evt : window.event;
    var elem = (evt.target) ? evt.target : evt.srcElement;
    elem.src = elem.src.replace(/.gif/, "_h.gif")
}

function processOut(evt){
    evt = (evt) ? evt : window.event;
    var elem = (evt.target) ? evt.target : evt.srcElement;
    elem.src = elem.src.replace(/_h.gif/, ".gif")
}
