var webNav = { 
    'nav1' : 'bedrijfsprofiel', 
    'nav2' : 'diensten', 
    'nav3' : 'reserveren', 
    'nav4' : 'solliciteren', 
    'nav5' : 'links', 
    'nav6' : 'contact', 
    'nav7' : 'nieuws'
};

var oTime = null;

var navMouseOver = function( elmId ) {
    navHideAll();
    var elm = document.getElementById( elmId );
    var elm2 = document.getElementById( webNav[elmId] );

    if( elm2 != null ) {
        var left = elm2.offsetLeft;
    }
    else {
        elm2 = document.getElementById( webNav[elmId] + 'Active' );
        var left = elm2.offsetLeft;
    }
    
    var url = window.location.href.toString();

    if( url.match( /Preview/gi ) == 'Preview' ) {
        if( elm != null ) {
            elm.style.display = 'block';
            elm.style.left = left + 'px';
        }
    }
    else {

        var ulLis = elm.getElementsByTagName('li');
        if( elm != null && ulLis.length > 2 ) {
            elm.style.display = 'block';
            elm.style.left = left + 'px';
        }
    }
}

var navMouseOut = function( elmId ) {
    
    oTime = setTimeout (function(){ 
        var elm = document.getElementById( elmId );
        if( elm != null && elm.style.display == 'block' ) {
            elm.style.display = 'none';
        }
    }, 500);
}

var subNavOver = function ( elmId ) {
    clearTimeout(oTime);
}

var subNavOut = function ( elmId ) {
    navMouseOut( elmId );
}

var navHideAll = function(){
    
    clearTimeout(oTime);
    
    var elms = $('body').find('.subnav');
    if( elms.length > 0 ) {
        for( var i = 0; i < elms.length; i++ ) {
            elms[i].style.display = 'none';
        }
    }
}

var clearTimer = function () {
    clearTimeout(oTime);
}

var getFunctionSubNavOver = function ( id ) {
    return function() {
        subNavOver( id );
    }
}
var getFunctionSubNavOut = function ( id ) {
    return function() {
        subNavOut( id );
    }
}

var getFunctionNavOver = function ( id ) {
    return function () {
        navMouseOver( id ); 
    }
}
var getFunctionNavOut = function ( id ) {
    return function () {
        navMouseOut( id ); 
    }
}

$(document).ready(function() {

    for( var i = 1; i < 8; i++ ) {

        var tEId = 'nav' + i;
        $('#'+webNav[ tEId ]).bind( 'mouseover', getFunctionNavOver( tEId ) );
        $('#'+webNav[ tEId ] + 'Active' ).bind( 'mouseover', getFunctionNavOver( tEId ) );
        $('#'+webNav[ tEId ]).bind( 'mouseout', getFunctionNavOut( tEId ) );
        $('#'+webNav[ tEId ] + 'Active' ).bind( 'mouseout', getFunctionNavOut( tEId ) );
        $('#'+tEId).bind( 'mouseover', getFunctionSubNavOver ( tEId ) );
        $('#'+tEId).bind( 'mouseout', getFunctionSubNavOut ( tEId ) );
    }
	
    $('#carousel-small').bxSliderVertical({
    mode: 'slide',
    auto: 'true',
    controls : false,
    speed: 2000,
    pause: 5000,
    width: 800,
    wrapper_class: 'cssmall'
    });   

    if( FlashDetect != null ) {
        if( ! FlashDetect.installed){
            var elm0 = document.getElementById('headerflash');
            var elm1 = document.getElementById('flash_alternate_home');
            if(elm0 != null) elm0.style.display = 'none';
            if(elm1 != null) elm1.style.display = 'block';
        }
    }
    
});


if(typeof sIFR == "function"){
    sIFR.replaceElement(named({sSelector:"h1", sFlashSrc:"/Sites/Chauffeurscentrale/flash/lucidagrande.swf",
    sWmode:"transparent",sColor:"#388dd0", sEmColor:"#388dd0", sStrongColor:"#388dd0", 
    sSpanColor:"#388dd0"}));
    sIFR.replaceElement(named({sSelector:"h2", sFlashSrc:"/Sites/Chauffeurscentrale/flash/lucidagrande.swf",
    sWmode:"transparent",sColor:"#565656", sEmColor:"#565656", sStrongColor:"#565656", 
    sSpanColor:"#565656"}));
};

var elmHead = document.getElementById('header');
var elmHead2 = document.getElementById('header2');
if( elmHead != null ) {
  elmHead.style.visibility = 'visible';
}
if( elmHead2 != null ) {
  elmHead2.style.visibility = 'visible';
}

function changeImage() {
    newImage = "url('http://www.chauffeurscentrale.nl/Sites/Chauffeurscentrale/img/bg_form_inloggen.jpg')";
    document.getElementById('bgForm').style.backgroundImage = newImage;
}
function changeImageBack() {
    oldImage = "url('http://www.chauffeurscentrale.nl/Sites/Chauffeurscentrale/img/bg_form_inloggen_normal.jpg')";
    document.getElementById('bgForm').style.backgroundImage = oldImage;
}

