﻿//===============================================================================================
dialog = {
    name: "dialogbox",
    id: "dialogbox"
}

dialog.init = function() {
    var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
    var left = parseInt((document.documentElement.clientWidth / 2) - 380, 10);
    var top = parseInt((document.documentElement.clientHeight / 2) - 100, 10); 
    var layer = document.createElement('div');
    layer.style.zIndex = 490;
    layer.id = 'popupframe';
    layer.style.display = "none";
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    layer.style.height = document.documentElement.scrollHeight + 'px';
    layer.style.width = width + 'px';
    layer.style.backgroundColor = 'gray';
    layer.style.opacity = '.6';
    layer.style.filter += ('progid:DXImageTransform.Microsoft.Alpha(opacity=50)');
    document.body.appendChild(layer);
    var div = document.createElement('div');
    div.style.zIndex = 491;
    div.id = 'popupbox';
    div.style.display = "none";
    div.style.height = 'auto';
    div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
    div.style.top = top + 'px';
    div.style.left = left + 'px';
    div.style.width = '370px';
    div.style.backgroundColor = '#F1EFEB';
    div.style.border = '6px solid #B3B2B2';
    div.style.padding = '10px';
    div.innerHTML = "<div id='closetab'><a href='javascript:dialog.hide();' style='float:right;' ><strong>close</strong></a></div>";
    document.body.appendChild(div);
    var p = document.createElement('p');
    div.appendChild(p);
    var SearchBarDiv = document.createElement('div');
    SearchBarDiv.id = 'divSearchBar';
    SearchBarDiv.style.display = "none";
    SearchBarDiv.innerHTML = '<img src="images/loader.gif" border="0" alt="Please wait..." />&nbsp;<strong>Please Wait...</strong>';
    SearchBarDiv.style.textAlign = "left";
    SearchBarDiv.style.float = 'left';
    div.appendChild(SearchBarDiv);
}

dialog.resetcontent = function() {
    document.getElementById("divSearchBar").innerHTML = '<img src="images/loader.gif" border="0" alt="Please wait..." />&nbsp;<strong>Please Wait...</strong>';
}


dialog.hide = function() {
    document.getElementById("popupframe").style.display = "none";
    document.getElementById("popupbox").style.display = "none";
    document.getElementById("divSearchBar").style.display = "none";
}

dialog.show = function() {
    document.getElementById("popupframe").style.display = "block";
    document.getElementById("popupbox").style.display = "block";
    document.getElementById("divSearchBar").style.display = "block";
}

dialog.showcustom = function(innercontent) {
    document.getElementById("divSearchBar").innerHTML = innercontent;
    document.getElementById("popupframe").style.display = "block";
    document.getElementById("popupbox").style.display = "block";
    document.getElementById("divSearchBar").style.display = "block";
}

dialog.resize = function() {
    var left = parseInt((document.documentElement.clientWidth / 2) - 70, 10);
    var top = parseInt((document.documentElement.clientHeight / 2) - 40, 10);
    document.getElementById("popupbox").style.top = top + 'px';
    document.getElementById("popupbox").style.left = left + 'px';
    document.getElementById("popupbox").style.width = '150px';
    document.getElementById("popupbox").style.height = '80px';
    document.getElementById("divSearchBar").style.width = '150px';
    document.getElementById("divSearchBar").style.height = '80px';
}

dialog.resizeXY = function(width , height) {
    var left = parseInt((document.documentElement.clientWidth / 2) - (width / 2) , 10);
    var top = parseInt((document.documentElement.clientHeight / 2) - (height/2) , 10);
    document.getElementById("popupbox").style.top = top + 'px';
    document.getElementById("popupbox").style.left = left + 'px';
    document.getElementById("popupbox").style.width = width + 'px';
    document.getElementById("popupbox").style.height = height + 'px';
    document.getElementById("divSearchBar").style.width = width + 'px';
    document.getElementById("divSearchBar").style.height = height + 'px';
}

dialog.originalresize = function() {
    var left = parseInt((document.documentElement.clientWidth / 2) - 380, 10);
    var top = parseInt((document.documentElement.clientHeight / 2) - 100, 10);
    document.getElementById("popupbox").style.top = top + 'px';
    document.getElementById("popupbox").style.left = left + 'px';
    document.getElementById("popupbox").style.width = '760px';
    document.getElementById("popupbox").style.height = '200px';
}
//===============================================================================================

