
// -------- Timer For Exam Alert ------------------------------//
window.onload=getDate;

function getDate() {
    var whiteSpaces = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";

var theEntDate = document.getElementById('ctl00_ContentPlaceHolder1_test_dt');
if (theEntDate != null) {
    var theValue = theEntDate.innerHTML;
    if (theValue != "undefined" || theValue != "") {
        var firstComma = theValue.indexOf(" ");
        var lastComma = theValue.lastIndexOf(" ");
        var theDay = theValue.substring(0, firstComma);
        var theMonth = theValue.substring(firstComma + 1, lastComma);
        var theYear = theValue.substring(lastComma + 1);
        if (theMonth == 'January') { theMonth = "01"; }
        else if (theMonth == "February") { theMonth = "02"; }
        else if (theMonth == "March") { theMonth = "03"; }
        else if (theMonth == "April") { theMonth = "04"; }
        else if (theMonth == "May") { theMonth = "05"; }
        else if (theMonth == "June") { theMonth = "06"; }
        else if (theMonth == "July") { theMonth = "07"; }
        else if (theMonth == "August") { theMonth = "08"; }
        else if (theMonth == "September") { theMonth = "09"; }
        else if (theMonth == "October") { theMonth = "10"; }
        else if (theMonth == "November") { theMonth = "11"; }
        else if (theMonth == "December") { theMonth = "12"; }

        var theTestDate = theYear + "/" + theMonth + "/" + theDay;
        var d = new Date();
        var curDay = d.getDate();
        var curMonth = d.getMonth() + 1;
        var curYear = d.getFullYear();
        var CurrentDate = curYear + "/" + curMonth + "/" + curDay;
        var d1 = new Date(theTestDate);
        var d2 = new Date(CurrentDate);
        var one_day = (1000 * 60 * 60 * 24) * 1;
        var one_hr = 1000 * 60 * 60;
        var one_min = 1000 * 60;
        var h = d.getHours();
        var m = d.getMinutes();
        var s = d.getSeconds();
        var TheClock = '';
        if (d1 >= d2) {
            var theDiff = d1.getTime() - d2.getTime();
            var DayLeft = theDiff / one_day;
            var hrLeft = theDiff / one_hr
            var totalCurrentDate = CurrentDate + " " + h + ":" + m + ":" + s
            dd = Date.parse(theTestDate) - Date.parse(totalCurrentDate)
            dhour = Math.floor((dd % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);
            dmin = Math.floor(((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1);
            dsec = Math.floor((((dd % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);
            var mydiv = document.getElementById("ctl00_ContentPlaceHolder1_H_div");
            if (DayLeft > 1) { TheClock = DayLeft + " Day(s):  " + dhour + "  Hr(s) " + whiteSpaces; }
            else if (DayLeft = 1 && DayLeft > 0) { TheClock = dhour + "  Hr(s) " + whiteSpaces; }
            else if (DayLeft = 0) { TheClock = "Today is the Exam date" + whiteSpaces; }
            else { TheClock = "Exam is Over" + whiteSpaces; }
            //if (DayLeft > 1) { TheClock = DayLeft + " Day(s):  " + dhour + "  Hr(s): " + dmin + " Min(s): " + dsec + "  Sec(s)"; }
            //else if (DayLeft = 1 && DayLeft > 0) { TheClock = dhour + "  Hr(s): " + dmin + " Min(s): " + dsec + "  Sec(s)"; }
//            else if (DayLeft = 0) { TheClock = "Today is the Exam date"; }
//            else { TheClock = "Exam is Over"; }
            mydiv.innerHTML = TheClock;
            var t = setTimeout('getDate()', 500);
        }
    }

}
}
    
// Comments CSS class
function checkBro() {
var brow = navigator.appName;
var thePanel = document.getElementById('ctl00_com1_Panel3');
//if (brow == "Microsoft Internet Explorer") {thePanel.className = "mypanel";}else {thePanel.className = "mypanel_FF";}
}

// -------- Search For Alert ------------------------------//

function ShowImage()        
{//ctl00_searchalert1_headTB
    var alerthead=document.getElementById('ctl00_searchalert1_headTB');
    alerthead.style.backgroundImage = 'url(http://www.indiaeducation.net/common/img/ajax-loader.gif)';
    alerthead.style.backgroundRepeat = 'no-repeat';
    alerthead.style.backgroundPosition = 'right';
}

function HideImage() {
    var alerthead = document.getElementById('ctl00_searchalert1_headTB'); alerthead.style.backgroundImage = 'none';
}

function ShowImage2()
{
    var alerthead=document.getElementById('ctl00_searchalert1_headTB');
    alerthead.style.backgroundImage = 'url(http://www.indiaeducation.net/common/img/Zoom-In-icon.png)';
    alerthead.style.backgroundRepeat = 'no-repeat';
    alerthead.style.backgroundPosition = 'right';
}

function ClientPopulated(source, eventArgs)
{
    if (source._currentPrefix != null)
    {
        var list = source.get_completionList();
        var search = source._currentPrefix.toLowerCase();
        var splitSearch = new Array();
        splitSearch = search.split(' ');                
        var temp = '';
        for (var x = 0; x < splitSearch.length; x++)
        {
            temp = splitSearch[x];
            if (temp.length > 2) {movetoBold4(list, temp);}
        }
    }
}

 function movetoBold4(list, stringValue) {
          //alert(list.tagName);
		  var theNewString = removeSpecial(stringValue);
          for (var i = 0; i < list.childNodes.length; i++) {
              var text = list.childNodes[i].innerHTML;
              var mydiv = document.getElementById('listdiv').innerHTML;
              var mydiv1 = document.getElementById('listdiv')
            // mydiv1.style.height = '100px';
             //alert(mydiv)
              var splitLink = text.indexOf('[')
              var splitLink2 = text.lastIndexOf(']')
              var myLink = "<a href=" + "http://www.indiaeducation.net/Alerts/" + text.substring(splitLink + 1, (splitLink2 - splitLink)) + ">";
              var index = text.toLowerCase().indexOf(theNewString);
             
              if (index != -1) {
                  var value = myLink + text.substring(splitLink2+1) + "</a>";

				  var mytext = value.indexOf('>');
                var theSub = value.substring(mytext + 1)

                var index2 = theSub.indexOf(theNewString);
                
               var v1= theSub.substring(0,index2);
                v1 += '<span class="AutoComplete_ListItemHiliteText">';
                v1 += theSub.substr(index2, theNewString.length);
                v1 += '</span>';
                v1 += theSub.substring(index2 + theNewString.length);
                var theFinal = myLink + v1
				//var index3 = theFinal.indexOf('>');

			
				 
                  list.childNodes[i].innerHTML = theFinal;
				 

              }
			  
          }
      }
      
      function ClientItemSelected(source, e) {
          var mytextBox = document.getElementById('ctl00_searchalert1_headTB');
          //alert(mytextBox);
          mytextBox.innerText = "";
          mytextBox.value = "";
          var myText = e._item.innerText;
          var myLink = new Array(); ;

          var list = source.get_completionList();
          for (var i = 0; i < list.childNodes.length; i++) {
              var text = list.childNodes[i].innerHTML;

              var splitLink = text.indexOf('=')
              var splitLink2 = text.indexOf('>')
              myLink[i] = text.substring(splitLink + 2, (splitLink2 - (splitLink + 1)));
              //alert(myLink);
              window.location = myLink1;
         }
      }
      

 function removeSpecial(theString) {
         
          var temp = new String(theString);
          temp = temp.replace(/[^a-zA-Z 0-9]+/g, '');
          //alert('chan: ' + temp)
          return temp;

      }


	   function sendValueSearch() {
            var theTextbox = document.getElementById('ctl00_searchalert1_headTB');
            var searchBt = document.getElementById('ctl00_search1_searchBtn');
            var theDDL = document.getElementById('ctl00_search1_mainCat_DDL');

            var mytext = theTextbox.value;            
            var selectedText = theDDL.options[theDDL.selectedIndex].value;            
            if (mytext.length>2) {
               // document.aspnetForm.action = "http://192.168.1.103/india/alerts/search/index.aspx";
                document.aspnetForm.action = "http://www.indiaeducation.net/alerts/search/index.aspx";
                document.aspnetForm.method = "post";
                document.aspnetForm.submit();
            
            }
        }
      

// -------- Search For Alert End------------------------------//
        function EduSearchFn() {
            var cxtext = document.aspnetForm.cx;
            var coftext = document.aspnetForm.cof;
            var qtext = document.aspnetForm.q;
            var urltext = document.URL;
            document.aspnetForm.action = "http://www.EduSearch.in/results.asp?cx=" + cxtext.value + "&q=" + qtext.value + "&cof=" + coftext.value + "&siteurl=" + urltext;
            document.aspnetForm.method = "post";
            document.aspnetForm.target = "_blank";
            document.aspnetForm.submit();
        }
