﻿
/**********************************************************************************/

var settings = {
    tl: { radius: 12 },
    tr: { radius: 12 },
    bl: { radius: 12 },
    br: { radius: 12 },
    antiAlias: true
}

    var browser = new Browser();

    var IE = browser.isIE;
    var ie = IE;
    var nn6 = browser.isFX;  

    var isdrag = false;
    var x = 0, y = 0;
    var dobj;

    function movemouse(e) {
        if (isdrag) {
            dobj.style.left = nn6 ? tx + e.clientX - x + "px" : tx + event.clientX - x + "px";
            dobj.style.top = nn6 ? ty + e.clientY - y + "px" : ty + event.clientY - y + "px";
            
            document.cookie = "dlgleft=" + dobj.style.left;
            document.cookie = "dlgtop=" + dobj.style.top;
            
            document.onmouseup = new Function("isdrag=false");
            
            return false;
        }
    }

    function selectmouse(e) {
        
        var fobj = nn6 ? e.target : window.event.srcElement;
        var topelement = nn6 ? "HTML" : "BODY";

        if (fobj.className && fobj.tagName) {

            while (fobj.tagName != topelement && fobj.className != "movecursor") {
                fobj = nn6 ? fobj.parentNode : fobj.parentElement;
            }

        }
        
        if (fobj.className == "movecursor") {
            isdrag = true;
            dobj = document.getElementById("svpopup");
            tx = parseInt(dobj.style.left + 0);
            ty = parseInt(dobj.style.top + 0);
            x = nn6 ? e.clientX : window.event.clientX;
            y = nn6 ? e.clientY : window.event.clientY;
            document.onmousemove = movemouse;
            return false;
        }
    }

    function svPopupClose() {

        var el;

        if (document.getElementById("bk")) {
            el = document.getElementById("bk");
            el.style.visibility = "hidden";
        }

        if (document.getElementById("svpopup")) {
            document.getElementById("svpopup").style.display = "none";

            document.onmousemove = getMouseXY;
        }
    }
    function svPopupClose2() {

        document.getElementById("svpopup").style.display = "none";
        document.onmousemove = getMouseXY;
    }

    function svPopupShow(xx,yy,w, h,cont) {

        document.getElementById("svpopup").style.display = "block";
        
        
        document.getElementById("svpopup").style.width = w + "px";
        document.getElementById("svpopup").style.height = h + "px";

        document.getElementById("svpopup").style.left = xx + "px";
        document.getElementById("svpopup").style.top = yy + "px";

        if (cont != "") {
            document.getElementById("cont").innerHTML = cont;
        }
        //curvyCorners(settings, "#svpopup");

     }

     try {
         document.onmousedown = selectmouse;
         document.onmouseup = new Function("isdrag=false;");
     } catch (e) { }
