// JavaScript Document
function OnPressClick_old()
	{
		var schString = "";
		var alpha=/^[a-zA-Z\0-9\s]+$/; 
		schString = document.getElementById("q").value;
		if (schString == "")
		{
			alert("Enter the search string.")
			return false;
		}
		if(!alpha.test(schString))
		{
			alert("*Search accepts only Alpha numeric!!");
			return false;
		}
		else
		{
			if (document.getElementById("rdIsro").checked==true)
			{
				document.location.href = "http://www.isro.gov.in/scripts/result.asp?search="+ schString +"&mode=allwords";
			}
			else
			{
				var strurl="http://www.google.com/search?q="+ schString;
				window.open(strurl);
			}
		}
		return true;
	}

function querySt(ji) {

		hu = window.location.search.substring(1);
		gy = hu.split("&");
	
		for (i=0;i<gy.length;i++) {
				ft = gy[i].split("=");
								if (ft[0] == ji) {
								return ft[1];
								}
							
				}


				return "-1";
		}

function doHighlight(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
  
  if ((!highlightStartTag) || (!highlightEndTag)) {
    highlightStartTag = "<font style='color:blue; background-color:yellow;'>";
    highlightEndTag = "</font>";
  }
  
 
  var newText = "";
  var i = -1;
  var lcSearchTerm = searchTerm.toLowerCase();
  var lcBodyText = bodyText.toLowerCase();
    
  while (bodyText.length > 0) {
    i = lcBodyText.indexOf(lcSearchTerm, i+1);
    if (i < 0) {
      newText += bodyText;
      bodyText = "";
    } else {
      
      if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
      
        if (lcBodyText.lastIndexOf("/script>", i) >= lcBodyText.lastIndexOf("<script", i)) {
          newText += bodyText.substring(0, i) + highlightStartTag + bodyText.substr(i, searchTerm.length) + highlightEndTag;
          bodyText = bodyText.substr(i + searchTerm.length);
          lcBodyText = bodyText.toLowerCase();
          i = -1;
        }
      }
    }
  }
  
  return newText;
}



function highlightSearchTerms(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{  
  if (treatAsPhrase) {
    searchArray = [searchText];
  } else {
    searchArray = searchText.split(" ");
  }
  
  if (!document.body || typeof(document.body.innerHTML) == "undefined") {
    if (warnOnFailure) {
      alert("Sorry, for some reason the text of this page is unavailable. Searching will not work.");
    }
    return false;
  }
  
  //var bodyText = document.body.innerHTML;
 
	var bodyText = document.getElementById("contentdiv").innerHTML;
 	 for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
 	 }
  document.getElementById("contentdiv").innerHTML = bodyText;  
  
  
  if(document.getElementById("divcontentleft")){  
  var bodyText = document.getElementById("divcontentleft").innerHTML;
 	 for (var i = 0; i < searchArray.length; i++) {
    bodyText = doHighlight(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
 	 }
  document.getElementById("divcontentleft").innerHTML = bodyText;  
    
  }
 //  document.body.innerHTML = bodyText;
		
	/*	
  		if (document.getElementsByTagName('div')) {
		var arrayOfDivs = document.getElementsByTagName('div');
		
			for (var i=0; i < arrayOfDivs.length -1 ; i++) {
			var thisDiv = arrayOfDivs[i];
			//alert(thisDiv.innerHTML);
					for (var j = 0; j < searchArray.length; j++) {
					 thisDiv.innerHTML = doHighlight(thisDiv.innerHTML, searchArray[j], highlightStartTag, highlightEndTag);
					}
					
					arrayOfDivs[i].innerHTML =thisDiv.innerHTML;	
		}
		
		
		}*/
		//mmLoadMenus();
 
  return true;
}

function higlightText() {
var text = querySt("Search");
	if(text != -1)
	{ 
	highlightSearchTerms(text);  
  	} 
  }
  
 function openwindow(url)
	{
		document.location.href = url;
	}
  function OnSearchPressClick()
	{
		var schString = "";
		var alpha=/^[a-zA-Z\0-9\s]+$/; 
		schString = document.getElementById("q").value;
		
		if (schString == "")
		{
			alert("Enter the search string.")
			return false;
		}
		if(!alpha.test(schString))
		{
			alert("*Search accepts only Alpha numeric!!");
			return false;
		}
		else
		{
			if (document.getElementById("rdIsro").checked==true)
			{
				document.location.href = "http://www.isro.gov.in/scripts/ISROSearch.aspx?search="+ schString;
			}
			else
			{
				var strurl="http://www.google.com/search?q="+ schString;
				window.open(strurl);
			}
		}
		return true;
	}


	function OnPressClick()
	{
		var schString = "";
		var alpha=/^[a-zA-Z\0-9\s]+$/; 
		schString = document.getElementById("q").value;
		
		if (schString == "")
		{
			alert("Enter the search string.")
			return false;
		}
		if(!alpha.test(schString))
		{
			alert("*Search accepts only Alpha numeric!!");
			return false;
		}
		else
		{
			if (document.getElementById("rdIsro").checked==true)
			{
				document.location.href = "http://www.isro.gov.in/scripts/ISROSearch.aspx?search="+ schString;
			}
			else
			{
				var strurl="http://www.google.com/search?q="+ schString;
				window.open(strurl);
			}
		}
		return true;
	}