dojo.require("dojo.io.*");
dojo.require("dojo.event.*");
dojo.require("dojo.fx.*");

/////////////// Funcionalidad de Caja Buscadora 2 Colores /////////////////////
function inputBusquedaOn (){
	document.getElementById('input_busqueda').style.backgroundImage='url(/php-include/imgs/sombrabuscadorin.gif)';
	document.getElementById('input_busqueda').style.border='1px solid #7997FF';
}
function inputBusquedaOff (){
	document.getElementById('input_busqueda').style.backgroundImage='url(/php-include/imgs/sombrabuscador.gif)';
	document.getElementById('input_busqueda').style.border='1px solid #CCCCCC';
}

/////////////// Funcionalidad de Menu Avatar /////////////////////
function ocultarPorTiempoMenuImagen(zona) {

}
function mostrarMenuImagen(zona) {
	document.getElementById(zona).style.display='block';
}
function ocultarMenuImagen(zona) {
	document.getElementById(zona).style.display='none';
}

///////////// Funcionalidad de la Capa Promocion Ipod /////////////////
function muestraCapaPromo() {
	dojo.style.setOpacity(document.getElementById('capaPromoIpod'), 0);
	document.getElementById('capaPromoIpod').style.display = 'block';
    dojo.fx.html.fadeIn (document.getElementById('capaPromoIpod'),1000);
}

function ocultaCapaPromo() {
    dojo.fx.html.fadeHide (document.getElementById('capaPromoIpod'),1000);
}

/////////////////////// Funcionalidad de Feedback //////////////////////////////
function mostrarFeedback() {
    dojo.fx.html.fadeHide (document.getElementById('layer_loginbox'),300);
	dojo.style.setOpacity(document.getElementById('layer_feedback'), 0);
	document.getElementById('layer_feedback').style.display = 'block';
    dojo.fx.html.fadeIn (document.getElementById('layer_feedback'),1000);
}

function cerrarFeedback() {
    dojo.fx.html.fadeHide (document.getElementById('layer_feedback'),1000);
}

function feedbackCallback(type, data, evt)
{
	if (type == 'error')
		document.getElementById("layer_feedback_form").innerHTML = "Por razones técnicas, no nos es posible gestionar su comentario. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		document.getElementById("layer_feedback_form").innerHTML = data;
    }
}

function enviarFormFeedback() {
	dojo.io.bind({
	    url: "/php-include/procesar_feedback.php",
	    handler: feedbackCallback,
	    formNode: document.getElementById("form_feedback")
	});
}

////////////////////// Funcionalidad de Login Box //////////////////////////////
function mostrarLoginBox() {
    dojo.fx.html.fadeHide (document.getElementById('layer_feedback'),300);
	dojo.style.setOpacity(document.getElementById('layer_loginbox'), 0);
	document.getElementById('layer_loginbox').style.display = 'block';
    dojo.fx.html.fadeIn (document.getElementById('layer_loginbox'),1000);
}

function cerrarLoginBox() {
    dojo.fx.html.fadeHide (document.getElementById('layer_loginbox'),1000);
}

function loginBoxCallback(type, data, evt)
{
	if (type == 'error')
		document.getElementById("layer_loginbox_form").innerHTML = "<br /><br /><br />Por razones técnicas, no es posible iniciar sesión en Shoomo. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		tempData = data.split('***');
        if (tempData.length > 1) {
			document.getElementById(tempData[0]).innerHTML = tempData[1];
			document.getElementById(tempData[2]).innerHTML = tempData[3];
		    dojo.fx.html.fadeHide (document.getElementById('layer_loginbox'),2000);
        } else
			document.getElementById("layer_loginbox_form").innerHTML = data;		
    }
}

function enviarFormLoginBox() {
	dojo.io.bind({
	    url: "/php-include/procesar_loginbox.php",
	    handler: loginBoxCallback,
	    formNode: document.getElementById("form_loginbox")
	});
}


