/***********************************************
* Bookmark site script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

/* Modified to support Opera */
function bookmarksite(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function addEngine() {
   if (window.external && ("AddSearchProvider" in window.external)) {
       // Firefox 2 and IE 7, OpenSearch
       window.external.AddSearchProvider("");
   } else if (window.sidebar && ("addSearchEngine" in window.sidebar)) {
       // Firefox <= 1.5, Sherlock
       window.sidebar.addSearchEngine("Птицеферма Ганеви", "");
   } else {
      // No search engine support (IE 6, Opera, etc).
      alert("No search engine support");
   }
}
function getXMLHTTPRequest() {
    var request = false;

    try { 
	    request = new XMLHttpRequest(); /* e.g. Firefox */ 
	} catch(e) { 
	    try { 
		    request = new ActiveXObject("Msxml2.XMLHTTP"); /* some versions IE */ 
		    } catch (e) { 
			    try { 
				    request = new ActiveXObject("Microsoft.XMLHTTP"); /* some versions IE */ 
				    } catch (E) { 
					    request = false; 
				    } 
		    } 
	}
    return request;
}

http = getXMLHTTPRequest();

function suggestTerm() { 
    var url = "suggest_term.php?param="; 
	var idValue = document.getElementById("q").value; 
	var myRandom = parseInt(Math.random()*99999999);
	http.open("GET", url + escape(idValue) + "&rand=" + myRandom, true); 
	http.onreadystatechange = handleHttpResponse; 
	http.send(null);
	document.getElementById("q").disabled = true;
}
function handleHttpResponse() { 
	if (http.readyState == 4) { 
        if (http.status == 200) {
//		    document.getElementById("hiddenDIV2").style.visibility = "visible"; 
		    document.getElementById("hiddenDIV2").style.display = "block"; 
		    document.getElementById("hiddenDIV2").innerHTML = http.responseText; 
			document.getElementById("q").disabled = false;
		}
	} 
} 
function loadrecord(record) { 
	document.schform.q.value = record; 
//	document.getElementById("hiddenDIV2").style.visibility = "hidden";
	document.getElementById("hiddenDIV2").style.display = "none";
}
function getRandomNews() {
    var url = "random_news.php"; 
	var myRandom = parseInt(Math.random()*99999999);
	http.open("GET", url + "?rand=" + myRandom, true); 
	http.onreadystatechange = handleRandomNews; 
	http.send(null);
}
function handleRandomNews() { 
	if (http.readyState == 4) { 
        if (http.status == 200) {
			document.getElementById("randomNews").innerHTML = http.responseText;
		}
	} else {
			document.getElementById("randomNews").innerHTML = "<div style=\"text-align: center; margin-top: 80px\"><img src=\"images/ajax_loader.gif\" style=\"border:none;width:32px;height:32px;\" alt=\"\" /></div>\n";
	}

}
function verifySMScode() {
    var url = "includes/verify_sms_code.php";
	var myRandom = parseInt(Math.random()*99999999);
	var myCode = document.getElementById("activation_code").value;
	http.open("GET", url + "?code=" + myCode + "&rand=" + myRandom, true);
	http.onreadystatechange = handleVerifySMScode;
	http.send(null);
}
function handleVerifySMScode() {
    if (http.readyState == 4) {
		if (http.status == 200) {
			document.getElementById("activation_status").innerHTML = http.responseText;
			document.getElementById("activation_code").innerHTML = "";
		}
    } else {
		document.getElementById("activation_status").innerHTML = "<div style=\"text-align: center; margin-top: 10px\"><img src=\"images/ajax_loader2.gif\" style=\"border:none;width:32px;height:32px;\" alt=\"\" /></div>";
	}
}
