﻿


var windowW=750; // wide
var windowH=600; // high
var windowX = 50; // from left
var windowY = 50; // from top
var windowTitle = "";

 // set this to true if the popup should close
// upon leaving the launching page; else, false
var autoclose = true;

// do not edit below this line
s = "width="+windowW+",height="+windowH+",scrollbars=yes,menubar=no,resizable=yes,toolbar=no,location=no,status=no";
var beIE = document.all?true:false;

function openFramelessWindow(urlPop, title)
{
    urlPop = decodeURIComponent(urlPop)

var objSplit = urlPop.split(':');

    if(urlPop.substring(5,0) == "Error")
        urlPop = "/Error.aspx";
    if(objSplit[0] != 'https'){
       if (urlPop.substring(7,0) != "http://")
        urlPop = "http://" + urlPop;
    }            
    if (beIE) {
        NFW = window.open("","popFrameless",""+s);
        NFW.blur();
        window.focus();
        NFW.resizeTo(windowW,windowH);
        NFW.moveTo(windowX,windowY);
        var frameString=""+
        "<html>"+
        "<head>"+
        "<title>"+title+"</title>"+
        "</head>"+
        "<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
        "<frame name='top' src=\""+urlPop+"\" scrolling=auto>"+
        "<frame name='bottom' src='about:blank' scrolling='no'>"+
        "</frameset>"+
        "</html>";
        NFW.document.open();
        NFW.document.write(frameString);
        NFW.document.close();
    }else {
        NFW = window.open("","popFrameless","scrollbars,"+s);
        NFW.blur();
        window.focus();
        NFW.resizeTo(windowW,windowH);
        NFW.moveTo(windowX,windowY);
        var frameString=""+
        "<html>"+
        "<head>"+
        "<title>"+title+"</title>"+
        "</head>"+
        "<frameset rows='*,0' framespacing=0 border=0 frameborder=0>"+
        "<frame name='top' src=\""+urlPop+"\" scrolling=auto>"+
        "<frame name='bottom' src='about:blank' scrolling='no'>"+
        "</frameset>"+
        "</html>";
        NFW.document.open();
        NFW.document.write(frameString);
        NFW.document.close();
    }
    NFW.focus();
    if (autoclose) {
        window.onunload = function(){
            NFW.close();
        }
    }
  }

function openFrameless(urlPop, title) {
    windowTitle = title;

    GetDecrUrl(urlPop);
}


/************** web service calls ***************/
var xmlhttp;

function GetDecrUrl(str)
{
    xmlhttp=GetXmlHttpObject();
    if (xmlhttp==null)
      {
      alert ("Your browser does not support AJAX!");
      return;
      }
    //var url="../GetDecrUrl.aspx";
    var url="/GetDecrUrl.aspx";
    url=url+"?Key="+str;
    
    xmlhttp.onreadystatechange=stateChanged;
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function stateChanged()
{
    if (xmlhttp.readyState==4)
    {
    
        var DecrUrl;
        var xmlDoc=xmlhttp.responseXML.documentElement;

        if(xmlDoc.childNodes.length> 0){
        
            if(xmlDoc.childNodes[0].nodeName == "Error" && xmlDoc.childNodes[0].childNodes[0].nodeValue == 1)
                DecrUrl = "Error";
            else
                DecrUrl = encodeURIComponent( xmlDoc.childNodes[1].childNodes[0].nodeValue);
                
        }

        openFramelessWindow(DecrUrl, windowTitle);
    }
}

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;
}

/************** web service calls ***************/