//===============================================================================================
glossary = {
    name: "glossary",
    id: "glossary"
}

glossary.init = function() {
    var width = document.documentElement.clientWidth + document.documentElement.scrollLeft;
    var left = parseInt((document.documentElement.clientWidth / 2) - 400, 10);
    var top = parseInt((document.documentElement.clientHeight / 2) - 200, 10);
    var layer = document.createElement('div');
    layer.style.zIndex = 490;
    layer.id = 'gpopupframe';
    layer.style.display = "none";
    layer.style.position = 'absolute';
    layer.style.top = '0px';
    layer.style.left = '0px';
    //layer.innerHTML = "sdsadsa";
    layer.style.height = document.documentElement.scrollHeight + 'px';
    layer.style.width = width + 'px';
    layer.style.backgroundColor = 'gray';
    layer.style.opacity = '.6';
    layer.style.filter += ('progid:DXImageTransform.Microsoft.Alpha(opacity=50)');
    document.body.appendChild(layer);
    var div = document.createElement('div');
    div.style.zIndex = 491;
    div.id = 'gpopupbox';
    div.style.display = "none";
    div.style.height = '400px';
    div.style.position = (navigator.userAgent.indexOf('MSIE 6') > -1) ? 'absolute' : 'fixed';
    div.style.top = top + 'px';
    div.style.left = left + 'px';
    div.style.width = '760px';
    div.style.backgroundColor = 'white';
    div.style.border = '5px solid #213744';
    div.style.padding = '5px';
    div.innerHTML = "<a href='javascript:glossary.hide();' style='float:right;' ><strong>X</strong></a>";
    document.body.appendChild(div);
    var p = document.createElement('p');
    div.appendChild(p);
    var leftdiv = document.createElement('div');
    var rightdiv = document.createElement('div');
    leftdiv.id = 'glossaryleftdiv';
    rightdiv.id = 'glossaryrightdiv';
    div.appendChild(leftdiv);
    div.appendChild(rightdiv);
}

glossary.hide = function() {
    document.getElementById("gpopupframe").style.display = "none";
    //document.getElementById("gpopupframe").innerHTML = "asdasjdaskhdjkashjkdashjkdhasjkddasdasd";
    document.getElementById("gpopupbox").style.display = "none";
    //document.getElementById("gdivSearchBar").style.display = "none";
}

glossary.show = function() {
    document.getElementById("gpopupframe").style.display = "block";
    document.getElementById("gpopupbox").style.display = "block";
    //document.getElementById("gdivSearchBar").style.display = "block";
}

glossary.showcustom = function(innercontentright , innercontentleft) {
document.getElementById("glossaryrightdiv").innerHTML = innercontentright;
document.getElementById("glossaryleftdiv").innerHTML = innercontentleft;
    document.getElementById("gpopupframe").style.display = "block";
    document.getElementById("gpopupbox").style.display = "block";
    //document.getElementById("gdivSearchBar").style.display = "block";
}

dialog.showcustom2 = function(innercontent) {
	document.getElementById("divSearchBar").style.padding = '10px';
    document.getElementById("divSearchBar").innerHTML = innercontent;
    document.getElementById("popupframe").style.display = "block";
    document.getElementById("popupbox").style.display = "block";
    document.getElementById("divSearchBar").style.display = "block";
}

//===============================================================================================

