// JavaScript Document



// 1.GEO ************************************




// 2.TIME ************************************








// 3.URL************************************

// parecida operativa a la de arriba... en este caso ejecuta un php externo sin mostrarlo y sin refrescar, pasandole la str en forma de variable q

function process(id, sect) {
 document.clubs.action='venueselect.php?a='+id+'&amp;b='+sect;
 document.clubs.submit();
}


	
function execurl(url,method,output) // AJAX EJECUTA UNA URL con POST o GET y sin mostrar el resultado
		{	
		
 		if (window.XMLHttpRequest)
 		 {// code for IE7+, Firefox, Chrome, Opera, Safari
  		xmlhttp=new XMLHttpRequest();
 		 }
		else
  		{// code for IE6, IE5
  		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
 		 }
		xmlhttp.open(method, url ,output);
		
		xmlhttp.send();
//alert (url);
		}
	
	
	



function openurl(web) // SOLO TIENE SENTIDO PARA ABRIR UNA VENTANA NUEVA... estoy usando myLink() mejor
{	var displaysetting = 'width=330,height=330,left=100, top=25';
	window.open(web, "pagename", displaysetting);


}

// esta es la manera de evitar que un link salga del modo WebApp en iOs
function myLink(link){
window.location = link;
}






// 4.EMAIL ************************************

	function PonEmail(nombre,dominio) {
		z = nombre + '@' + dominio;
		a = '<a href="mailto:'+z+'">'+z+'</a>'; 
		document.write(a);
	}



   function sendMailTo(name, company, domain) {
      locationstring = 'mai' + 'lto:' + name + '@' + company + '.' + domain;
      window.location.replace(locationstring);
   }










// 5.SCROLL / BLOQEO / MENU  ************************************


function BlockMove(event) {
  // Tell Safari not to move the window. Para iOs que no se mueva la pantalla
  event.preventDefault() ;
 }


	


// scroll
$(document).ready(function(){
	$(".scroll").click(function(event){
		//prevent the default action for the click event
		event.preventDefault();

		//get the full url - like mysitecom/index.htm#home
		var full_url = this.href;

		//split the url by # and get the anchor target name - home in mysitecom/index.htm#home
		var parts = full_url.split("#");
		var trgt = parts[1];

		//get the top offset of the target anchor
		var target_offset = $("#"+trgt).offset();
		var target_top = target_offset.top;

		//goto that anchor by setting the body scroll top to anchor top
		$('html, body').animate({scrollTop:target_top}, 500);
	});
});




	


// 6.SHOW/HIDE /FILTER  ************************************



	
	function restorerows()
{
var elem = document.getElementsByTagName('tr');
for (var i = 0; i < elem.length; i++) { elem[i].style.display=""}
}


// esta es la funcion de filtro de la u-vox ANTIGUA solo TABLAS

   	function filter (phrase, _id){
		var words = phrase.value.toLowerCase().split(" ");
		var table = document.getElementById(_id);
		var ele;
		for (var r = 1; r < table.rows.length; r++){
			ele = table.rows[r].innerHTML.replace(/<[^>]+>/g,"");
		        var displayStyle = 'none';
		        for (var i = 0; i < words.length; i++) {
			    if (ele.toLowerCase().indexOf(words[i])>=0)
				displayStyle = '';
			    else {
				displayStyle = 'none';
				break;
			    }
		        }
			table.rows[r].style.display = displayStyle;
		}
	}







// AJAX: La uso para enviar un valor de un select o form a un php sin necesidad de recarga
  // Ej: el php (url) de destino puede en vez de asignar una variable, calcular un result y mostrarl, esto lo mostrará en el DIV pagina
    //Ej: en el select de clubs si selecciono 'Gris' la variable $venue cambia a ese valor automáticamente.
  
function showSubmenu(sect, divsect)
{
/*if (sect=="")
  {
  document.getElementById(divsect).innerHTML="";
  return;
  } */
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    {
    document.getElementById(divsect).innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET","submenu.php?q="+sect,true);
xmlhttp.send();
}








function hidediv(div) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'hidden'; 
} 
} 
}

function showdiv(div) { 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'visible'; 
} 
} 
} 


function shiftdiv(sect,div) {
	

if (sect == "clubs") {
	
	
{ 
if (document.getElementById) { // DOM3 = IE5, NS6 

document.getElementById(div).style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'visible'; 
} 
} 
} 

}else {


if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'hidden'; 
} 
} 

}

}





/*






function shiftdivlink(sect,div,link) {

if (sect == "clubs") {
	
	
{ 
if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.visibility = 'visible'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'visible'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'visible'; 
} 
} 
} 



}else {


if (document.getElementById) { // DOM3 = IE5, NS6 
document.getElementById(div).style.visibility = 'hidden'; 
} 
else { 
if (document.layers) { // Netscape 4 
document.hideShow.visibility = 'hidden'; 
} 
else { // IE 4 
document.all.hideShow.style.visibility = 'hidden'; 
} 
} 

}

window.location = link;

}


*/





// 7. MENU  ************************************


 // AJAX: La uso para enviar un valor de un select o form a un php sin necesidad de recarga
  // Ej: el php (url) de destino puede en vez de asignar una variable, calcular un result y mostrarl, esto lo mostrará en el DIV pagina
    //Ej: en el select de clubs si selecciono 'Gris' la variable $venue cambia a ese valor automáticamente.
  
function changeSelect(id, sect)
{
if (str=="")
  {
  document.getElementById("content").innerHTML="";
  return;
  } 
if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
xmlhttp.onreadystatechange=function()
  {
  if (xmlhttp.readyState==4 && xmlhttp.status==200)
    { 
    document.getElementById("content").innerHTML=xmlhttp.responseText;
    }
  }
xmlhttp.open("GET",'venueselect.php?a='+id+'&amp;b='+sect,true);
xmlhttp.send();

}





// 8.UPDATE CONTENT  ************************************

function addhtml(div, html) {
	 	var previousInnerHTML = new String();
        
        previousInnerHTML = document.getElementById(div).innerHTML;
        previousInnerHTML = previousInnerHTML.concat(html); 
        document.getElementById(div).innerHTML = previousInnerHTML;
	}


 // LO USO PARA ACTUALIZAR LOS SUBSECTS TRAS CAMBIAR VALOR EN DROPDOWN
function processreload(id, nam ,div) {

 if (window.XMLHttpRequest)
  {// code for IE7+, Firefox, Chrome, Opera, Safari
  xmlhttp=new XMLHttpRequest();
  }
else
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
  
xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById(div).innerHTML=xmlhttp.responseText;} }

xmlhttp.open("GET",'subsects.php?idv='+id+'&amp;namv='+nam,true);
xmlhttp.send();

 document.getElementById('droptitle').innerHTML = '@ '+nam; 
 
}



function changebackground(div,img) {
document.getElementById(div).style.backgroundImage = "url("+img+")"; // JS puro
//$('#'+div).css("background-image", "url("+img+")");  //alternativa JQUERY

}

 


   



