﻿// JScript File
var xmlHttpCRMPopUp
var UserID;
function GetXmlHttpObject()
{ 

    var objXMLHttp=null
    if (window.XMLHttpRequest)
    {
        objXMLHttp=new XMLHttpRequest()
    }
    else if (window.ActiveXObject)
    {
        objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
    }
   
    return objXMLHttp
}

function SubmitPopUp(Choice,DateAdd)
{
    var currentTime = new Date()
    var month = currentTime.getMonth() + 1
    var day = currentTime.getDate()
    var year = currentTime.getFullYear()
    var hours = currentTime.getHours()
    var minutes = currentTime.getMinutes()
    var seconds = currentTime.getSeconds()        
    var temp = month + "-" + day + "-" + year + "-" + hours + "-" + minutes + "-" + seconds;  
    
    xmlHttpCRMPopUp=GetXmlHttpObject()
    if (xmlHttpCRMPopUp==null)
    {
        alert ("Browser does not support HTTP Request")
        return
    }
    var url="AjaxRequests/AJAXCRMPopUp.aspx?temp="+temp+"&UserID="+UserID+"&Choice="+Choice+"&CenterCode="+CenterCodeCRM +"&DateAdd="+DateAdd; 
    xmlHttpCRMPopUp.onreadystatechange=SubmitPopUp_Callback
    xmlHttpCRMPopUp.open("GET",url,true)
    xmlHttpCRMPopUp.send(null)        
}

function SubmitPopUp_Callback()
{
    if (xmlHttpCRMPopUp.readyState==4 || xmlHttpCRMPopUp.readyState=="complete")
	{	
	    if (xmlHttpCRMPopUp.status == 200)      
	    { 
	        ClearCRMPopUp();
	    }
	}
}

function UpdatePopUpStatus()
{
    var Choice ;
    
    if(document.getElementById('radio1').checked)
    {
        Choice = 2;
        //document.frames[0].LoadCRMReg(0013);
        location.href="memberregistration.aspx";
    }
    else if(document.getElementById('radio2').checked)
    {
        Choice = 2;
        location.href="FunRewards.aspx";
        //window.open('FunRewards.aspx','FunCinemas',  'width=570, height=550, location=no, menubar=no, status=no, toolbar=no, scrollbars=yes, resizable=no')
    }
    else if(document.getElementById('radio3').checked)
    {
        Choice = 2;
    }
    else if(document.getElementById('radio4').checked)
    {
        Choice = 1;
    }
    SubmitPopUp(Choice,1);
}

function ShowCRMPopUp(UserID1,CenterCode1)
{
    UserID = UserID1;
    var div_temp = document.getElementById('div_CenterPop');
    div_temp.style.height = document.body.scrollHeight + 'px';//document.body.parentNode.scrollHeight + 'px';
    div_temp.style.display = 'block';
   
    //DarkenPage();
    ShowCRMPopUpPanel();
   
}

function ClearCRMPopUp()
{
    var div_temp = document.getElementById('div_CRMPopUp');
    div_temp.style.display = 'none';
    div_temp = document.getElementById('div_CenterPop');
    div_temp.style.display = 'none';
    //LightenPage();
}


function ShowCRMPopUpPanel()
{
    var div_temp = document.getElementById('div_CRMPopUp');
    
    // w is a width of the newsletter panel
    w = 600;
    // h is a height of the newsletter panel
    h = 400;
    
    // get the x and y coordinates to center the newsletter panel
    xc = Math.round((document.body.clientWidth/2)-(w/2))
    //yc = Math.round((document.body.clientHeight/2)-(h/2))
	yc = Math.round((650/2)-(h/2))
    
    // show the newsletter panel
    div_temp.style.left = xc + "px";
    div_temp.style.top  = yc + "px";
    div_temp.style.display = 'block';
    
}

/*
function DarkenPage()
{
   var div_temp = document.getElementById('div_CenterPop');
   div_temp.style.height = document.body.scrollHeight + 'px';//document.body.parentNode.scrollHeight + 'px';
   div_temp.style.display = 'block';
   
}

// this function removes the dark screen and the page is light again
function LightenPage()
{
    var div_temp = document.getElementById('div_CenterPop');
    div_temp.style.display = 'none';
}*/

