﻿// Client side functions.
/// <reference path="jquery.validate.js" />
///// <reference path="/altwebsite/Jquery/FunctinalDemoJscript/ui.core.js" />
///// <reference path="/altwebsite/Jquery/FunctinalDemoJscript/ui.datepicker.js" />

function confirmSubmit() {
    if(Page_ClientValidate()) 
{
        if (confirm("Are you sure you want to submit the data.You can not undo this operation.") == true)
            return true;
        else
            return false;
    }
}



// Hook up application handlers

var app = Sys.Application;

app.add_init(ApplicationInit);
app.add_load(ApplicationLoad);

//===========================================================================================================================

function ApplicationInit(sender) {


    var prm = Sys.WebForms.PageRequestManager.getInstance();
    //if (!prm.get_isInAsyncPostBack()) {
        prm.add_initializeRequest(InitializeRequest);
        prm.add_beginRequest(BeginRequest);
        prm.add_pageLoading(PageLoading);
        prm.add_pageLoaded(PageLoaded);
        prm.add_endRequest(EndRequest);
  //  }
}

//===========================================================================================================================

function ApplicationLoad(sender, args) {

    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox1").Watermark("Name");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox2").Watermark("Company");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox3").Watermark("Address");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox4").Watermark("City");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox5").Watermark("State");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox6").Watermark("Zipcode");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox7").Watermark("Email");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox8").Watermark("Phone");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox9").Watermark("Fax");


    
    
    
    // for NonStagenet form

    //nonStageNetBtnClose

    // Assign calender to planned date textbox
    $('#ctl00_ctl00_SubApp1_SubContent_FormView1_plan_dateTextBox').datepicker({
        changeMonth: true,
        changeYear: true
    });
    
    
    $("#nonStageNetBtnClose").click(function() {

        $("#errorDiv").slideUp("slow", function() {
           
            $("#mainDiv").removeClass("modalpopupNonStageNet");
        });

    });


    $("#ctl00_ctl00_SubApp1_SubContent_FormView1_InsertButton").click(function(event) {



    });

 // DAILY SCHEDULE EVENTS.

           
    // For closing the credit popUp

    

    $("#ctl00_ContentPlaceHolder1_eventdailybtnClose").click(function () {


        $('#ctl00_ContentPlaceHolder1_pnlPopup').slideUp("slow", callback);

        return false;
    });


    // For closing the meeting popUp

    $("#ctl00_ContentPlaceHolder1_newMeetingbtnNowClose").click(function () {

        $('#ctl00_ContentPlaceHolder1_NewMeetingPanel').slideUp("slow", callback);

        return false;

    });

    
         //callback function to bring a hidden box back
		function callback(){

		    $("#dailyScheduleOuter").removeClass("modalpopupDailySchedule");

		  
		  };

		 
       
 // EVENTS FOR DAILY SHCEDULE BY ROOM

		  // Closing the meeting pop window

		  $("#ctl00_ContentPlaceHolder1_btnMeetingClose").click(function () {

		      $('#ctl00_ContentPlaceHolder1_NewMeetingPanel').slideUp("slow", callback);

		      return false;

		  });

		  // for closing the class pop up window


		  $("#ctl00_ContentPlaceHolder1_btnClassClose").click(function () {

		      $('#ctl00_ContentPlaceHolder1_Meetingpnlpopup').slideUp("slow", callback);

		      return false;

		  });
          
          
} // end of ApplicationLoad

//===========================================================================================================================
var postbackElement;
var divElem = 'AlertDiv';
var dailyDiv = 'dailyScheduleOuter'

//===========================================================================================================================
     function InitializeRequest(sender, args) {
        
       
        
        postbackElement = args.get_postBackElement().id;
        
        //alert(postbackElement);
      

        // LMS registration
        // Register button is clicked

        if (postbackElement == "ctl00_ContentPlaceHolder1_Calendar1") {
            $('#ctl00_ContentPlaceHolder1_Panel1').hide("fast");
            
        }
        
    }
