﻿// This is the main function that controls the dynamic fetch.  
// It takes as a parameter the ID of the popup we want
    function popupGetHTML(PopupBoxID)
    { 
        var view = PopupBoxID;
        var url;
        
        popupHttp=popupGetXmlHttpObject();
        if (popupHttp==null)
          {
          alert ("Your browser does not support AJAX!");
          return;
          } 
          
        // Set the default class on the popup box just in case we've already run one of the doublewide boxes on this page
        document.getElementById('popup_notification').className='popup_notification';

        switch (view) {
            case 'popup_notification':
                url="/login/login_popup.asp";
                break;
                
            case 'comingsoon':
                url="/ajax/popup_comingsoon.asp";
                break;
                
            case 'formerrors':
                url="/ajax/popup_formerrors.asp";
                break;
                
            case 'betawelcome':
                url="/ajax/popup_betawelcome.asp";
                document.getElementById('popup_notification').className='popup_notification_doublewide';
                break;
                
            case 'pleaseupgrade':
                url="/ajax/popup_pleaseupgrade.asp";
                break;
                
            case 'popup_couponCode':
                url="/ajax/popup_couponCode.asp";
                break;
                
            default:
                url='';
                break;
        }
        url = url + '?sid=' + Math.random();
        //prompt('', url);
        popupHttp.onreadystatechange=popupStateChanged;
        popupHttp.open("GET",url,true);
        popupHttp.send(null);
        
        popUpBox("popup_notification");
    }

// This function watches the XmlHttpObject and reacts when it gets back results
    function popupStateChanged() 
    { 
        

        if (popupHttp.readyState==4)
        { 
        document.getElementById("popup_notification").innerHTML=popupHttp.responseText;
        
        }
    }

// This function creates and returns a XmlHttpObject which we will use to get stuff after page loads
    function popupGetXmlHttpObject()
    {
        var xmlHttp=null;
        try
          {
          // Firefox, Opera 8.0+, Safari
          xmlHttp=new XMLHttpRequest();
          }
        catch (e)
          {
          // Internet Explorer
          try
            {
            xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            }
          catch (e)
            {
            xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
          }
        return xmlHttp;
    }

