// Div Pop-up Functions
var posx;var posy;
window.onMouseMove = mouser;
function mouser(event){posx = event.clientX;posy = event.clientY;}
function divpopup(meth,url,qStr,divID,toclick,doload,rload){if(GetPopDivElm('minimized-' + divID)){MaximizePopDiv(divID);}if(!rload){if(GetElm(divID)){return false;}}if(meth.length==0||url.length==0||divID.length==0){return false;}else{CreatePopDiv(divID);}if(toclick){MoveDivToClick(divID);}var xmlhttp=null;if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest();}if(window.ActiveXObject){xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");}if(xmlhttp==null){return false;}xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==1){if(doload){dispload(divID,"","w");}else{if(GetPopDivElm('popDivTtl_'+divID)){GetPopDivElm('popDivTtl_'+divID).innerHTML='<table cellpadding="2" cellspacing="0" border="0"><tr><td style="color:#000000;"><b>Loading...</b></td><td><img src="popdiv/images/loading_small.gif" border="0"/></td></tr></table>';}}}if(xmlhttp.readyState==4){GetPopDivElm(divID).innerHTML=xmlhttp.responseText;}};xmlhttp.open(meth,url+'?d='+divID+qStr,true);xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlhttp.send();}
function CreatePopDiv(divID){if(!GetPopDivElm(divID)){$("body").append("<div id=\"" + divID + "\" name=\"" + divID + "\" class=\"PopDiv\"></div>");}BringToFront(divID);}
function dispload(divID,Msg,dw){var loadingpic = '<center><div class="loadingpic"></div></center>';var loadingwindow = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" onmousedown=\"javascript:BringToFront('" + divID + "');\">";loadingwindow += "<tr><td class=\"PopDivFrameTopLeft\"></td><td class=\"PopDivFrameTop\"></td><td class=\"PopDivFrameTopRight\"></td></tr>";loadingwindow += "<tr><td class=\"PopDivFrameLeft\">&nbsp;&nbsp;&nbsp;</td><td class=\"PopDivFrameBg\">";loadingwindow += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width: 100%;\">";loadingwindow += "<tr><td class=\"popDivTopBar\" onmousedown=\"return MoveDiv('" + divID + "');\" onmouseup=\"return StopDiv('" + divID + "');\">";loadingwindow += "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" style=\"width: 100%;\">";loadingwindow += "<tr><td style=\"text-align: left; font-size: 14px; color: #000000;\"><b>Loading...</b></td>";loadingwindow += "<td style=\"text-align: right;\"><input type=\"button\" class=\"popDivCloseBut\" value=\" \" title=\"close\" onclick=\"javascript:ClosePopDiv('" + divID + "');\" /></td>";loadingwindow += "</tr>";loadingwindow += "</table>";loadingwindow += "</td></tr>";loadingwindow += "<tr><td style=\"width: 200px; height: 100px; vertical-align: middle; text-align: center;\">" + loadingpic + "</td></tr>";loadingwindow += "</table>";loadingwindow += "</td><td class=\"PopDivFrameRight\">&nbsp;&nbsp;&nbsp;</td></tr>";loadingwindow += "<tr><td class=\"PopDivFrameBottomLeft\"></td><td class=\"PopDivFrameBottom\"></td><td class=\"PopDivFrameBottomRight\"></td></tr>";loadingwindow += "</table>";if(dw=="d"){GetPopDivElm(divID).innerHTML = "<center>" + loadingpic + "<br/><b>" + Msg + "</b></center>";}else{if(dw=="w"){GetPopDivElm(divID).innerHTML = loadingwindow;}}}
function dispload_small(divID){var loadingpic = '<div class="loadingpic_small"></div>';GetPopDivElm(divID).innerHTML = loadingpic;}
function MoveDivToClick(divID){if (!posx){posx = 150;}if (!posy){posy = 50;}var moveX = posx;var moveY = posy;GetPopDivElm(divID).style.left = moveX + "px";GetPopDivElm(divID).style.top = moveY + "px";}
function BringToFront(divID){DropDivsZIndex(divID);$("#" + divID).css({"z-index":7778});}
function DropDivsZIndex(divID){$(".PopDiv").each(function(){if($(this).attr("id") != divID){var DivZIndex = $(this).css('z-index');var newDivZIndex = DivZIndex - 1;$(this).css({"z-index":newDivZIndex});}});$(".PopDivMin").each(function(){if($(this).attr("id") != divID){var DivZIndex = $(this).css('z-index');var newDivZIndex = DivZIndex - 1;$(this).css({"z-index":newDivZIndex});}});}
function MoveDiv(divID){dsblSlct(document.body,divID);var DivClkLft = posx - GetPopDivElm(divID).offsetLeft;var DivClkRgt = posy - GetPopDivElm(divID).offsetTop;document.onmousemove = MovemyDiv;function MovemyDiv(){var moveX = posx - DivClkLft;var moveY = posy - DivClkRgt;GetPopDivElm(divID).style.left = moveX + "px";GetPopDivElm(divID).style.top = moveY + "px";document.onmouseup = function(){enblSlct(document.body,divID);document.onmousemove = function(){return false;};};}}
function StopDiv(divID){enblSlct(document.body,divID);document.onmousemove = function(){return false;};}
function ResizeDiv(divID){divID = 'popDivCell_' + divID;dsblSlct(document.body,divID);var currposx = posx;var currposy = posy;var startwidth = getPopDivStyle(GetPopDivElm(divID),'width');startwidth = (startwidth.replace('px','')) * 1;var startheight = getPopDivStyle(GetPopDivElm(divID),'height');startheight = (startheight.replace('px','')) * 1;if(navigator.appName != 'Opera' && navigator.appName != 'Microsoft Internet Explorer'){if(navigator.userAgent.indexOf('Firefox') <= 0){var actWidth = GetPopDivElm(divID).clientWidth;var actHeight = GetPopDivElm(divID).clientHeight;var scrWidth = GetPopDivElm(divID).scrollWidth;var scrHeight = GetPopDivElm(divID).scrollHeight;if(actWidth < scrWidth){startheight+= 17;}if(actHeight < scrHeight){startwidth+= 17;}}}document.onmousemove = ResizemyDiv;function ResizemyDiv(){var newposx = posx;var newposy = posy;var changedamtx = newposx - currposx;var changedamty = newposy - currposy;var newwidth = startwidth + changedamtx;var newheight = startheight + changedamty;if(newwidth > 200){GetPopDivElm(divID).style.width = newwidth + 'px';}if(newheight > 100){GetPopDivElm(divID).style.height = newheight + 'px';}document.onmouseup = function(){enblSlct(document.body,divID);document.onmousemove = function(){return false;};};}}
function MinimizePopDiv(divID,divTitle){var minimizedwindow = "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" onmousedown=\"javascript:BringToFront('minimized-" + divID + "');\">";minimizedwindow += "<td class=\"PopDivFrameBgMin\">";minimizedwindow += "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width: 100%;\">";minimizedwindow += "<tr><td class=\"popDivTopBarMin\">";minimizedwindow += "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\" style=\"width: 100%;\">";minimizedwindow += "<tr><td style=\"text-align: left; font-size: 11px; color: #000000;\"><b>" + divTitle + "</b></td>";minimizedwindow += "<td style=\"text-align: right; width: 20px;\"><input type=\"button\" class=\"popDivMaximizeBut\" value=\" \" title=\"maximize\" onclick=\"javascript:MaximizePopDiv('" + divID + "');\" /></td>";minimizedwindow += "<td style=\"text-align: right; width: 20px;\"><input type=\"button\" class=\"popDivCloseBut\" value=\" \" title=\"close\" onclick=\"javascript:ClosePopDiv('" + divID + "');ClosePopDivMin('minimized-" + divID + "');\" /></td>";minimizedwindow += "</tr>";minimizedwindow += "</table>";minimizedwindow += "</td></tr>";minimizedwindow += "</table>";minimizedwindow += "</td>";minimizedwindow += "</table>";var mycount = $(".PopDivMin").length;var mydist = mycount * 25;GetPopDivElm(divID).style.display = 'none';$("body").append("<div id=\"minimized-" + divID + "\" class=\"PopDivMin\"></div>");GetPopDivElm('minimized-' + divID).style.left = "0px";GetPopDivElm('minimized-' + divID).style.bottom = mydist + "px";GetPopDivElm('minimized-' + divID).innerHTML = minimizedwindow;}
function MaximizePopDiv(divID){ClosePopDivMin('minimized-' + divID);BringToFront(divID);GetPopDivElm(divID).style.display = 'block';}
function ClosePopDiv(divID){$('div').remove('#' + divID);}
function ClosePopDivMin(divID){var thisDivBottom = parseFloat($('#' + divID).css('bottom'));$(".PopDivMin").each(function(){var DivBottom = parseFloat($(this).css('bottom'));if(DivBottom > thisDivBottom){var newDivBottom = DivBottom-25;}$(this).css({"bottom":newDivBottom+"px"});});$('div').remove('#' + divID);}
function ClearPopDivs(){$("div").remove(".PopDiv");}
function dsblSlct(trgt,divID){divID = divID.replace('popDivCell_','');if (typeof trgt.onselectstart!="undefined"){trgt.onselectstart=function(){return false};}else if (typeof trgt.style.MozUserSelect!="undefined"){trgt.setAttribute("class","moznone");}else{trgt.onmousedown=function(){return false};trgt.style.cursor = "default";}GetPopDivElm(divID).setAttribute("class","PopDivNotSelect");}
function enblSlct(trgt,divID){divID = divID.replace('popDivCell_','');if (typeof trgt.onselectstart!="undefined"){trgt.onselectstart=function(){return true};}else if (typeof trgt.style.MozUserSelect!="undefined"){trgt.setAttribute("class","moztext");}else{trgt.onmousedown=function(){return true};trgt.style.cursor = "select";}GetPopDivElm(divID).setAttribute("class","PopDiv");}
function GetPopDivElm(fld){return document.getElementById(fld);}
function getPopDivStyle(oElm, strCssRule){var strValue = "";if(document.defaultView && document.defaultView.getComputedStyle){strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);}else if(oElm.currentStyle){strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){return p1.toUpperCase();});strValue = oElm.currentStyle[strCssRule];}return strValue;}