//===========================================================================================================================
   
   
    function BeginRequest(sender, args) {

     // when date is selected in todays events page
        if (postbackElement.indexOf('TodayEventCalendarSelect') > 0) {

            $("#disableDiv").addClass("CreateBackGroundOpacity");
           
            $("#AlertDiv").show();


        }

        // when show button is clicked in daily schedule form
        if (postbackElement.indexOf('btnDailyScheduleByRoom') > 0) {

            $("#disableDivDailySchedule").addClass("CreateBackGroundOpacity");

            $("#AlertDivDailySchedule").show();


        }

       if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_hdCheckConflict") {
         ActivateAlertDiv('visible', 'This postback will be canceled.');
     }

     
            
        
     } // end of BeginRequest
//===========================================================================================================================
    
     function PageLoading(sender, args) {
         //// For higher Ed 
         
         // during checking
         if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_hdCheckConflict") {
             ActivateAlertDiv('visible', 'This postback will be canceled.');
         }

         //during submission

         if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_hdClassSubmit") {
             ActivateAlertDiv('visible', 'This postback will be canceled.');
         }

                
     }  // end if PageLoading

 //==============================================================================================================================
  
  
     function PageLoaded(sender, args) {

         // For dailyschedule forms...
//         var updatedPanels = args.get_panelsUpdated();
         if (typeof (postbackElement) == "undefined") {
             return;
         }

       // this is used for maintaining the scroll inside the list of rooms in daily Schedule By Rooms App
         if (postbackElement.indexOf('MainGroups') > 0) {
          
             $get("divScroll").scrollTop = $get("ctl00_ContentPlaceHolder1_hdnScrollTop").value;
            
         }
         
     } // end of PageLoaded
//==================================================================================================================================
    
    
     function EndRequest(sender, args) {

         // For today's events

         if (postbackElement.indexOf('TodayEventCalendarSelect') > 0) {


             $("#AlertDiv").slideUp("slow", function () {

                 $("#disableDiv").removeClass("CreateBackGroundOpacity");
             });

         }

         // For todays events when the title is cliked. 
         if (postbackElement.indexOf('dailyScheduleGridView') > 0) {

             // now check if its credit...
             if (postbackElement.indexOf('LinkButton1') > 0) {

                 $('#dailyScheduleOuter').addClass("modalpopupDailySchedule");

                 $('#ctl00_ContentPlaceHolder1_pnlPopup').slideDown("slow", function () {
                 });

             }

             // if its meeting
             if (postbackElement.indexOf('LinkButton2') > 0) {

                 $('#dailyScheduleOuter').addClass("modalpopupDailySchedule");
                 $('#ctl00_ContentPlaceHolder1_NewMeetingPanel').slideDown("slow", function () {

                 });

             }

         }

   //------------------------------------------------------------------------------------------------

         // for Daily Schedule by Rooms App.
         // The pop up delay window slowly slides Up when show button is clicked.

              if (postbackElement.indexOf('btnDailyScheduleByRoom') > 0) {

            
             $("#AlertDivDailySchedule").slideUp("slow", function () {

                 $("#disableDivDailySchedule").removeClass("CreateBackGroundOpacity");
             });


         }


       
   //---------------------------------------------------------------------------------------------------
    

         //ForNONStage net successfull subbmission   
         if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_FormView1_InsertButton") {

             $("#mainDiv").addClass("modalpopupNonStageNet");
             $("#errorDiv").slideDown("slow", function() {

             });
             
         }
     
         if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_DetailsView1_btnInsertData") {

             ActivateAlertDiv('visible', 'This postback will be canceled.');

         }



     }
   //----------------------------------------------------------------------------------------------------

     function ActivateAlertDiv(visString, msg) {
        
         var adiv = $get(divElem);
//         var aspan = $get(messageElem);
         adiv.style.visibility = visString;
//         aspan.innerHTML = msg;
     }
     
     
     


if (typeof (Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

