// JavaScript Document
// Libreria YUI, Ovelays

//--  Variables ----------------------
var isOtrasCiudades = false;  //	Esta o no visible el overlay de otras ciudades
//------------------------------------


//-- Instancias -------------------------
YAHOO.namespace("example.container");
		function init() {
			
			// Inicializa el Overlay de otras ciudades
			masCiudades = new YAHOO.widget.Panel("panel1", { width:"290px", constraintoviewport: true, underlay:"none", close:true, visible:false, context:["otra_ciudad", "tl", "bl", ["beforeShow"]]} );
			masCiudades.cfg.setProperty("draggable","true"); 
			masCiudades.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25});
			masCiudades.hideEvent.subscribe( setIsOtrasCiudades );	
			masCiudades.render();
			
			// Inicializa el overlay de ingreso y registro
			ingreso_overlay = new YAHOO.widget.Panel("panel2", { width:"620px", close: true, draggable: false, modal: true, visible: false, context:["botonOverlayIngreso", "tr", "br", ["beforeShow"]]  } );
			ingreso_overlay.render();
			
			// Inicializa el overlay de cambiar contraseņa
			cambio_password = new YAHOO.widget.Panel("panel3", { width:"500px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			cambio_password.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25});
			cambio_password.render();
			
			// Inicializa el overlay de editar imagen
			editar_imagen = new YAHOO.widget.Panel("panel4", { width:"400px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			editar_imagen.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25});
			editar_imagen.render();
			
			// Inicializa el overlay de crear lugar o negocio
			nuevo_lugar_negocio = new YAHOO.widget.Panel("panel5", { width:"600px", close: true, draggable: false, modal: true, visible: false, context:["cuentaPerfilUsuario", "tl", "tl", ["beforeShow"]]} );
			nuevo_lugar_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			nuevo_lugar_negocio.render();
			
			// Inicializa el overlay de editar lugar o negocio
			editar_lugar_negocio = new YAHOO.widget.Panel("panel6", { width:"450px", close: true, draggable: false, modal: true, visible: false, context:["cuentaPerfilUsuario", "tl", "tl", ["beforeShow"]]} );
			editar_lugar_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			editar_lugar_negocio.render();
			
			// Inicializa el overlay de confirmacion eliminar lugar o negocio
			delete_lugar_negocio = new YAHOO.widget.Panel("panel7", { width:"450px", close: true, draggable: false, modal: true, visible: false, context:["cuentaPerfilUsuario", "tl", "tl", ["beforeShow"]]} );
			delete_lugar_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			delete_lugar_negocio.render();
			
			// Inicializa el Overlay de ciudades ubicacion establecimiento
			masCiudadesUbicacion = new YAHOO.widget.Panel("panel51", { width:"290px", draggable: false, close:true, visible:false} );
			masCiudadesUbicacion.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.05});
			masCiudadesUbicacion.render();
			
			// Inicializa el Overlay de ciudades ubicacion establecimiento
			otraCategoriaEstablecimiento = new YAHOO.widget.Panel("panel52", { width:"290px", draggable: false, close:true, visible:false} );
			otraCategoriaEstablecimiento.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.05});
			otraCategoriaEstablecimiento.render();
			
			// Inicializa el overlay de nueva categoria productos
			categoria_producto = new YAHOO.widget.Panel("panel8", { width:"400px", height:"auto", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			categoria_producto.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			categoria_producto.render();
			
			// Inicializa el overlay de producto
			producto_negocio = new YAHOO.widget.Panel("panel9", { width:"400px", height:"auto", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			producto_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			producto_negocio.render();
			
			// Inicializa el overlay de imagen
			imagen_negocio = new YAHOO.widget.Panel("panelImagen", { width:"400px", height:"auto", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			imagen_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			imagen_negocio.render();
			
			// Inicializa el overlay de direccion
			direccion_negocio = new YAHOO.widget.Panel("panelDireccion", { width:"400px", height:"auto", close: true, draggable: false, modal: true, visible: false, fixedcenter: true} );
			direccion_negocio.cfg.setProperty("effect", {effect:YAHOO.widget.ContainerEffect.FADE,duration:0.1});
			direccion_negocio.render();
			
			// Inicializa el overlay de comentar
			comentar_overlay = new YAHOO.widget.Panel("panelComentario", { width:"620px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true } );
			comentar_overlay.render();
			
			// Inicializa el overlay de recomendar
			recomendar_overlay = new YAHOO.widget.Panel("panelRecomendar", { width:"620px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true } );
			recomendar_overlay.render();
			
			// Inicializa el overlay de guardarFavoritos
			gFavoritos_overlay = new YAHOO.widget.Panel("panelGuardarFavoritos", { width:"620px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true } );
			gFavoritos_overlay.render();
			
			
			// Inicializa el overlay de imprimir
			imprimir_overlay = new YAHOO.widget.Panel("panelImprimir", { width:"620px", close: true, draggable: false, modal: true, visible: false, context:["encabezado", "tl", "bl", ["beforeShow"]] } );
			imprimir_overlay.render();
			
			// Inicializa el overlay de productos
			productos_overlay = new YAHOO.widget.Panel("panelProductos", { width:"620px", close: true, draggable: false, modal: true, visible: false, context:["encabezado", "tl", "bl", ["beforeShow"]] } );
			productos_overlay.render();
			
			// Inicializa el overlay de video tutorial
			video_overlay = new YAHOO.widget.Panel("videoTutorial", { width:"400px", close: true, draggable: false, modal: true, visible: false, fixedcenter: true } );
			video_overlay.render();
			video_overlay.hideEvent.subscribe(pararVideoTutorial); 
		}
		
		YAHOO.util.Event.addListener(window, "load", init);		//  Carga las Instacias
//-----------------------------------------------------
		
// Cierra la ventana de ingreso y registro		
function salirIngreso(){
	ingreso_overlay.hide();
}

// Cambia el estado del overlay de otras ciudades a no visible
function setIsOtrasCiudades(){
	isOtrasCiudades = false;
}

//	Llama a la plantilla de ingreso y registro y muestra el overlay
function ingresarOverlay(){
		cargarIngreso();
		ingreso_overlay.show();
}
function cerrarIngresarOverlay(){
		ingreso_overlay.hide();
}

// Muestra u Oculta el Overlay de otras ciudades
function cambiarCiudad(){
	if (isOtrasCiudades){
		masCiudades.hide();
		isOtrasCiudades=false;
	}else {
		mostrarDepartamentosOverflow();
		masCiudades.show();
		isOtrasCiudades=true;
	}
}

//	Llama a la plantilla de cambiar password
function overlayPassword(){
		cargarCP();
		cambio_password.show();
}
// Cierra la ventana de cambio de password		
function salirCambioPassword(){
	cambio_password.hide();
}

//	Llama a la plantilla de editar imagen (Usuario no facebook)
function overlayEditarImagen(){
		cargarEI();
		editar_imagen.show();
}

//	Llama a la plantilla de nuevo lugar negocio
function overlayCrearLugarNegocio(){
		cargarCLN();
		nuevo_lugar_negocio.show();
}
//	Llama a la plantilla de esitar lugar negocio
function overlayEditarLugarNegocio(){
		cargarELN();
		editar_lugar_negocio.show();
}
//	Llama a la plantilla de confirmacion eliminar lugar negocio
function overlayDeleteLugarNegocio(){
		cargarDLN();
		delete_lugar_negocio.show();
}
// Cierra la ventana de confirmacion eliminar lugar negocio		
function salirDeleteLugarNegocio(){
	delete_lugar_negocio.hide();
}
//	Ciudad de ubicacion
function cambiarCiudadUbicacion(){
	masCiudadesUbicacion.cfg.setProperty("context", ["otra_ciudad_establecimiento", "bl", "bl", ["beforeShow"]]);
	mostrarDepartamentosUbicacionOverflow();
	masCiudadesUbicacion.show();
}
function cerrarCambiarCiudadUbicacion(){
	masCiudadesUbicacion.hide();
}
//	categoria Establecimiento
function cambiarCategoriaEstablecimiento(){
	otraCategoriaEstablecimiento.cfg.setProperty("context", ["otra_categoria_establecimiento", "bl", "bl", ["beforeShow"]]);
	mostrarCategoriasOverflow();
	otraCategoriaEstablecimiento.show();
}
function cerrarCambiarCategoriaEstablecimiento(){
	otraCategoriaEstablecimiento.hide();
}

//	Llama a la plantilla de crear una categoria de productos para su lugar o negocio
function overlayNuevaCategoria(){
		cargarNCP();
		categoria_producto.show();
}
function cerrarOverlayNuevaCategoria(){
	categoria_producto.hide();
}

//	Llama a la plantilla de editar una categoria de productos para su lugar o negocio
function overlayEditarCategoria(idcategoria){
		cargarECP(idcategoria);
		categoria_producto.show();
}
function cerrarOverlayEditarCategoria(){
	categoria_producto.hide();
}

//	Llama a la plantilla de crear un nuevo producto para su lugar o negocio
function overlayNuevoProducto(idcategoria){
		cargarNPN(idcategoria);
		producto_negocio.show();
}
function overlayNuevoProductoDireccion(idelemento, idcategoria){
		cargarNPD(idelemento, idcategoria);
		producto_negocio.show();
}
function cerrarOverlayNuevoProducto(){
	producto_negocio.hide();
}

//	Llama a la plantilla de editar un nuevo producto para su lugar o negocio
function overlayEditarProducto(idproducto){
		cargarEPN(idproducto);
		producto_negocio.show();
}
function overlayEditarProductoDireccion(idelemento, idproducto){
		cargarEPD(idelemento, idproducto);
		producto_negocio.show();
}
function cerrarOverlayEditarProducto(){
	producto_negocio.hide();
}

//	Llama a la plantilla de editar un nuevo producto para su lugar o negocio
function overlayImagenNegocio(idelemento){
		cargarNIN(idelemento);
		imagen_negocio.show();
}
function overlayImagenDireccion(idelemento){
		cargarNID(idelemento);
		imagen_negocio.show();
}
function cerrarOverlayImagenNegocio(){
	imagen_negocio.hide();
}


//	Llama a la plantilla de nueva direccion del Negocio
function overlayNuevaDireccion(){
		cargarNDN();
		direccion_negocio.show();
}
function overlayEditarDireccion(idsucursal){
		cargarEDN(idsucursal);
		direccion_negocio.show();
}
function cerrarOverlayDireccion(){
	direccion_negocio.hide();
}


//	Llama a la plantilla de realizar comentario
function comentarOverlay(){
		cargarComentar();
		comentar_overlay.show();
}
function cerrarComentarOverlay(){
	comentar_overlay.hide();
}

//	Llama a la plantilla de realizar comentario
function recomendarOverlay(id, tipo){
		cargarEnviarA(id, tipo);
		recomendar_overlay.show();
}
function cerrarRecomendarOverlay(){
	recomendar_overlay.hide();
}

//	Llama a la plantilla de confirmacion de gusrdar
function guardarFavoritosOverlay(id){
		cargarGuardarFavoritos(id);
		gFavoritos_overlay.show();
}
function cerrarGuardarFavoritosOverlay(){
	gFavoritos_overlay.hide();
}


//	Llama a la plantilla de imprimir
function imprimirOverlay(id){
		cargarElementoImpresion(id);
		imprimir_overlay.show();
}
function cerrarImprimirOverlay(){
	imprimir_overlay.hide();
}



//	Llama a la plantilla de productos
function productosOverlay(idelemento, idcategoria){
		cargarProductos(idelemento, idcategoria);
		productos_overlay.show();
}
function cerrarProductosOverlay(){
	productos_overlay.hide();
}

function verVideoTutorial(url){
	cargarVideoTutorial(url);
	video_overlay.show();
}