﻿// JScript File
var XmlHttp
 
function createXmlHttp()
{ 
    try
    {
        XmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
    catch(e)
    {
        try
        {
            XmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
        catch (e)
        {
            XmlHttp=new XMLHttpRequest();
        }
    }
}

function addEvents(date)
{
    url="addevent.asp?EventDate=" + date + "&Mode=AddEvent"
    window.location= url;
}
function getEvents(date) 
{
  url="displayevents.asp?EventDate=" + date
  window.location= url;
}

function getCalendar(date) 
{
    window.status ='Loading Calendar...';
    document.getElementById('dvCalendar').innerHTML= '<div id="dvmask" style="left:0px;top:0;position:relative;filter:alpha(opacity=50);-moz-opacity:0.5;opacity:50;width:100%;height:175px;z-index:999">' + document.getElementById('dvCalendar').innerHTML + '<div><img src="../images/ajax-loader.gif" style="position:relative;top:-50%;left:45%;z-index:998" />';
   
    createXmlHttp()
    XmlHttp.open("GET", '../calendar/calendar.asp?date=' + date,true);
    XmlHttp.onreadystatechange=function() 
    {
        if (XmlHttp.readyState==4) 
        {
             window.status ='Done';
            document.getElementById('dvCalendar').innerHTML=XmlHttp.responseText
        }
    }
    XmlHttp.send(null);
}

function getUpComingEvents() 
{
    window.status ='Loading Events...';
    document.getElementById('dvUpComingEvents').innerHTML= '<img src="../images/ajax-loader.gif" style="position:relative;left:45%;top:20px;z-index:999" />';  
          
    createXmlHttp()
    XmlHttp.open("GET", 'UpComingEvents.asp',true);
    XmlHttp.onreadystatechange=function() 
    {
        if (XmlHttp.readyState==4) 
        {
            document.getElementById('dvUpComingEvents').innerHTML=XmlHttp.responseText
            window.status ='Done';
        }
    }
    XmlHttp.send(null);
    //return true;
    
}

function getEventsForDate(date) 
{
    window.status ='Loading Events...';
    document.getElementById('dvEventsForDate').innerHTML= '<img src="../images/ajax-loader.gif" />';  
          
    createXmlHttp() 
    XmlHttp.open("GET", 'UpComingEvents.asp?EventDate=' + date + '&EventDateOnly=Y',true);
    XmlHttp.onreadystatechange=function() 
    {
        if (XmlHttp.readyState==4) 
        {
            document.getElementById('dvEventsForDate').innerHTML=XmlHttp.responseText
             document.getElementById('dvEventsForDate').style.height = "auto"
            window.status ='Done';
        }
    }
    XmlHttp.send(null);
    //return true;
}

function updateEvents(PKID,Action) 
{   
    window.status ='Ready to Action';    
    createXmlHttp() 
    XmlHttp.open("GET", 'upDateEvent.asp?PKID=' + PKID + '&Action=' + Action,true);
    XmlHttp.onreadystatechange=function() 
    {
        if (XmlHttp.readyState==4) 
        {
            alert('Action Completed')
            document.getElementById('tbl' + PKID).style.display = 'none'
            
            var intRowCount = parseInt(document.getElementById('RowCount').value);
            intRowCount--;
            document.getElementById('RowCount').value = intRowCount;
            document.getElementById('dvRowCount').innerHTML = intRowCount;
            window.status ='Done';
        }
    }
    XmlHttp.send(null);
    //return true;
}


function getEventsForDateNon()
{
    if(document.getElementById('dvEventsForDate').innerHTML !='')
    {
        document.getElementById('dvEventsForDate').innerHTML= '';  
        document.getElementById('dvEventsForDate').style.height = "0px"
    }
}

