﻿// 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("First Name");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox2").Watermark("Last Name");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox3").Watermark("Address");
    //$("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox4").Watermark("City");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox5").Watermark("Email");
    $("#ctl00_ctl00_SubApp1_SubContent_DetailsView1_TextBox6").Watermark("Phone");
    $("#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 daily schedule form pop up close button

//    $("#ctl00_ContentPlaceHolder1_eventdailybtnClose").mouseover(
//      function () {
//          $(this).append($("<span> Close</span>"));
//      },
//      function () {
//          $(this).find("span:last").remove();
//      }
//    );

    
    
    
    
    
    // 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 CLASS POP UP WINDOW...


   


    $("#ctl00_ContentPlaceHolder1_eventdailybtnClose").click(function () {


        $('#ctl00_ContentPlaceHolder1_pnlPopup').slideUp("slow", callback);

        return false;
    });

 
 
         //callback function to bring a hidden box back
		function callback(){

		    $("#dailyScheduleOuter").removeClass("modalpopupDailySchedule");
		    

		  };

		 
        // FOR CLOSING THE MEETING POP UP

		  $("#ctl00_ContentPlaceHolder1_newMeetingbtnNowClose").click(function () {

		      $('#ctl00_ContentPlaceHolder1_NewMeetingPanel').slideUp("slow", callback);

		      return false;

		  }); 
   
}

var postbackElement;
var divElem = 'AlertDiv';
var dailyDiv = 'dailyScheduleOuter'


     function InitializeRequest(sender, args) {
        
        //ctl00_ctl00_SubApp1_SubContent_Button1      
        
        postbackElement = args.get_postBackElement().id;
//alert(postbackElement);
      

        // LMS REGISTRATION FORM
        // REGISTER BUTTON CLIECKED....

        if (postbackElement == "ctl00_ContentPlaceHolder1_Calendar1") {
            $('#ctl00_ContentPlaceHolder1_Panel1').hide("fast");
            
        }
        
    }

    function BeginRequest(sender, args) {
       
       
       if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_hdCheckConflict") {
         ActivateAlertDiv('visible', 'This postback will be canceled.');
        }

// For daily events page. Display while reading from TCR database...
        if (postbackElement == "ctl00_ContentPlaceHolder1_Calendar1") {
            ActivateAlertDiv('visible', 'This postback will be canceled.');
        }

      
            if (postbackElement.indexOf('dailyScheduleGridView') > 0) {
             
                ActivateAlertDiv('visible', 'This postback will be canceled.');
            }
       
        
     }

     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.');
         }

                
     }

     function PageLoaded(sender, args) {

         // For dailyschedule forms...
//         var updatedPanels = args.get_panelsUpdated();
         if (typeof (postbackElement) == "undefined") {
             return;
         }

       
         if (postbackElement.indexOf('MainGroups') > 0) {
          
             $get("divScroll").scrollTop = $get("ctl00_ContentPlaceHolder1_hdnScrollTop").value;
            
         }
         
     }

     function EndRequest(sender, args) {

        
         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 (postbackElement.indexOf('LinkButton2') > 0) {
             
                 $('#dailyScheduleOuter').addClass("modalpopupDailySchedule");
                 $('#ctl00_ContentPlaceHolder1_NewMeetingPanel').slideDown("slow", function() {
                 });

             }
             
            }

  


         //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.');

         }

// Occurs when Administrator registers new student information
         if (postbackElement == "ctl00_ctl00_SubApp1_SubContent_Button2") {
           

         //    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();