/*************************************************************************************/

         function overlay(bg,w) {
                      
             if (document.getElementById("bk")) {
                 var el = document.getElementById("bk");

                 el.style.display = "block";

                 el.style.height = getDocHeight() + "px";
                 el.style.width = getDocWidth() + "px";

                 if (browser.isIE) {
                     if (w) {
                          el.style.width = (getDocWidth() - w) + "px";
                       
                     }else{
                         if (browser.version == 8) {
                             el.style.width = (getDocWidth() - 22) + "px";
                         } else {
                             el.style.width = (getDocWidth() - 18) + "px";
                         }
                     }

                     el.setAttribute("class", "modalPageIE");

                 } else if (browser.isFX) {
                 
                     el.setAttribute("class", "modalPageFX");
                 }


                 if (bg) {
                     el.style.backgroundColor = bg;
                 }

                 el.style.visibility = (el.style.visibility == "visible") ? "hidden" : "visible";
             }
         }

         function getDocHeight() {
             var D = document;
             return Math.max(
            Math.max(D.body.scrollHeight, D.documentElement.scrollHeight),
            Math.max(D.body.offsetHeight, D.documentElement.offsetHeight),
            Math.max(D.body.clientHeight, D.documentElement.clientHeight)
            );
         }

         function getDocWidth() {
             var D = document;
             return Math.max(
            Math.max(D.body.scrollWidth, D.documentElement.scrollWidth),
            Math.max(D.body.offsetWidth, D.documentElement.offsetWidth),
            Math.max(D.body.clientWidth, D.documentElement.clientWidth)
            );
         }
          
         function Browser() {

             try {
                 var ua, s, i;

                 this.isIE = false;
                 this.isFX = false;
                 this.version = null;

                 ua = navigator.userAgent;

                 s = "MSIE";
                 if ((i = ua.indexOf(s)) >= 0) {
                     this.isIE = true;
                     this.version = parseFloat(ua.substr(i + s.length));
                     return;
                 }

                 s = "Firefox";
                 if ((i = ua.indexOf(s)) >= 0) {
                     this.isFX = true;
                     this.version = parseFloat(ua.substr(i + s.length));
                     return;
                 }

                 // Treat any other "Gecko" browser as NS 6.1.

                 s = "Gecko";
                 if ((i = ua.indexOf(s)) >= 0) {
                     this.isFX = true;
                     this.version = 6.1;
                     return;
                 }
             } catch (e) {
             } 
         
         }


         // Detect if the browser is IE or not.
         // If it is not IE, we assume that the browser is NS.
         //var IE = document.all ? true : false
         // If NS -- that is, !IE -- then set up for mouse capture
        // if (!IE) document.addEventListener('mousemove', getMouseXY, false);

         // Set-up to use getMouseXY function onMouseMove
        // document.onmousemove = getMouseXY;

         // Temporary variables to hold mouse x-y pos.s
         var tempX = 0
         var tempY = 0

         if (browser.isFX) {
            document.addEventListener("mousemove", getMouseXY,false); 
            //document.captureEvents(Event.MOUSEMOVE)
              
         } else if (browser.isIE){
             // Set-up to use getMouseXY function onMouseMove
             document.onmousemove = getMouseXY;
         }

         // Main function to retrieve mouse x-y pos.s

         function getMouseXY(e) {
            
             if (browser.isIE) { // grab the x-y pos.s if browser is IE
                 if (event) {
                     if (document.body) {
                         tempX = event.clientX + document.body.scrollLeft;
                     }
                     if (document.body) {
                         tempY = event.clientY + document.body.scrollTop;
                     }
                  }
             } else {  // grab the x-y pos.s if browser is NS

             //alert(tempX);                     
                 tempX = e.pageX;
                 tempY = e.pageY;
                
             }
             // catch possible negative values in NS4
             if (tempX < 0) { tempX = 0 }
             if (tempY < 0) { tempY = 0 }
             // show the position values in the form named Show
             // in the text fields named MouseX and MouseY
             return true
         }

         function Trim(s) {
             // Remove leading spaces and carriage returns

             while ((s.substring(0, 1) == ' ') || (s.substring(0, 1) == '\n') || (s.substring(0, 1) == '\r')) {
                 s = s.substring(1, s.length);
             }

             // Remove trailing spaces and carriage returns

             while ((s.substring(s.length - 1, s.length) == ' ') || (s.substring(s.length - 1, s.length) == '\n') || (s.substring(s.length - 1, s.length) == '\r')) {
                 s = s.substring(0, s.length - 1);
             }
             return s;
         }
 
         function getCookie(name) {

             var cks = new Array();
             var dc = document.cookie;
             var s = "", val = null;

             cks = dc.split(";");

             for (var i = 0; i < cks.length; i++) {
                 s = cks[i];
                 if (Trim(s.substr(0, s.indexOf("="))) == Trim(name)) {
                     val = s.substr(s.indexOf("=") + 1, s.length);
                     break;
                 }

             }
             return val;

         }

         function setCookie(name, value) {
             var expires = expdate;
             if (!expires) expires = new Date();
             document.cookie = name + "=" + escape(value) +
             "; expires=" + expires.toGMTString() + "; path=/";
         }



         function GetWidth() {

             var x = 0;

             if (self.innerHeight) x = self.innerWidth;

             else if (document.documentElement && document.documentElement.clientHeight) x = document.documentElement.clientWidth;

             else if (document.body) x = document.body.clientWidth;

             return x;

         }

         function GetHeight() {

             var y = 0;

             if (self.innerHeight) y = self.innerHeight;

             else if (document.documentElement && document.documentElement.clientHeight) y = document.documentElement.clientHeight;

             else if (document.body) y = document.body.clientHeight;

             return y;

         }

