﻿

/* - - - - - - - - - - - - - - - - - - - - - - - - -
     Animations
 - - - - - - - - - - - - - - - - - - - - - - - - - -*/

function mouseActions(domElement, picDefault, picOver, picDown, topDefault, topOver, topDown) {
    //picDefault is de background-position
    //topDefault is de top positie.

    $(domElement).mouseover(function() {
        $(this).css("background-position", picOver);
        $(this).css("top", topOver);
    });
    $(domElement).mouseout(function() {
        $(this).css("background-position", picDefault);
        $(this).css("top", topDefault);
    });
    $(domElement).mousedown(function() {
        $(this).css("background-position", picDown);
        $(this).css("top", topDown);
    });
    $(domElement).mouseup(function() {
        $(this).css("background-position", picOver);
        $(this).css("top", topOver);
    });
}

var selectedButton = "";
function mouseActionsAirButtons(domElement, picDefault, picOver, picDown, topDefault, topOver, topDown) {
    //picDefault is de background-position
    //topDefault is de top positie.

    $(domElement).mouseover(function() {
        if (selectedButton != domElement) {
            $(this).css("background-position", picOver);
            $(this).css("top", topOver);
        }
    });
    $(domElement).mouseout(function() {
        if (selectedButton != domElement) { 
            $(this).css("background-position", picDefault);
            $(this).css("top", topDefault);
        }
    });
    $(domElement).mousedown(function() {
        $(this).css("background-position", picDown);
        $(this).css("top", topDown);
    });
    $(domElement).mouseup(function() {
        deselectInclickableButtons(picDown, topDown); //reset
        selectedButton = domElement;
    });
}
function deselectInclickableButtons(picOver, topOver) {
    selectedButton = "";
    $("#loop_item_lees_meer").css("background-position", picOver);
    $("#loop_item_lees_meer").css("top-position", topOver);
    $("#loop_item_realisaties").css("background-position", picOver);
    $("#loop_item_realisaties").css("top-position", topOver);
}

/* - - - - - - - - - - - - - - - - - - - - - - - - -
    FUNCTIONS
- - - - - - - - - - - - - - - - - - - - - - - - - -*/
function cleanForURL(url) {
    return url.toLowerCase().replace(/ /g, '-');
}

function disableSelection(target) {

    if (typeof target.onselectstart != "undefined") //IE route
        target.onselectstart = function() { return false }

    else if (typeof target.style.MozUserSelect != "undefined") //Firefox route
        target.style.MozUserSelect = "none"

    else //All other route (ie: Opera)
        target.onmousedown = function() { return false }

    target.style.cursor = "default"
}

function IsIE8Browser() {
    var rv = -1;
    var ua = navigator.userAgent;
    var re = new RegExp("Trident\/([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null) {
        rv = parseFloat(RegExp.$1);
    }
    return (rv == 4);
}

function IsOperaBrowser() {
    var result = false;
    if (navigator.userAgent.indexOf("Opera") != -1) {
        result = true;
    }
    return result;
}

function allowTransitions() {
    var result = true;
    if (navigator.userAgent.match(/iPad/i) != null || navigator.userAgent.match(/iPhone/i) != null)
    {result = false;}
    return result;
}

function getScrollElement() {
    var result = "html, body";
    if (IsOperaBrowser()){
        result = "html";
    }
    return result;
}



/* - - - - - - - - - - - - - - - - - - - - - - - - -
    DEBUGGING
- - - - - - - - - - - - - - - - - - - - - - - - - -*/

function debug() {
    //shoveLayers("2", "right");
}

/* - - - - - - - - - - - - - - - - - - - - - - - - -
    VUILBAK
- - - - - - - - - - - - - - - - - - - - - - - - - -*/

