﻿function $(elementID) {
    return document.getElementById(elementID);
}
function $get(elementID) {
    return $(elementID);
}

var Utility = {
    show: function(id) {
        $(id).style.display = 'block';
        $(id).style.visibility = 'visible';
    },
    hide: function(id) {
        $(id).style.display = 'none';
        $(id).style.visibility = 'hidden';
    },
    show1: function(id) {
        $(id).style.display = 'inline';
        $(id).style.visibility = 'visible';
        $(id).style.position = 'static';
    },
    hide1: function(id) {
        $(id).style.display = 'none';
        $(id).style.visibility = 'hidden';
        $(id).style.position = 'absolute';
    },


    show3: function(id) {
        /*$(id).style.display = 'block';*/
        $(id).style.visibility = 'visible';
        $(id).style.position = 'static';
    },
    hide3: function(id) {
        /*$(id).style.display = 'none';*/
        $(id).style.visibility = 'hidden';
        $(id).style.position = 'absolute';
    },


    IsHidden: function(id) {
        if ($(id) == null) return true;
        //alert($(id).style.display)
        //alert($(id).style.visibility)
        if ($(id).style.display == '' && $(id).style.visibility == '')
            return null;
        if ($(id).style.display == 'none')
            return true;
        if ($(id).style.visibility == 'hidden')
            return true;
        return false;
    },
    fix: function(event) {
        if (!event) event = window.event
        //if (event.target) {
        //    if (event.target.nodeType == 3) event.target = event.target.parentNode

        //} else if (event.srcElement) {
        //    event.target = event.srcElement
        //}
        return event
    },
    ShowModalPage: function(DestinationPage, PageHight/*default="180"*/, PageWidth/*default="500"*/, PageScroll/*default=0*/) {
        //set optional parameters	
        if (PageHight == "")
            PageHight = "180"
        if (PageWidth == "")
            PageWidth = "500"
        if (PageScroll == "")
            PageScroll = "0"
        var Reload;
        Reload = window.showModalDialog("" + DestinationPage + "", window, 'help:0;status:0;scroll:' + PageScroll + ';dialogHeight:' + PageHight + 'px;dialogWidth:' + PageWidth + 'px;');
        if (Reload) {
            return true;
        }
        if (Reload == 'Cancel') {
            return false;
        }
    },
    getMousePos: function(e) {
        e = Utility.fix(e);
        if ('undefined' != typeof e.pageX) {
            mouseX = e.pageX;
            mouseY = e.pageY;
        } else {
            mouseX = e.clientX + document.body.scrollLeft;
            mouseY = e.clientY + document.body.scrollTop;
        }
    }
};

function Showinfo(innerHTML) {
    favArea();
    $('theadContainer').innerHTML = innerHTML;
    Utility.show('thead');


    //$('wrapper').style.filter='alpha(opacity=30)';
    //$('wrapper').style.opacity = 0.3;
    //$('wrapper').style['-moz-opacity'] = 0.3;
    //$('wrapper').style['-khtml-opacity'] = 0.3;


    // div = $('printer'); 
    //div.innerHTML='<a href="' + path + '" target="_blank" class="printer1"><img src="print.gif"/>Print</a>';
    // newlink = document.createElement('a'); 
    //div.appendChild(newlink);
    //newlink.setAttribute('target', '_blank'); 
    //newlink.setAttribute('href', path);
    //newlink.setAttribute('class','printer1');
    //newlink.innerHTML='Print';

}
function HideInfo() {
    Utility.hide('thead');

    //$('wrapper').style.filter='alpha(opacity=100)';
    //$('wrapper').style.opacity = 1;
    //$('wrapper').style['-moz-opacity'] = 1;
    //$('wrapper').style['-khtml-opacity'] = 1;
}


function favArea() {

    var x, y;
    if (self.innerHeight) // all except Explorer
    {
        x = self.innerWidth;
        y = self.innerHeight;
    }
    else if (document.documentElement && document.documentElement.clientHeight)
    // Explorer 6 Strict Mode
    {
        x = document.documentElement.clientWidth;
        y = document.documentElement.clientHeight;
    }
    else if (document.body) // other Explorers
    {
        x = document.body.clientWidth;
        y = document.body.clientHeight;
    }

    cx = x;
    cy = y;

    var x, y;
    if (self.pageYOffset) // all except Explorer
    {
        x = self.pageXOffset;
        y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
    // Explorer 6 Strict
    {
        x = document.documentElement.scrollLeft;
        y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
        x = document.body.scrollLeft;
        y = document.body.scrollTop;
    }



    var Element = document.getElementById("thead");
    // objh = parseFloat(Element.style.height)/2;
    //alert(document.documentElement.offsetHeight);
    //alert(document.documentElement.clientHeight);
    //alert(document.body.clientHeight)
    //alert(document.documentElement.scrollTop);



    objh = parseFloat(300) / 2; //default with of div
    objw = parseFloat(550) / 2; //defualt height of div
    t = Math.floor(Math.round(cy / 2) + y - objh);
    l = Math.floor(Math.round((cx / 2) + x) - objw);

    //alert(cx + "." + cy + "." + x + "." + y + "." + t + "." + l );

    Element.style.top = t + 'px';
    Element.style.left = l + 'px';
}
function favArea1() {





    var Element = document.getElementById("thead");
    // objh = parseFloat(Element.style.height)/2;
    objh = parseFloat(300) / 2;
    objw = parseFloat(550) / 2;
    //alert(document.documentElement.offsetHeight);
    //alert(document.documentElement.clientHeight);
    alert(document.body.clientHeight)
    //alert(document.documentElement.scrollTop);

    Element.style.top = Math.floor(Math.round(document.documentElement.clientHeight / 2) + document.documentElement.scrollTop - objh) - 20 + 'px';
    Element.style.left = Math.floor(Math.round((document.documentElement.offsetWidth / 2) + document.documentElement.scrollLeft) - objw) - 20 + 'px';
}


function DoPrint() {
    var pp = frames['PersonInfo'];

    pp.focus();
    //$('PersonInfo').contentWindow.print(); 
    pp.print();
    //			hideallmenus();	
    //			div1.style.visibility="hidden";
    //			var storeTitle=document.title;
    //			document.title="Organization Chart"
    //			window.print();
    //			document.title=storeTitle;
    //			div1.style.visibility="visible";
}

function isNumeric(elem) {
    var numericExpression = /^[0-9]+$/;
    if (elem.match(numericExpression)) {
        return true;
    } else {
        return false;
    }
}
function isEnglish(elem) {
    return true;
    var numericExpression = /^a-zA-Z0-9-_\./;
    if (elem.match(numericExpression)) {
        return true;
    } else {
        return false;
    }
}
function getY(oElement) {

    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetTop;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}
function getX(oElement) {

    var iReturnValue = 0;
    while (oElement != null) {
        iReturnValue += oElement.offsetLeft;
        oElement = oElement.offsetParent;
    }
    return iReturnValue;
}
function GetXmlHttpObject() {
 
    if (window.XMLHttpRequest) {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
    }
    if (window.ActiveXObject) {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
    }
    return null;
}