﻿//Global Variables
var LastVisitedPage;
// JScript File
var SelectedMenu;
//Calendar variable
var cal1x = new CalendarPopup("testdiv1");

function GetCurrentMenuImage(menuid)
{
    document.getElementById(menuid).style.backgroundPosition = "top";
    SelectedMenu = menuid;
}

function RollOverMenuMouseOver(menuid)
{
    if(menuid != SelectedMenu)
    {
    
      document.getElementById(menuid).style.cursor = "pointer";
      document.getElementById(menuid).style.backgroundPosition = "top";
    }
}

function RollOverMenuMouseOut(menuid)
{
    if(menuid != SelectedMenu)
    {
      document.getElementById(menuid).style.cursor = "pointer";
      document.getElementById(menuid).style.backgroundPosition = "bottom";      
    }
}

function RedirectToPage(nextpage)
{
    window.location = nextpage;
}



function runSlideShow(pagename) {
if(pagename == "index")
{
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = preLoad[j].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
j = j + 1;
if (j > (p - 1)) j = 0;
t = setTimeout("runSlideShow('index')", slideShowSpeed);
}
else if (pagename == "gallery")
{
if (document.all) {
document.images.SlideShow.style.filter="blendTrans(duration=2)";
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)";
document.images.SlideShow.filters.blendTrans.Apply();
}
document.images.SlideShow.src = offpreLoad[offj].src;
if (document.all) {
document.images.SlideShow.filters.blendTrans.Play();
}
offj = offj + 1;
if (offj > (poff - 1)) offj = 0;
t = setTimeout("runSlideShow('gallery')", slideShowSpeed);
}
}
//  End -->

/// AJAX FUNCTIONS //////////////////////////////////

function AjaxPages() {
    if (LastVisitedPage == "offices.aspx") {        
        GetAjaxFile("appadd.aspx", "totalbar", true);
        return;
    }
    if (LastVisitedPage == "doctors.aspx") {
        GetAjaxFile("doctorsup.aspx", "leftupper", true);
        GetAjaxFile("appadd.aspx", "totalbar", true);
        return;
    }
    if (LastVisitedPage == "gallery.aspx") {
        GetAjaxFile("galup.aspx", "leftupper", true);
        GetAjaxFile("appadd.aspx", "totalbar", true);
        return;
    }
    if (LastVisitedPage == "appointments.aspx") {
        GetAjaxFile("appsup.aspx", "leftupper", true);
        //GetAjaxFile("appadd.aspx", "totalbar", true);
          
        return;
    }
    if (LastVisitedPage == "viewappointment.aspx") {
        GetAjaxFile("appointments.html", "leftupper", true);
        GetAjaxFile("delapps.aspx", "totalbar", true);
        return;
    }

    if (LastVisitedPage == "specialities.aspx") {
        GetAjaxFile("specialup.aspx", "leftupper", true);
        GetAjaxFile("appadd.aspx", "totalbar", true);
        return;
    }
}

function GetAjaxFile(proname, contentId, isLoading) {
    LastPageVisited = proname;
    if (isLoading != "false")
        ShowLoading(contentId);
    var xmlHttp;
    try {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            //Uncomment the following lines when you go live..
            //Need to debugging to see the exact error as it occurrs..
            if (xmlHttp.status != 200) {
                GetAjaxFile("noexist.aspx", contentId);
                return;
            }
            if (!document.getElementById(contentId)) {
                return;
            }
            document.getElementById(contentId).innerHTML = xmlHttp.responseText;
            if (proname == 'appsup.aspx') {
                initializeGoogle();
            }
        }
    }

    if (proname.indexOf('?') != -1) {
        xmlHttp.open("GET", proname + "&seed=" + Math.random(), true);
    }
    else {
        xmlHttp.open("GET", proname + "?" + Math.random(), true);
    }
    xmlHttp.send(null);
}

function ShowLoading(divId) {
    document.getElementById(divId).innerHTML = "<img alt='loading' src='images/busy.gif'></img><br><br>Please wait. Page is loading...";
}

function __doPostBackButton001() {
    if (LastPageVisited.indexOf('?') != -1) {
        LastPageVisited = LastPageVisited.substring(0, LastPageVisited.indexOf('?'));
    }
    var poststr = "__EVENTTARGET=btnMsg" +
                  "&txtName=" + document.getElementById('txtName').value +
                  "&txtPhone=" + document.getElementById('txtPhone').value +
                  "&txtDate=" + document.getElementById('txtDate').value + 
                  "&txtMsg=" + document.getElementById('txtMsg').value;
    GetAjaxFilePost("appsup.aspx", poststr, "leftupper");
}

function __doPostBackButton002() {
    if (LastPageVisited.indexOf('?') != -1) {
        LastPageVisited = LastPageVisited.substring(0, LastPageVisited.indexOf('?'));
    }
    var poststr = "__EVENTTARGET=btnMsg";
    document.getElementById("leftupper").innerHTML = "";
    GetAjaxFilePost("delapps.aspx", poststr, "totalbar");
}

function GetAjaxFilePost(proname, parameters, contentId) {

    LastPageVisited = proname;
    ShowLoading(contentId);
    var xmlHttp;
    try {
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) {
                alert("Your browser does not support AJAX!");
                return false;
            }
        }
    }
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4) {
            //Uncomment the following lines when you go live..
            //Need to debugging to see the exact error as it occurrs..
            if (xmlHttp.status != 200) {
                GetAjaxFile("noexist.aspx", contentId);
                return;
            }
            if (!document.getElementById(contentId)) {
                return;
            }
            document.getElementById(contentId).innerHTML = xmlHttp.responseText;
        }
    }

    xmlHttp.open('POST', proname, true);
    xmlHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    xmlHttp.setRequestHeader("Content-length", parameters.length);
    xmlHttp.setRequestHeader("Connection", "close");
    xmlHttp.send(parameters);
}