function nuevoAjax()
{
	/* Crea el objeto AJAX. */
        var obj;

        if(window.XMLHttpRequest){
            obj = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
			obj = new ActiveXObject("Microsoft.XMLHTTP");
        }

        return obj;

}

function pause(milisec){
	var d = new Date();
	var begin = d.getTime();
alert(begin+" - "+d.getTime());
	while ((d.getTime() - begin ) > milisec){
	// nothing...
	}
}

function obre_s(URL) {
	day = new Date();
	id = day.getTime();
	eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=1,resizable=1,width=800,height=600');");
}

function showMisters(){
	document.getElementById('misters').style.display='block';
	document.getElementById('misses').style.display='none';
	document.getElementById('missesSelect').className='notSelectedGenre positioningFirstItemLeftNav';
	document.getElementById('mistersSelect').className='selectedGenre positioningSecondItemLeftNav';
	document.getElementById('missesLink').className='desactiveMissTer';
	document.getElementById('mistersLink').className='activeMissTer';
}

function showMisses(){
	document.getElementById('misses').style.display='block';
	document.getElementById('misters').style.display='none';
	document.getElementById('missesSelect').className='selectedGenre positioningFirstItemLeftNav';
	document.getElementById('mistersSelect').className='notSelectedGenre positioningSecondItemLeftNav';
	document.getElementById('missesLink').className='activeMissTer';
	document.getElementById('mistersLink').className='desactiveMissTer';
}

function MF_UpdateResultado(partido_id){

 	var myPartido = document.getElementById('matchResult'+partido_id);
	var ajax=nuevoAjax();
	ajax.open("GET", "/sections/multifutbol/ajax.getResultado.php?partido_id="+partido_id, true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1){
			//myPartido.innerHTML = "<img src='/img/generales/ajax-loader.gif' />";
			showLoader('matchResult'+partido_id);
		}
		if (ajax.readyState==4){
			myPartido.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}

function MF_UpdateTime(partido_id){

 	var myPartido = document.getElementById('matchTime'+partido_id);
	var ajax=nuevoAjax();
	ajax.open("GET", "/sections/multifutbol/ajax.getMatchTime.php?partido_id="+partido_id, true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1){
			showLoader('matchTime'+partido_id);
		}
		if (ajax.readyState==4){
			myPartido.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}

function MF_UpdatePhotos(partido_id){

	var myPartidoPics = document.getElementById('matchPhotos'+partido_id);
	var ajax=nuevoAjax();
	ajax.open("GET", "/sections/multifutbol/ajax.getFotosPartido.php?partido_id="+partido_id, true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1){
			showLoader('matchPhotos'+partido_id);
		}
		if (ajax.readyState==4){
			myPartidoPics.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}

function MF_UpdateComments(partido_id){

	var myPartidoCom = document.getElementById('matchComments'+partido_id);
	var ajax=nuevoAjax();
	ajax.open("GET", "/sections/multifutbol/ajax.getCommentsPartido.php?partido_id="+partido_id, true);
	ajax.onreadystatechange=function()
	{
		if (ajax.readyState==1){
			showLoader('matchComments'+partido_id);
		}
		if (ajax.readyState==4){
			myPartidoCom.innerHTML=ajax.responseText;
		}
	}
	ajax.send(null);
}

function showLoader(myDiv){
	var myDivLoad = document.getElementById(myDiv);
	myDivLoad.innerHTML =  "<img src='/img/generales/ajax-loader.gif' />";
}


