/**
 
* ContextMenu
 
*/
 
 
 
// taken from: http://www.quirksmode.org/js/detect.html
 
var thestring;
 
function detectBrowser(){
 
    var detect = navigator.userAgent.toLowerCase();
 
    var OS,browser,version,total;
 
 
    if(checkIt('konqueror')){
 
        browser = 'Konqueror';
 
        OS = 'Linux';
 
    }else if (checkIt('safari')) browser = 'Safari';
 
    else if (checkIt('omniweb')) browser = 'OmniWeb';
 
    else if (checkIt('opera')) browser = 'Opera';
 
    else if (checkIt('webtv')) browser = 'WebTV';
 
    else if (checkIt('icab')) browser = 'iCab';
 
    else if (checkIt('msie')) browser = 'Internet Explorer';
 
    else if (!checkIt('compatible')){
 
        browser = 'Netscape Navigator';
 
        version = detect.charAt(8);
 
    }else browser = 'An unknown browser';
 
    if(browser != 'Konqueror'){
 
        if(checkIt('gecko'))browser = 'Mozilla';
 
    }
 
    if(!version) version = detect.charAt(place + thestring.length);
 
    if(!OS){
 
        if (checkIt('linux')) OS = 'Linux';
 
        else if (checkIt('x11')) OS = 'Unix';
 
        else if (checkIt('mac')) OS = 'Mac'
 
        else if (checkIt('win')) OS = 'Windows'
 
        else OS = 'an unknown operating system';
 
    }
 
    total = OS+' '+browser+' '+version;
 
    return browser;
 
}
 
function checkIt(string){
 
    var detect = navigator.userAgent.toLowerCase();
 
    place = detect.indexOf(string) + 1;
 
    thestring = string;
 
    return place;
 
}
 
 
 
 
 
 
 
window.noHide = false;
 
 
function OnOver(bu){
 
    var elem = document.getElementById(bu);
 
    elem.style.backgroundColor = '#000088';
 
    elem.style.color = '#FFFFFF';
 
    window.status = elem.innerHTML;
 
}
 
function OnOut(bu){
 
    var elem = document.getElementById(bu);
 
    elem.style.backgroundColor = '#E0E0E0';
 
    elem.style.color = '#000000';
 
    window.status = '';
 
}
 
 
/**
 
* creates a contextMenu button and returns the HTML
 
*/
 
function mFAct(actName){
 
    act = eval(cMenu.actions);
 
    return '<tr><td class=cMenu_button id=\"cMenu_'+actName+'\" onmouseover=\"OnOver(id)\" onmouseout=\"OnOut(id)\" onclick=\"'+act[actName]+'\"><span onclick=\"'+act[actName]+'\">'+actName+'</span></td></tr>';
 
}
 
 
function contextMenuIE(){
 
    elem = event.srcElement;
 
    if(elem.className){
 
        return contextMenu(elem);
 
    }else{
 
        // get the parentElement to correct the M$IE failure
 
        elem = elem.parentElement;
 
        if(elem.className){
 
            return contextMenu(elem);
 
        }else{
 
            alert(elem.parentLayer);
 
        }
 
    }
 
}
 
 
/**
 
* creates and shows the contextMenu of the submitted element
 
*/
 
