// JavaScript Document
function showVideos(id){
	hideAudio(id);hideFoto(id);
	var v = document.getElementById('vid'+id);
	var mv = document.getElementById('mnu_vid'+id);
	v.style.visibility = "visible";
	v.style.display = "block";
	//mv.className = "menusel";
}
function showAudios(id){
	hideVideo(id);hideFoto(id);
	var a = document.getElementById('aud'+id);	
	var ma = document.getElementById('mnu_aud'+id);	
	a.style.visibility = "visible";
	a.style.display = "block";
	//ma.className = "menusel";
}
function showFotos(id){
	hideVideo(id);hideAudio(id);
	var f = document.getElementById('fot'+id);	
	var mf = document.getElementById('mnu_fot'+id);	
	f.style.visibility = "visible";
	f.style.display = "block";
	//mf.className = "menusel";
}
function hideVideo(id){
	var v = document.getElementById('vid'+id);	
	var mv = document.getElementById('mnu_vid'+id);
	v.style.visibility = "hidden";
	v.style.display = "none";
	//if(mv!=null) mv.className = "menu";
}
function hideAudio(id){
	var a = document.getElementById('aud'+id);	
	var ma = document.getElementById('mnu_aud'+id);
	a.style.visibility = "hidden";
	a.style.display = "none";
	//if(ma!=null)  ma.className = "menu";
}
function hideFoto(id){
	var f = document.getElementById('fot'+id);	
	var mf = document.getElementById('mnu_fot'+id);	
	f.style.visibility = "hidden";
	f.style.display = "none";
	//if(mf!=null) mf.className = "menu";
}
function siguiente(id){
	var NumImagen = parseInt(eval("document.getElementById('cont_img"+id+"')").innerHTML);
	if(NumImagen < (eval('fot'+id).length)){
		NumImagen = parseInt(eval("document.getElementById('cont_img"+id+"')").innerHTML); 
		eval("document.getElementById('fot_src"+id+"')").src = "multi/fotos/thumbs/"+id+"_"+eval('fot'+id)[NumImagen];
		eval("document.getElementById('fot_desc"+id+"')").innerHTML = eval('fot_desc'+id)[NumImagen];
		eval("document.getElementById('cont_img"+id+"')").innerHTML = NumImagen+1;
	}
}
function anterior(id){
	var NumImagen = parseInt(eval("document.getElementById('cont_img"+id+"')").innerHTML);
	if(NumImagen > 1){
		NumImagen = parseInt(eval("document.getElementById('cont_img"+id+"')").innerHTML)-1; 
		eval("document.getElementById('fot_src"+id+"')").src = "multi/fotos/thumbs/"+id+"_"+eval('fot'+id)[NumImagen-1];
		eval("document.getElementById('fot_desc"+id+"')").innerHTML = eval('fot_desc'+id)[NumImagen-1];
		eval("document.getElementById('cont_img"+id+"')").innerHTML = NumImagen;
	}
}

function Popup(url,name,width,height,resize,scroll) {
	var dialogWin = new Object();
	dialogWin.width = width;
	dialogWin.height = height;
	dialogWin.left = (screen.width - dialogWin.width) / 2;
	dialogWin.top = (screen.height - dialogWin.height) / 2;
	var attr = 'left=' + dialogWin.left + ',top=' + dialogWin.top + ',resizable=' + resize + ',width=' + dialogWin.width + ',height=' + dialogWin.height + ',scrollbars=' + scroll + ',menubar=no,location=no,toolbar=no,status=no,directories=no';
	window.open(url,name,attr);

}

function habilitarFormSend(id){
	var formS = document.getElementById('formSend'+id);
	formS.style.visibility = 'visible';
	formS.style.display = 'block';
}
function deshabilitarFormSend(id){
	var formS = document.getElementById('formSend'+id);
	formS.style.visibility = 'hidden';
	formS.style.display = 'none';
}



var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {

            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('encuesta_form').innerHTML = result;            
        
      }
   }
   
   
  function submit_votacion(obj) {
	  
	  for (i=0;i<document.formEncuesta.opcion_voto.length;i++) 
		{ 
      		if (document.formEncuesta.opcion_voto[i].checked) 
      		{ 
             var rbgroup_value = document.formEncuesta.opcion_voto[i].value; 
      		} 
		}

      var poststr = "voto_encuesta=" + encodeURI( document.getElementById("voto_encuesta").value ) +
                    "&id_encuesta=" + encodeURI( document.getElementById("id_encuesta").value ) +
					"&ip=" + encodeURI( document.getElementById("ip").value ) +
					"&opcion_voto=" + encodeURI( rbgroup_value );
      makePOSTRequest('encuesta.php', poststr);
   }
   
  function submit_resultados(obj) {
      var poststr = "voto_encuesta=" + encodeURI( document.getElementById("voto_encuesta").value ) +
                    "&id_encuesta=" + encodeURI( document.getElementById("id_encuesta").value ) +
					"&ip=0";
					
      makePOSTRequest('encuesta.php', poststr);
   }
   
   function volver_votacion(obj) {
      var poststr = "";
      makePOSTRequest('encuesta.php', poststr);
   }
   
   
   
  function submit_votacion_dia7(obj) {
	  
	  for (i=0;i<document.formEncuestaDia7.opcion_voto.length;i++) 
		{ 
      		if (document.formEncuestaDia7.opcion_voto[i].checked) 
      		{ 
             var rbgroup_value = document.formEncuestaDia7.opcion_voto[i].value; 
      		} 
		}

      var poststr = "voto_encuesta=" + encodeURI( document.getElementById("voto_encuesta").value ) +
                    "&id_encuesta=" + encodeURI( document.getElementById("id_encuesta").value ) +
					"&ip=" + encodeURI( document.getElementById("ip").value ) +
					"&opcion_voto=" + encodeURI( rbgroup_value );
      makePOSTRequest('encuesta_dia7.php', poststr);
   }
   
  function submit_resultados_dia7(obj) {
      var poststr = "voto_encuesta=" + encodeURI( document.getElementById("voto_encuesta").value ) +
                    "&id_encuesta=" + encodeURI( document.getElementById("id_encuesta").value ) +
					"&ip=0";
					
      makePOSTRequest('encuesta_dia7.php', poststr);
   }
   
   function volver_votacion_dia7(obj) {
      var poststr = "";
      makePOSTRequest('encuesta_dia7.php', poststr);
   }   