function Search(val) {
    document.getElementById("loading").style.visibility = "visible";
    var pl = new SOAPClientParameters();
    pl.add("prefixText", val);
    pl.add("count", "0");
    SOAPClient.invoke("http://indiaeducation.net/searchService.asmx", "Search", pl, true, Search_callBack);
}
function Search_callBack(r) {
    document.getElementById("Search_assist1").innerHTML = r;
    document.getElementById("Search_assist1").style.visibility = "visible";
    document.getElementById("loading").style.visibility = "hidden";
}
document.onclick = hideDiv;
function hideDiv(e) {
    var div = document.getElementById('Search_assist1');
    var target = e ? e.target : event.srcElement;
    target != div ? div.style.visibility = 'hidden' : null;
}
// -------- Timer For Exam Alert ------------------------------//
window.onload=getDate;

function getDate() {
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): " + 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()        
{//headTB
    var alerthead=document.getElementById('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('headTB'); alerthead.style.backgroundImage = 'none';
}

function ShowImage2()
{
    var alerthead=document.getElementById('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);
          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(stringValue);
             
              if (index != -1) {
                  var value = myLink + text.substring(splitLink2+1) + "</a>";
                  list.childNodes[i].innerHTML = value;

              }
          }
      }
      
      function ClientItemSelected(source, e) {
          var mytextBox = document.getElementById('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 sendValueSearch() {
            var theTextbox = document.getElementById('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 theTextbox = document.getElementById('headTB');
//http://www.edusearch.in/results.asp?cx=004531092988780131070%3Aqqhropsapwk&cof=FORID%3A10&q=sec&siteurl=www.indiaeducation.net%2Fmanagement%2F#1149
            var cxtext = document.form1.cx;
            var coftext = document.form1.cof;
            var qtext = document.form1.q;
            var urltext = document.URL;
            document.form1.action = "http://www.EduSearch.in/results.asp?cx=" + cxtext.value + "&q=" + qtext.value + "&cof=" + coftext.value + "&siteurl=" + urltext;
            document.form1.method = "post";
            document.form1.target = "_blank";
            document.form1.submit();
        }

        