function loginBoxCallbackHOME(type, data, evt)
{
	if (type == 'error')
		document.getElementById("capalogin_container").innerHTML = "<br />Por razones técnicas, no es posible iniciar sesión en Shoomo. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		tempData = data.split('***');
        if (tempData.length > 1) {
			document.getElementById(tempData[0]).innerHTML = tempData[1];
			document.getElementById(tempData[2]).innerHTML = tempData[3];
			document.getElementById("capalogin_container").innerHTML = tempData[4];
		    dojo.fx.html.highlight (document.getElementById('capalogin_container'),2000);
        } else
			document.getElementById("capalogin_container").innerHTML = data;
    }
}

function enviarFormLoginBoxHOME() {
	dojo.io.bind({
	    url: "/php-include/procesar_loginbox_home.php",
	    handler: loginBoxCallbackHOME,
	    formNode: document.getElementById("form_loginboxHOME")
	});
}

function pedirLoginCallbackHOME(type, data, evt)
{
	if (type == 'error')
		document.getElementById("capalogin_container").innerHTML = "<br />Por razones técnicas, no nos es posible mandarle sus datos de acceso. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		document.getElementById("capalogin_container").innerHTML = data;
    }
}

function pedirDatosLoginHOME() {
	dojo.io.bind({
	    url: "/php-include/procesar_loginbox_home.php",
	    handler: pedirLoginCallbackHOME,
	    content: {accion: 'pedir_datos_usuario'}
	});
}

function pedirLoginCallback(type, data, evt)
{
	if (type == 'error')
		document.getElementById("layer_loginbox_form").innerHTML = "<br /><br /><br /><br /><br />Por razones técnicas, no nos es posible mandarle sus datos de acceso. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		document.getElementById("layer_loginbox_form").innerHTML = data;
    }
}

function pedirDatosLogin() {
	dojo.io.bind({
	    url: "/php-include/procesar_loginbox.php",
	    handler: pedirLoginCallback,
	    content: {accion: 'pedir_datos_usuario'}
	});
}

function enviarFormPedirDatos() {
	dojo.io.bind({
	    url: "/php-include/procesar_loginbox.php",
	    handler: pedirLoginCallback,
	    formNode: document.getElementById("form_loginbox")
	});
}
function eliminarLoginBoxCallback(type, data, evt)
{
	if (type == 'error') {
	} else {
		tempData = data.split('***');
        if (tempData.length > 1) {
			document.getElementById(tempData[0]).innerHTML = tempData[1];
			document.getElementById(tempData[2]).innerHTML = tempData[3];
        }
    }
}
function eliminarLoginBox(codigo) {
	dojo.io.bind({
	    url: "/php-include/cerrar_sesion.php",
	    handler: eliminarLoginBoxCallback,
	    content: {codigo: codigo}
	});
}

function eliminarLoginBoxHOMECallback(type, data, evt)
{
	if (type == 'error') {
	} else {
		tempData = data.split('***');
        if (tempData.length > 1) {
			document.getElementById(tempData[0]).innerHTML = tempData[1];
			document.getElementById(tempData[2]).innerHTML = tempData[3];
			document.getElementById("capalogin_container").innerHTML = tempData[4];
        }
    }
}

function eliminarLoginBoxHOME(codigo) {
	dojo.io.bind({
	    url: "/php-include/cerrar_sesion.php",
	    handler: eliminarLoginBoxHOMECallback,
	    content: {codigo: codigo}
	});
}

function verificarEnvioEmailCallback(type, data, evt)
{
	if (type == 'error')
		document.getElementById("enviar_email_div_errores").innerHTML = "<br />Por razones técnicas, no nos es posible mandarle su email. <br />Por favor, inténtelo más adelante.<br />El Equipo de Shoomo.com";
	else {
		tempData = data.split('***');
        if (tempData[0] == 'TRUE') {
			document.getElementById("enviar_email_div_errores").innerHTML = tempData[1] + "<br />";
        } else {
			document.getElementById("enviar_email_form").submit();
        }
    }
}

function verificarEnvioEmail() {
	dojo.io.bind({
	    url: "/php-include/procesar_envio_email.php",
	    handler: verificarEnvioEmailCallback,
	    formNode: document.getElementById("enviar_email_form")
	});
}