﻿function isMouseLeaveOrEnter(e, handler)
{ if (e.type != 'mouseout' && e.type != 'mouseover') return false; var reltg = e.relatedTarget ? e.relatedTarget : e.type == 'mouseout' ? e.toElement : e.fromElement; while (reltg && reltg != handler) reltg = reltg.parentNode; return (reltg != handler); }

function closePopup(popupId) {
    closePopUp(popupId+'_PopupDialog', popupId+'_PopupCover');
}


// http://www.w3schools.com/JS/js_cookies.asp

function setCookie(c_name, value, exdays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value + ";path=/";
}

function setCurrencyCookie(value) {
    setCookie('currency', value, 2000);
    document.location = document.location;
}

function setVATIncCookie(value) {
    setCookie('vat', value, 2000);
    document.location = document.location;
}

function changeCSSClass(control, value) {
    control.className = value;
}

function showhideleftnav(groupId) {

    var groupControl = document.getElementById('leftnav' + groupId);

    if (groupControl.className == 'left-column-group') {
        groupControl.className = 'left-column-group left-column-hidden';
    }
    else {
        groupControl.className = 'left-column-group';
    }
}

function showTip(id, code) {
    //stop all existing animation on the element
    $('#' + id + 'Tip').stop(true, true).clearQueue();    
    if ($('#' + id + 'Tip').css("display") == "none") {   
        $('#' + id + 'Tip').fadeIn(50);
    }
}

function hideTip(id) {
    $('#' + id + 'Tip').delay(1000).fadeOut(50);
}

function mouseOverEditImg(id) {
    if ($('#' + id).parent().is("a")) {
        $('#' + id).parent().click(function(ev) {
            //prevent the default action of the event, this will stop the href in the anchor being followed
            //before the animation has started, u can also use return false;
            ev.preventDefault();
        });
    }
    else {
        $('#' + id).parentsUntil("a").click(function(ev) {
            //prevent the default action of the event, this will stop the href in the anchor being followed
            //before the animation has started, u can also use return false;
            ev.preventDefault();
        });
    }
}

function mouseOutEditImg(id) {

    if ($('#' + id).parent().is("a")) {
        $('#' + id).parent().clearQueue();
    }
    else {
        $('#' + id).parentsUntil("a").clearQueue();
    }
    
}
