/***********************************************
* Dynamic Ajax Content- © 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
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}
function cercamenu(q)
{
document.write('<img src="images/lente2.gif" border="0" alt="ricerca" title="ricerca"><br><h1 class="Stile5" align="center">Motore di ricerca interno al sito</h1><div align="center">Inserisci il testo da <a href="http://www.bracegirdle.it/strumenti.php" title="strumenti del sito">cercare</a> nel sito:</div><br><input type="text" name="q" size="23" maxlength="256" value="' + q + '" title="risultati">&nbsp;<input type="submit" value="  Cerca!  " title="Cerca!"><br><br><input type="checkbox" name="opz1" value="1" checked="true" onclick="selez(\'1\')"> nel sito&nbsp;&nbsp;<input type="checkbox" name="opz2" value="2" onclick="selez(\'2\')"> nell\'Enciclopedia<br><input type="checkbox" name="opz3" value="3" onclick="selez(\'3\')"> nella <em>History of Middle-earth</em> (pillole)<br><input type="checkbox" name="opz4" value="4" onclick="selez(\'4\')"> nel sito (con Google)<br><br><div id="attesa" align="center"></div>');
}
function settaCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else var expires = "";
	document.cookie = name+"="+value+expires+"; path=/";
}
function selez (opz) {
		for (x=1;x<=4;x++) {
				if (x!=opz){
				document.corzoogle.elements['opz'+x].checked=false;
				}
				else {
				document.corzoogle.elements['opz'+x].checked=true;
				}
	 }
return false;
}
function bottona(div1,div2)
{
if (document.getElementById(div1).value=='nascondi') {
	 document.getElementById(div1).value='mostra';
	 document.getElementById(div2).style.display='none';
	 document.getElementById(div1).className = 'bottone';
	 }
else {
	 document.getElementById(div1).value='nascondi';
	 document.getElementById(div2).style.display='block';
	 document.getElementById(div1).className = 'bottone2';
	 }
}
function manda (form, opz) {
ogg = document.corzoogle.q.value;
if      (document.corzoogle.elements['opz2'].checked==true) url = 'Arda/cerca.php?q='
else if (document.corzoogle.elements['opz3'].checked==true) url = 'randompillola.php?s=';
else if (document.corzoogle.elements['opz4'].checked==true) url = 'http://www.google.it/search?q=site:www.bracegirdle.it ';
else  url = 'ricerca.php?q=';
location.href = url+ogg;
return false;
}
function attesa()
{
document.getElementById('attesa').innerHTML='<div style="background-color:#FEFFD5;width:300px"><br><font size="+1">Ricerca in corso...<br><br>Attendere prego...</font><br><br></div>';
}
function switcha()
{
if (document.corzoogle.elements['opz1'].checked==true){
return manda(this,'opz1');
}
else if (document.corzoogle.elements['opz2'].checked==true){
return manda(this,'opz2');
}
else if (document.corzoogle.elements['opz3'].checked==true){
return manda(this,'opz3');
}
else if (document.corzoogle.elements['opz4'].checked==true){
return manda(this,'opz4');
}
}
function guida()
{
var page = "http://www.bracegirdle.it/aiuto_ricerca2.php";
popwin = window.open(page,"","width=460,height=500,left=175,top=30,scrollbars,resizable")
popwin.focus();
}
function personalizza()
{
var page = "http://www.bracegirdle.it/personalizza_ricerca.php";
popwin = window.open(page,"","width=460,height=500,left=175,top=30,scrollbars,resizable")
popwin.focus();
}
function findw (word) {
location.href = "ricerca.php?q="+word;
return false;
}
function doHighlight3(bodyText, searchTerm, colore, highlightStartTag, highlightEndTag) 
{
// the highlightStartTag and highlightEndTag parameters are optional
if ((!highlightStartTag) || (!highlightEndTag)) {
if (colore==0) {
colore2="yellow";
}
else if (colore==1) {
colore2="GOLD";
}
else if (colore==2) {
colore2="LIME";
}
else if (colore==3) {
colore2="AQUAMARINE";
}
else if (colore==4) {
colore2="LIGHTPINK";
}
else if (colore==5) {
colore2="GREENYELLOW";
}
else {
colore2="yellow";
}
highlightStartTag = "<span style=\"background-color:"+colore2+"\">";
highlightEndTag = "</span>";
}
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 {
// skip anything inside an HTML tag
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
// skip anything inside a <script> block
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, colore, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight3(bodyText, searchArray[i], colore, highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}
function evidenzia(searchText, colore, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
if (!document.body || typeof(document.getElementById('risultati').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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight3(bodyText, searchArray[i], colore, highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}
function doHighlight4(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
// the highlightStartTag and highlightEndTag parameters are optional
if ((!highlightStartTag) || (!highlightEndTag)) {
highlightStartTag = "</span>";
highlightEndTag = "<span>";
}
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 {
// skip anything inside an HTML tag
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
// skip anything inside a <script> block
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 highlightSearchTerms4(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight4(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}
function disevid(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
if (!document.body || typeof(document.getElementById('risultati').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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight4(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}
function doHighlight5(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
// the highlightStartTag and highlightEndTag parameters are optional
if ((!highlightStartTag) || (!highlightEndTag)) {
highlightStartTag = "<strong>";
highlightEndTag = "</strong>";
}
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 {
// skip anything inside an HTML tag
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
// skip anything inside a <script> block
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 highlightSearchTerms5(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight5(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}

function bolda(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
if (!document.body || typeof(document.getElementById('risultati').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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight5(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}
function doHighlight6(bodyText, searchTerm, highlightStartTag, highlightEndTag) 
{
// the highlightStartTag and highlightEndTag parameters are optional
if ((!highlightStartTag) || (!highlightEndTag)) {
highlightStartTag = "</strong>";
highlightEndTag = "<strong>";
}
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 {
// skip anything inside an HTML tag
if (bodyText.lastIndexOf(">", i) >= bodyText.lastIndexOf("<", i)) {
// skip anything inside a <script> block
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 highlightSearchTerms6(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight6(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}

function sgrass(searchText, treatAsPhrase, warnOnFailure, highlightStartTag, highlightEndTag)
{
if (treatAsPhrase) {
searchArray = [searchText];
} else {
searchArray = [searchText];
}
if (!document.body || typeof(document.getElementById('risultati').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.getElementById('risultati').innerHTML;
for (var i = 0; i < searchArray.length; i++) {
bodyText = doHighlight6(bodyText, searchArray[i], highlightStartTag, highlightEndTag);
}
document.getElementById('risultati').innerHTML = bodyText;
}