//===============================================================================================
/*var qTipTag = "a,label,input"; //Which tag do you want to qTip-ize? Keep it lowercase!//
var qTipX = 0; //This is qTip's X offset//
var qTipY = 15; //This is qTip's Y offset//

//There's No need to edit anything below this line//
tooltip = {
    name: "qTip",
    offsetX: qTipX,
    offsetY: qTipY,
    tip: null
}

tooltip.init = function() {
    var tipNameSpaceURI = "http://www.w3.org/1999/xhtml";
    if (!tipContainerID) { var tipContainerID = "qTip"; }
    var tipContainer = document.getElementById(tipContainerID);

    if (!tipContainer) {
        tipContainer = document.createElementNS ? document.createElementNS(tipNameSpaceURI, "div") : document.createElement("div");
        tipContainer.setAttribute("id", tipContainerID);
        document.getElementsByTagName("body").item(0).appendChild(tipContainer);
    }

    if (!document.getElementById) return;
    this.tip = document.getElementById(this.name);
    if (this.tip) document.onmousemove = function(evt) { tooltip.move(evt) };

    var a, sTitle, elements;

    var elementList = qTipTag.split(",");
    for (var j = 0; j < elementList.length; j++) {
        elements = document.getElementsByTagName(elementList[j]);
        if (elements) {
            for (var i = 0; i < elements.length; i++) {
                a = elements[i];
                sTitle = a.getAttribute("title");
                if (sTitle) {
                    a.setAttribute("tiptitle", sTitle);
                    a.removeAttribute("title");
                    a.removeAttribute("alt");
                    a.onmouseover = function() { tooltip.show(this.getAttribute('tiptitle')) };
                    a.onmouseout = function() { tooltip.hide() };
                }
            }
        }
    }
}

tooltip.move = function(evt) {
    var x = 0, y = 0;
    if (document.all) {//IE
        x = (document.documentElement && document.documentElement.scrollLeft) ? document.documentElement.scrollLeft : document.body.scrollLeft;
        y = (document.documentElement && document.documentElement.scrollTop) ? document.documentElement.scrollTop : document.body.scrollTop;
        x += window.event.clientX;
        y += window.event.clientY;

    } else {//Good Browsers
        x = evt.pageX;
        y = evt.pageY;
    }
    this.tip.style.left = (x + this.offsetX) + "px";
    this.tip.style.top = (y + this.offsetY) + "px";
}

tooltip.show = function(text) {
    if (!this.tip) return;
    this.tip.innerHTML = text;
    this.tip.style.display = "block";
}

tooltip.hide = function() {
    if (!this.tip) return;
    this.tip.innerHTML = "";
    this.tip.style.display = "none";
}
//===============================================================================================*/

// http://bontragerconnection.com/ and http://willmaster.com/
// Version: July 28, 2007
var cX = 0; var cY = 0; var rX = 0; var rY = 0;
function UpdateCursorPosition(e){ cX = e.pageX; cY = e.pageY;}
function UpdateCursorPositionDocAll(e){ cX = event.clientX; cY = event.clientY;}
if(document.all) { document.onmousemove = UpdateCursorPositionDocAll; }
else { document.onmousemove = UpdateCursorPosition; }
function AssignPosition(d) {
if(self.pageYOffset) {
	rX = self.pageXOffset;
	rY = self.pageYOffset;
	}
else if(document.documentElement && document.documentElement.scrollTop) {
	rX = document.documentElement.scrollLeft;
	rY = document.documentElement.scrollTop;
	}
else if(document.body) {
	rX = document.body.scrollLeft;
	rY = document.body.scrollTop;
	}
if(document.all) {
	cX += rX; 
	cY += rY;
	}
d.style.left = (cX+10) + "px";
d.style.top = (cY+10) + "px";
}
function HideContent(d) {
if(d.length < 1) { return; }
document.getElementById(d).style.display = "none";
}
function ShowContent(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
dd.style.display = "block";
}
function ReverseContentDisplay(d) {
if(d.length < 1) { return; }
var dd = document.getElementById(d);
AssignPosition(dd);
if(dd.style.display == "none") { dd.style.display = "block"; }
else { dd.style.display = "none"; }
}

function ShowManualContent(d , content) {
    if (d.length < 1) { return; }
    GSIX.Webservice.gsixweb.getGlossPerId(content, function(result) {
        if (result.tables[0].rows != null) {
            //alert('asdasdsada');
            content = "<div class='head11'>" + result.tables[0].rows[0]["term"].toString() + "</div>";
            content = content + "<div class='textcontentmain'>" + result.tables[0].rows[0]["description"].toString() + "</div>";
            document.getElementById(d).innerHTML = content;
        }
    }
        , onFailed);        
    var dd = document.getElementById(d);
    AssignPosition(dd);
    dd.style.display = "block";
}



