// JavaScript Document

var myHttp = (window.ActiveXObject)?new ActiveXObject("Microsoft.XMLHTTP"):new XMLHttpRequest();
var myHTML;var xmlObj;

function carica2() {

	myHttp.onreadystatechange = function(){
									if ((myHttp.readyState==4)&&(myHttp.status==200||myHttp.status==304)){	
										xmlObj = myHttp.responseXML.documentElement;									
									}
								}
	//myHttp.open("GET", "http://www.scalagroupinternational.com/demo.xml", true);
    if(/^http:\/\/www.scalagroupinternational.com\//.test(window.location)) {
       myHttp.open("GET", "http://www.scalagroupinternational.com/demo.xml", true);
    }
    if(/^http:\/\/scalagroupinternational.com\//.test(window.location)) {
       myHttp.open("GET", "http://scalagroupinternational.com/demo.xml", true);
    }
    if(/^http:\/\/www.scalaint.com\//.test(window.location)) {
       myHttp.open("GET", "http://www.scalaint.com/demo.xml", true);
    }
    if(/^http:\/\/scalaint.com\//.test(window.location)) {
       myHttp.open("GET", "http://scalaint.com/demo.xml", true);
    }
	myHttp.send(null);
}		


function check(str){
	if (str=="") {resetta();
	}else{
		str = str.toLowerCase();
		myHTML= "";
		document.getElementById("results").innerHTML = myHTML;
		myTags = xmlObj.getElementsByTagName("tags");
		for (i=0;i<myTags.length;i++){	
			if (myTags[i].childNodes[0].nodeValue.indexOf(str)!=-1) inserisciLink(i);
		}
	}
}

function inserisciLink(indice){
	var myDemo = xmlObj.getElementsByTagName("demo")[indice];	
	demoNome = myDemo.getElementsByTagName("name")[0].childNodes[0].nodeValue;
	demoLink = myDemo.getElementsByTagName("name")[0].childNodes[0].nodeValue;
	myHTML += "<a href='"+demoLink+"' >"+demoNome+"</a><br/>";
	document.getElementById("results").innerHTML = myHTML;
}

function resetta(){
	document.getElementById("results").innerHTML = " ";
	}

carica2();