function contextMenu(elem){
 
 
    if(type = elem.className){
 
        id = elem.id;
 
        window.cMenu.value = id;
 
//        document.getElementById('browserValue').value = cMenu_value;
 
        if(detectBrowser() != 'Internet Explorer'){
 
            ContextMenu = document.getElementById('ContextMenu');
 
        }
 
 
        items = eval(cMenu.classes[type]);
 
        ContextMenu.style.visibility = 'hidden';
 
        mouseX = window.mouseX;
 
        mouseY = window.mouseY;
 
        cMenuW = 100;
 
        cMenuH = items.length*19+4;
 
        if(mouseX > document.body.clientWidth+document.body.scrollLeft-cMenuW)mouseX -= cMenuW;
 
        if(mouseY > document.body.clientHeight+document.body.scrollTop-cMenuH)mouseY -= cMenuH;
 
        if(mouseX <= 0)mouseX = document.body.scrollLeft;
 
        if(mouseY <= 0)mouseY = document.body.scrollTop;
 
        ContextMenu.style.left = mouseX -7;
 
        ContextMenu.style.top = mouseY -7;
 
        HTML ='';
 
        for(i = 0; i < items.length; i++){
 
            HTML += mFAct(items[i]);
 
        }
 
        ContextMenu.innerHTML = '<table cellspacing=0 class=cMenu_cMenu>'+HTML+'</table>';
 
        ContextMenu.style.visibility = 'visible';
 
        return false;
 
    }else return false;
 
}
 
 
/**
 
* this function evaluates the mouse position and makes it avilable in 'window.mouse(X/Y)'
 
*/
 
function mousePos(e){
 
    if(e)event = e;
 
    window.mouseX = event.clientX + document.body.scrollLeft;
 
    window.mouseY = event.clientY + document.body.scrollTop;
 
}
 
 
/**
 
* this function hides the contextMenu
 
*/
 
function hide(){
 
    if(window.noHide){
 
        window.noHide = false;
 
        return;
 
    }
 
 
    if(detectBrowser() != 'Internet Explorer')ContextMenu = document.getElementById('ContextMenu');
 
    ContextMenu.style.visibility = 'hidden';
 
//    ContextMenu.style.left = -999;
 
//    ContextMenu.style.top = -999;
 
}
 
 
function cancelproc(){
 
    window.event.cancelBubble = true;
 
    window.event.returnValue = false;
 
}
 
 
function fals(){
 
    return false;
 
}
 
 
 
function cMenu_begin(){
 
    document.body.innerHTML += '<div id=ContextMenu class=cMenu_cMenu style=z-index:4;></div>';
 
    var browser = detectBrowser();
 
    if(browser != 'Internet Explorer'){
 
        ContextMenu = document.getElementById('ContextMenu');
 
    }
 
    ContextMenu.style.visibility = 'hidden';
 
    ContextMenu.style.position = 'absolute';
 
    ContextMenu.style.border = '1px solid #E0E0E0';
 
 
    document.body.oncontextmenu = fals;
 
    document.body.onmousemove = mousePos;
 
 
    tags = eval(cMenu.tags);
 
    for(h = 0; h < tags.length; h++){
 
        tag = tags[h];
 
        for(i = 0; i < document.getElementsByTagName(tag).length; i++){
 
            elem = document.getElementsByTagName(tag).item(i);
 
 
            if(eval(cMenu.classes[elem.className])){
 
//                alert(detectBrowser());
 
                if(browser == 'Internet Explorer'){
 
                    elem.attachEvent('oncontextmenu', contextMenuIE);
 
                }else if(browser == 'Mozilla'){
 
                    elem.setAttribute('oncontextmenu', 'contextMenu(this)');
 
                }else if(browser == 'Opera'){
 
//                alert('<'+tag+' class='+elem.className+'>'+eval(cMenu.classes[elem.className]).length);
 
                    elem.innerHTML = '<input type=button onclick="contextMenu(this.parentElement); window.noHide=true;" value=cM>'+elem.innerHTML;
 
                }else{
 
                    elem.onclick = 'contextMenu(this); window.noHide=true;';
 
                    elem.setAttribute('onclick', 'contextMenu(this); window.noHide=true;');
 
                }
 
            }
 
 
        }
 
    }
 
 
    
 
    document.onclick = hide;
 
    ContextMenu.ondragstart = cancelproc;
 
    ContextMenu.onselectstart = cancelproc;
 
//    alert(document.body.innerHTML);
 
}
 
 
//if(window.attachEvent)window.attachEvent('onload', cMenu_begin);
 
//else if(window.addEventListener)window.addEventListener('load', cMenu_begin, false);
 
 
 |