﻿document.getElementsByTagName("form")[0].style.height = document.getElementsByTagName("body")[0].style.height;
document.getElementsByTagName("form")[0].style.width = document.getElementsByTagName("body")[0].style.width;

var ie5=document.all&&document.getElementById
var ns6=document.getElementById&&!document.all
if (ie5||ns6)
var menuobj=document.getElementById("ctl00_ContentMain_mycontextmenu")

function showmenuie5(e,type){
//Find out how close the mouse is to the corner of the window
document.getElementById("ctl00_ContentMain_lastRightClickId").value=e.srcElement.id;

if(type==-1){
    document.getElementById("ctl00_ContentMain_lnlbtnnewpage").style.display='block';
    document.getElementById("ctl00_ContentMain_lnlbtneditpage").style.display='none';
    document.getElementById("ctl00_ContentMain_lnlbtndeletepage").style.display='none';
    document.getElementById("ctl00_ContentMain_lnlbtnmovepageup").style.display='none';
    document.getElementById("ctl00_ContentMain_lnlbtnmovepagedown").style.display='none';
    document.getElementById("ctl00_ContentMain_lnlbtncopypage").style.display='none';
    document.getElementById("ctl00_ContentMain_lnlbtncutpage").style.display='none';
     
   
    if (document.getElementById("ctl00_ContentMain_lastRightClickIdForCut").value == -1 && document.getElementById("ctl00_ContentMain_lastRightClickIdForCopy").value == -1 ){
      document.getElementById("ctl00_ContentMain_lnlbtnpastepage").style.display='none';
    }
      else
    {
      document.getElementById("ctl00_ContentMain_lnlbtnpastepage").style.display='block';
    }
}
else{
    if(type==0){
        document.getElementById("ctl00_ContentMain_lnlbtnmovepageup").style.display='block';
        document.getElementById("ctl00_ContentMain_lnlbtnmovepagedown").style.display='block';
        document.getElementById("ctl00_ContentMain_lnlbtnnewpage").style.display='block';
        if (document.getElementById("ctl00_ContentMain_lastRightClickIdForCut").value == -1 && document.getElementById("ctl00_ContentMain_lastRightClickIdForCopy").value == -1 ){
            document.getElementById("ctl00_ContentMain_lnlbtnpastepage").style.display='none';
        }
        else
        {
            document.getElementById("ctl00_ContentMain_lnlbtnpastepage").style.display='block';
        }
    }
    else
    {
        document.getElementById("ctl00_ContentMain_lnlbtnmovepageup").style.display='none';
        document.getElementById("ctl00_ContentMain_lnlbtnmovepagedown").style.display='none';
        document.getElementById("ctl00_ContentMain_lnlbtnnewpage").style.display='none';
        document.getElementById("ctl00_ContentMain_lnlbtnpastepage").style.display='none';    
    }
    document.getElementById("ctl00_ContentMain_lnlbtneditpage").style.display='block';
    document.getElementById("ctl00_ContentMain_lnlbtndeletepage").style.display='block';
    document.getElementById("ctl00_ContentMain_lnlbtncopypage").style.display='block';
    document.getElementById("ctl00_ContentMain_lnlbtncutpage").style.display='block'
}


////Find out how close the mouse is to the corner of the window
//var rightedge=ie5? document.body.clientWidth - event.clientX : window.innerWidth - e.clientX
//var bottomedge=ie5? document.body.clientHeight - event.clientY : window.innerHeight - e.clientY

////if the horizontal distance isn't enough to accomodate the width of the context menu
//if (rightedge<menuobj.offsetWidth)
////move the horizontal position of the menu to the left by it's width
//menuobj.style.left=ie5? document.body.scrollLeft+event.clientX-menuobj.offsetWidth : window.pageXOffset+e.clientX-menuobj.offsetWidth
//else
////position the horizontal position of the menu where the mouse was clicked
//menuobj.style.left=ie5? document.body.scrollLeft+event.clientX : window.pageXOffset+e.clientX

//alert(document.body.scrollTop);
//alert(event.clientY);

////same concept with the vertical position
//if (bottomedge<menuobj.offsetHeight)
//menuobj.style.top=ie5? document.body.scrollTop + event.clientY - menuobj.offsetHeight : window.pageYOffset+e.clientY - menuobj.offsetHeight
//else
//menuobj.style.top=ie5? document.body.scrollTop + event.clientY : window.pageYOffset + e.clientY


var left = ie5? event.clientX : e.clientX 
var top =  ie5? event.clientY : e.clientY 

menuobj.style.left = left + f_scrollLeft();
menuobj.style.top = top + f_scrollTop();




//if(ie5)
//{
    //window.event.cancelBubble = true;
//}
//else if(ns6)
//{
    //e.stopPropagation();
//}

try{
event.cancelBubble=true;
}catch(e){}
try{
e.cancelBubble = true
}catch(e){}
try{
e.stopPropagation();
}catch(e){}

menuobj.style.visibility="visible"

    
return false
}

function hidemenuie5(e){
try{
menuobj.style.visibility="hidden"
}catch(e){}
}

function highlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="contextmenuitems"||ns6&&firingobj.parentNode.className=="contextmenuitems"){
if (ns6&&firingobj.parentNode.className=="contextmenuitems") 
firingobj=firingobj.parentNode //up one node

firingobj.style.backgroundColor="highlight"

}
}

function lowlightie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="contextmenuitems"||ns6&&firingobj.parentNode.className=="contextmenuitems"){
if (ns6&&firingobj.parentNode.className=="contextmenuitems") 
firingobj=firingobj.parentNode //up one node

firingobj.style.backgroundColor=""


window.status=''
}
}

function jumptoie5(e){
var firingobj=ie5? event.srcElement : e.target
if (firingobj.className=="contextmenuitems"||ns6&&firingobj.parentNode.className=="contextmenuitems"){
if (ns6&&firingobj.parentNode.className=="contextmenuitems") 
var firingobj2=firingobj.parentNode
// the click can be controlled by firingobj
// if the click was generated by the div tag enclosing the link buttons
//then the value of firingobj=htmlDivElement el
// else if the click was generated by the linkbutton
// then the value of firingobj will be href of the link button and the value of firingobj2 will be htmlDivElement
// the code for controlling the clciks goes here

}
}

if (ie5||ns6){
try{
menuobj.style.display=''
}catch(e){}
try{
document.onclick=hidemenuie5
}catch(e){}
}





function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

