function createRequestObject() {
    var ro;
    var browser = navigator.appName;
    if(browser == "Microsoft Internet Explorer"){
        ro = new ActiveXObject("Microsoft.XMLHTTP");
    }else{
        ro = new XMLHttpRequest();
    }
    return ro;
}

var http = createRequestObject();

function sndReq(action,id,id2,id3) {    
    
    if(id3){
        url = 'rcp.php?action='+action+'&id='+id+'&id2='+id2+'&id3='+id3;;
    }else if(!id3 && id2){
        url = 'rcp.php?action='+action+'&id='+id+'&id2='+id2;        
    }else if(!id3 && !id2){
        url = 'rcp.php?action='+action+'&id='+id;
    }
    http.open('get',url);
    http.onreadystatechange = handleResponse;
    http.send(null);    
	
}

function handleResponse() {
        
    if(http.readyState == 4){
        var response = http.responseText;
        var update = new Array();

        if(response.indexOf('|' != -1)) {
            
            update = response.split('|');
            
			if(update[0]=='a'){
				
				document.getElementById('pop').innerHTML = update[1];				
				document.getElementById('popup').style.display = "block";
			
			}
			
        }
    }
}


function rollOver(id){
	document.getElementById("imagemenu"+id).src = "_img/noumenu/"+id+"_off.gif";
}
function rollOut(id){
	document.getElementById("imagemenu"+id).src = "_img/noumenu/"+id+"_on.gif";
}
function chgStyleEquip(id){
	document.getElementById('link'+id).style.color = "#b3151b";
	document.getElementById('team'+id).style.backgroundImage = "url('_img/botoequipB.gif')";		
}
function restoreStyleEquip(id){
	document.getElementById('link'+id).style.color = "#ffffff";
	document.getElementById('team'+id).style.backgroundImage = "url('_img/botoequip.gif')";
}
function tancarPopup(){
	document.getElementById('popup').style.display = "none";
}
function obrirPopup(id){
	sndReq('faa',id);
}
function posarNegreta(id){
	document.getElementById('col1'+id).style.fontWeight = 'bold';
	document.getElementById('col2'+id).style.fontWeight = 'bold';
	document.getElementById('col3'+id).style.fontWeight = 'bold';
	document.getElementById('col4'+id).style.fontWeight = 'bold';
}

function treureNegreta(id){
	document.getElementById('col1'+id).style.fontWeight = 'normal';
	document.getElementById('col2'+id).style.fontWeight = 'normal';
	document.getElementById('col3'+id).style.fontWeight = 'normal';
	document.getElementById('col4'+id).style.fontWeight = 'normal';
}
function posarNegretaMenu(id){
	document.getElementById('sub_submenu'+id).style.fontWeight = 'bold';	
}

function treureNegretaMenu(id){
	document.getElementById('sub_submenu'+id).style.fontWeight = 'normal';	
}
function canviaDivCerca(){
	var valor = document.getElementById('id_op').options[document.getElementById('id_op').selectedIndex].value;
	if(valor == 1){
		document.getElementById('id_cerca_text').style.display = 'block';
		document.getElementById('id_cerca_equip').style.display = 'none';
		document.getElementById('id_cerca_data').style.display = 'none';
	}else if(valor == 2){
		document.getElementById('id_cerca_text').style.display = 'none';
		document.getElementById('id_cerca_equip').style.display = 'block';
		document.getElementById('id_cerca_data').style.display = 'none';
	}else if(valor == 3){
		document.getElementById('id_cerca_text').style.display = 'none';
		document.getElementById('id_cerca_equip').style.display = 'none';
		document.getElementById('id_cerca_data').style.display = 'block';
	}
}
function abandonaDates(){
	if(document.getElementById('inp_calendari_fi')){
		if(document.getElementById('inp_calendari_fi').value.length > 0 && (document.getElementById('inp_calendari_inici').value > document.getElementById('inp_calendari_fi').value)){
			document.getElementById('inp_calendari_fi').value = '';	
		}
	}
}
