var paginaAjax = "../ajax.php";



function Check(chk, idC){

	Check_ctr = document.getElementById("padre_"+idC);

	chk = document.getElementsByName("hijo_"+idC+"[]");

	if(Check_ctr.checked==true){

		for (i = 0; i < chk.length; i++)

			chk[i].checked = true ;

	}else{

		for (i = 0; i < chk.length; i++)

			chk[i].checked = false ;

	}

}



function CheckPadre(idC){

	band = false;

	Check_ctr = document.getElementById("padre_"+idC);

	chk = document.getElementsByName("hijo_"+idC+"[]");

	for(i = 0; i < chk.length; i++){

		if(chk[i].checked==true){

			band=true;

		}

	}

	

	if(band){

		Check_ctr.checked=true;

	}else{

		Check_ctr.checked=false;

	}	

}


function mostrarTab(mostrar)

{

	var tabName = "tb" + mostrar;



	var contenedor = document.getElementsByClassName('tab');

	var l = contenedor.length;

	for(x=0;x<l;x++)

	{

		contenedor[x].style.display = 'none';

	}

	Effect.BlindDown(tabName);

	

	return true		

}



function dejarNumeros()

{

	var input = $('txtConvert');

	var texto = input.value.trim();

	var l = texto.length;

	var ret = "";

	for(x=0;x<l;x++)

	{

		var char = texto.charAt(x);

		if((!isNaN(char) || (char == ".")) && (char != "") && (char != " "))

		{

			ret = ret + char;

		}

	}

	input.value = ret;

	return true;

}



function invitarAmigo(dir)

{

	window.open("enviar-amigo.php?DIR=" + dir,"wIntivarAmigo","location=0,status=0,scrollbars=0,width=350,height=200"); 

	return true;

}



function recomendarAmigo()

{

	alert('Recomendar amigo');

	return true;	

}

function addToFavorites() {
	title = document.title; 
	url = window.location.href;
	if (window.sidebar) { // Mozilla Firefox Bookmark
		window.sidebar.addPanel(title, url,"");
	} else if( window.external ) { // IE Favorite
		window.external.AddFavorite( url, title); }
	else if(window.opera && window.print) { // Opera Hotlist
		return true; 
	}
}


function buscadorAvanzadoTab(seccion){

	var bgColor = '#e4eff5';
	var tdContenedor = $('#tdBuscadorForm');

	if(seccion == 'categoria')
		bgColor ='#5187a6';

	if(seccion == 'tienda')
		bgColor = '#73a6c3';

	if(seccion == 'servicio')
		bgColor = '#3a6075';
	
	if(seccion == 'precio')
		bgColor = '#686868';

	tdContenedor.css("backgroundColor", bgColor);

	$('#tblcategoria').css("display","none");
	$('#tblservicio').css("display","none");
	$('#tbltienda').css("display","none");
	$('#tblproducto').css("display","none");
	$('#tblprecio').css("display","none");

	$('#tbl' + seccion).css("display","block");
	return true;
}


function removeElements(idE){

	var fila = document.getElementById(idE);

	while (fila.firstChild) {

	 fila.removeChild(fila.firstChild);

	}

}





function mostrarCategoria(idC){

	var itemList = '#lista' + idC;

	if ($(itemList).is(":hidden")){
		$(itemList).slideDown("slow");
	} else {
		$(itemList).slideUp("slow");
	}
	return true;	
}


function mostrarCategoriasMenu(){

	var serviceList = '#menuContainer';

	if ($(serviceList).is(":hidden")){
		$(serviceList).slideDown("slow");
	} else {
		$(serviceList).slideUp("slow");
	}
	return true;	
}



function mostrarServiciosMenu(){

	var serviceList = '#serviciosContainer';

	if ($(serviceList).is(":hidden"))

	{

		$(serviceList).slideDown("slow");

	} else {

		$(serviceList).slideUp("slow");

	}

	return true;	

}



function mostrarRestaurantesMenu(){

	var restaurantList = '#restaurantesContainer';

	if ($(restaurantList).is(":hidden"))

	{

		$(restaurantList).slideDown("slow");

	} else {

		$(restaurantList).slideUp("slow");

	}

	return true;	

}



function eliminaEspacios(id){
	var cual = '#email';

	$(cual).val(jQuery.trim($(cual).val()));
	return true;
}

function setCanton(){
	var id = $('#provincia').val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "parametro="+id+"&accion=4",
			success: function(datos){
				eval(datos);
			},
			error: function(objeto, quepaso, otroobj){
    	        alert("Ha ocurrido un error intentelo nuevamente");
	        }
		});	
	}else
		$('#canton').size = 1;

	//ajaxCall('ajax.php', 'accion=2&parametro=' + id);
	return true;
}

function setCantonChk(){
	var id = $('#provinciachk').val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "parametro="+id+"&accion=8",
			success: function(datos){
				eval(datos);
			},
			error: function(objeto, quepaso, otroobj){
    	        alert("Ha ocurrido un error intentelo nuevamente");
	        }
		});	
	}else
		$('#cantonchk').size = 1;

	return true;
}

function ObtieneShipping(canton) {
  $.ajax({
	type: "POST",
	url: "ajax.php",
	data: "parametro="+canton+"&accion=9",
	success: function(datos){
	  eval(datos);
	},
	error: function(objeto, quepaso, otroobj){
    alert("Ha ocurrido un error intentelo nuevamente");
    }
  });
  return true;
}

function setSubsubcategorias(){
	var id = $('#subcategoria').val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "parametro="+id+"&accion=2",
			success: function(datos){
				eval(datos);
			},
			error: function(objeto, quepaso, otroobj){
    	        alert("Ha ocurrido un error intentelo nuevamente");
	        }
		});	
	}else
		$('#subsubcategoria').size = 1;

	//ajaxCall('ajax.php', 'accion=2&parametro=' + id);
	return true;
}

function setSubcategorias(){
	var id = $('#categorias').val();
	if(id > 0){
		$.ajax({
			type: "POST",
			url: "ajax.php",
			data: "parametro="+id+"&accion=1",
			success: function(datos){
				eval(datos);
			},
			error: function(objeto, quepaso, otroobj){
    	        alert("Ha ocurrido un error intentelo nuevamente");
	        }
		});	
	}else
		$('#subcategoria').size = 1;
	return true;
}