// JavaScript Document
var numeroPaginasMenu1 = 0;
var numeroPaginasMenu2 = 0;
var numeroPaginasMenu3 = 0;
var numeroPaginasMenu4 = 0;
var numeroPaginasMenu5 = 0;
var numeroPaginasMenu6 = 0;
var numeroPaginasMenu7 = 0;

var totIncrement = 0;
var totIncrement2 = 0;
var totIncrement3 = 0;
var totIncrement4 = 0;
var totIncrement5 = 0;
var totIncrement6 = 0;
var totIncrement7 = 0;
var increment = 228;

var initMultiBox = null;

function mueveImagen(imagen) {
    initMultiBox.move(imagen);
    //alert(entro);
}

window.addEvent('domready', function() {
	
	

	initMultiBox = new multiBox({
		mbClass: '.mb',//class you need to add links that you want to trigger multiBox with (remember and update CSS files)
		container: $(document.body),//where to inject multiBox
		descClassName: 'multiBoxDesc',//the class name of the description divs
		path: './Files/',//path to mp3 and flv players
		useOverlay: true,//use a semi-transparent background. default: false;
		maxSize: {w:1000, h:800},//max dimensions (width,height) - set to null to disable resizing
		addDownload: true,//do you want the files to be downloadable?
		pathToDownloadScript: './Scripts/forceDownload.asp',//if above is true, specify path to download script (classicASP and ASP.NET versions included)
		addRollover: true,//add rollover fade to each multibox link
		addOverlayIcon: true,//adds overlay icons to images within multibox links
		addChain: true,//cycle through all images fading them out then in
		recalcTop: true,//subtract the height of controls panel from top position
		addTips: true,//adds MooTools built in 'Tips' class to each element (see: http://mootools.net/docs/Plugins/Tips)
		autoOpen: 0//to auto open a multiBox element on page load change to (1, 2, or 3 etc)
	});

	
	
	
    /* MENU PRODUCTOS */
    var maxRightIncrement = increment * (-numeroPaginasMenu1);
    var maxRightIncrement2 = increment * (-numeroPaginasMenu2);
    var maxRightIncrement3 = increment * (-numeroPaginasMenu3);
    var maxRightIncrement4 = increment * (-numeroPaginasMenu4);
    var maxRightIncrement5 = increment * (-numeroPaginasMenu5);
    var maxRightIncrement6 = increment * (-numeroPaginasMenu6);
    var maxRightIncrement7 = increment * (-numeroPaginasMenu7);
	
	
	var fx = new Fx.Morph('slider-menu1', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx2 = new Fx.Morph('slider-menu2', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx3 = new Fx.Morph('slider-menu3', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx4 = new Fx.Morph('slider-menu4', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx5 = new Fx.Morph('slider-menu5', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx6 = new Fx.Morph('slider-menu6', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx7 = new Fx.Morph('slider-menu7', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});


    //-------------------------------------
    // EVENTS for the button "previous"
	
	
    $('previous1').addEvents({
        'click': function(event) {
			//alert(totIncrement);
            if (totIncrement < 0) {
               totIncrement = totIncrement + increment;
                fx.start({ 'margin-left':totIncrement});
				//alert(totIncrement);
            }
        }
    });
    $('previous2').addEvents({
        'click': function(event) {
            if (totIncrement2 < 0) {
                totIncrement2 = totIncrement2 + increment;
				//fx2.stop()
                fx2.start({ 'margin-left':totIncrement2});
            }
        }
    });
    $('previous3').addEvents({
        'click': function(event) {
            if (totIncrement3 < 0) {
                totIncrement3 = totIncrement3 + increment;
				//fx2.stop()
                fx3.start({ 'margin-left':totIncrement3});
            }
        }
    });
    $('previous4').addEvents({
        'click': function(event) {
            if (totIncrement4 < 0) {
                totIncrement4 = totIncrement4 + increment;
				//fx2.stop()
                fx4.start({ 'margin-left':totIncrement4});
            }
        }
    });
    $('previous5').addEvents({
        'click': function(event) {
            if (totIncrement5 < 0) {
                totIncrement5 = totIncrement5 + increment;
				//fx2.stop()
                fx5.start({ 'margin-left':totIncrement5});
            }
        }
    });
    $('previous6').addEvents({
        'click': function(event) {
            if (totIncrement6 < 0) {
                totIncrement6 = totIncrement6 + increment;
				//fx2.stop()
                fx6.start({ 'margin-left':totIncrement6});
            }
        }
    });
    $('previous7').addEvents({
        'click': function(event) {
            if (totIncrement2 < 0) {
                totIncrement2 = totIncrement2 + increment;
				//fx2.stop()
                fx2.start({ 'margin-left':totIncrement2});
            }
        }
    });
    $('previous2').addEvents({
        'click': function(event) {
            if (totIncrement7 < 0) {
                totIncrement7 = totIncrement7 + increment;
				//fx2.stop()
                fx7.start({ 'margin-left':totIncrement7});
            }
        }
    });
	
	
	
	
	

    //-------------------------------------
    // EVENTS for the button "next"
	
	
	
	
	
	
	 $('next1').addEvents({
        'click': function(event) {
			//alert(totIncrement);
				if (totIncrement > maxRightIncrement) {
                totIncrement = totIncrement - increment;
                //fx.stop()
				fx.start({ 'margin-left':totIncrement});
				//alert(totIncrement);
            }
        }
    })
	$('next2').addEvents({
        'click': function(event) {
            if (totIncrement2 > maxRightIncrement2) {
                totIncrement2 = totIncrement2 - increment;
                //fx2.stop()
                fx2.start({ 'margin-left':totIncrement2});
				//alert(totIncrement2);
            }
        }
    })
	$('next3').addEvents({
        'click': function(event) {
            if (totIncrement3 > maxRightIncrement3) {
                totIncrement3 = totIncrement3 - increment;
                //fx2.stop()
                fx3.start({ 'margin-left':totIncrement3});
				//alert(totIncrement2);
            }
        }
    })
	$('next4').addEvents({
        'click': function(event) {
            if (totIncrement4 > maxRightIncrement4) {
                totIncrement4 = totIncrement4 - increment;
                //fx2.stop()
                fx4.start({ 'margin-left':totIncrement4});
				//alert(totIncrement2);
            }
        }
    })
	$('next5').addEvents({
        'click': function(event) {
            if (totIncrement5 > maxRightIncrement5) {
                totIncrement5 = totIncrement5 - increment;
                //fx2.stop()
                fx5.start({ 'margin-left':totIncrement5});
				//alert(totIncrement2);
            }
        }
    })
	$('next6').addEvents({
        'click': function(event) {
            if (totIncrement6 > maxRightIncrement6) {
                totIncrement6 = totIncrement6 - increment;
                //fx2.stop()
                fx6.start({ 'margin-left':totIncrement6});
				//alert(totIncrement2);
            }
        }
    })
	$('next7').addEvents({
        'click': function(event) {
            if (totIncrement7 > maxRightIncrement7) {
                totIncrement7 = totIncrement7 - increment;
                //fx2.stop()
                fx7.start({ 'margin-left':totIncrement7});
				//alert(totIncrement2);
            }
        }
    })

});


//eventos para desplazar ciclico
function desplaza_menu(consecutivo, repeticiones) {
    //debo saver que consecutivo es?
    //alert('entra');

    var maxRightIncrement = increment * (-numeroPaginasMenu1);
    var maxRightIncrement2 = increment * (-numeroPaginasMenu2);
    var maxRightIncrement3 = increment * (-numeroPaginasMenu3);
    var maxRightIncrement4 = increment * (-numeroPaginasMenu4);
    var maxRightIncrement5 = increment * (-numeroPaginasMenu5);
    var maxRightIncrement6 = increment * (-numeroPaginasMenu6);
    var maxRightIncrement7 = increment * (-numeroPaginasMenu7);
	

	var fx = new Fx.Morph('slider-menu1', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx2 = new Fx.Morph('slider-menu2', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx3 = new Fx.Morph('slider-menu3', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx4 = new Fx.Morph('slider-menu4', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx5 = new Fx.Morph('slider-menu5', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx6 = new Fx.Morph('slider-menu6', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});
	var fx7 = new Fx.Morph('slider-menu7', { 'duration': 1000, 'transition':Fx.Transitions.Back.easeInOut, 'link': 'cancel'});

    var mover = (repeticiones-1) * increment;

    if (consecutivo == 1) {
        if (totIncrement > maxRightIncrement) {
            totIncrement -= mover;
            fx.start({ 'margin-left':totIncrement});
        }
    }

    if (consecutivo == 2) {
        if (totIncrement2 > maxRightIncrement2) {
            totIncrement2 -= mover;
            //alert(totIncrement);
           // fx2.stop()
            fx2.start({ 'margin-left':totIncrement2});
        }
    }

    if (consecutivo == 3) {
        if (totIncrement3 > maxRightIncrement3) {
            totIncrement3 -= mover;
            //alert(totIncrement);
            //fx3.stop()
            fx3.start({ 'margin-left':totIncrement3});
        }
    }

    if (consecutivo == 4) {
        if (totIncrement4 > maxRightIncrement4) {
            totIncrement4 -= mover;
            //alert(totIncrement);
            //fx4.stop()
            fx4.start({ 'margin-left':totIncrement4});
        }
    }

    if (consecutivo == 5) {
        if (totIncrement5 > maxRightIncrement5) {
            totIncrement5 -= mover;
            //alert(totIncrement);
           // fx5.stop()
            fx5.start({ 'margin-left':totIncrement5});
        }
    }


    if (consecutivo == 6) {
        if (totIncrement6 > maxRightIncrement6) {
            totIncrement6 -= mover;
            //alert(totIncrement);
            fx6.stop()
            fx6.start({ 'margin-left':totIncrement6});
        }
    }


    if (consecutivo == 7) {
        if (totIncrement7 > maxRightIncrement7) {
            totIncrement7 -= mover;
            //alert(totIncrement);
           // fx7.stop()
            fx7.start({ 'margin-left':totIncrement7});
        }
    }
    
}




/* SCRIPT PARA MENU DE PRODUCTOS*/

var idSeccion = '';
var idMenu = '';
var idMenuInOut = '';
var currPoss = 0;

/*
var cuantosHay = document.getElementById(idSeccion);
var cuantos = cuantosHay.getElementsByTagName("a");
var nuevoAncho = cuantos.length;
*/







var submenuProductos=new Array();
submenuProductos[0] = "menu1";
submenuProductos[1] = "menu2";
submenuProductos[2] = "menu3";
submenuProductos[3] = "menu4";
submenuProductos[4] = "menu5";
submenuProductos[5] = "menu6";
submenuProductos[6] = "menu7";

var colorMenuProductos=new Array();
colorMenuProductos[0] = "menuCategoria1";
colorMenuProductos[1] = "menuCategoria2";
colorMenuProductos[2] = "menuCategoria3";
colorMenuProductos[3] = "menuCategoria4";
colorMenuProductos[4] = "menuCategoria5";
colorMenuProductos[5] = "menuCategoria6";
colorMenuProductos[6] = "menuCategoria7";



function abreMenu(idSeccion,idMenu){	
	
	for (i = 0; i < 7; i++) {
		if (idSeccion == submenuProductos[i]) {
			var toogleShow = document.getElementById(submenuProductos[i]);
			if ( toogleShow.style.display != 'none' ) {
				clear();
				toogleShow.style.display = 'none';
				document.getElementById(colorMenuProductos[i]).style.backgroundColor = '#AA9F99';
				document.getElementById(colorMenuProductos[i]).style.backgroundImage = "url(imagenes/bullet-flecha-up.gif)";
			} else {
				toogleShow.style.display = '';
				document.getElementById(colorMenuProductos[i]).style.backgroundColor = '#db772c';
				document.getElementById(colorMenuProductos[i]).style.backgroundImage = "url(imagenes/bullet-flecha-down.gif)";
			}
			
		} else {
			document.getElementById(submenuProductos[i]).style.display = 'none';
			document.getElementById(colorMenuProductos[i]).style.backgroundColor = '#AA9F99';
			document.getElementById(colorMenuProductos[i]).style.backgroundImage = "url(imagenes/bullet-flecha-up.gif)";
		}
	} 
}
function clear() {
	idMenu='';
}
function over(idMenuOver) {
	document.getElementById(idMenuOver).style.backgroundColor = '#db772c';
}
function out(idMenuOut) {
	if (idMenu != idMenuOut) {
		document.getElementById(idMenuOut).style.backgroundColor = '#AA9F99';
	} 
}


/* CARGA MAPA */

function cargaMapa() {

    var obj = document.getElementById('iFrameIomabe');
    var pagina=document.getElementById('mapa').options[document.getElementById('mapa').selectedIndex].value;
    obj.src = pagina;
    //alert(pagina);
}



function iniciaScroll () {	

	/* OBTIENE TAMAÑO DE LA IMAGEN EN PRODUCTOS Y ACTUALIZA LA FICHA */
	  
	var imgWidth = document.getElementById("info-imagen").offsetWidth;
	var parsedImgWidth = parseInt(imgWidth);
	var espacio = 580;
	var fichaWidthNew = espacio - parsedImgWidth;
	   
	document.getElementById("info-ficha").style.width = fichaWidthNew+'px';
	document.getElementById("info-scroll").style.width = (fichaWidthNew-15)+'px';
	
	
	/* INCREMENTA EL MARGEN DE LA IMAGEN GRANDE PARA ELINEARLA ABAJO*/
	
	/*
	var imgHeight = document.getElementById("imagen-grande").offsetHeight;
	var parsedImgHeight = parseInt(imgHeight);
	var espacioHeight = 271;
	var margenImgTop = espacioHeight - parsedImgHeight;
	
	document.getElementById("imagen-grande").style.marginTop = margenImgTop+'px';
	*/
	
}

window.onload = iniciaScroll;


function taggAnaliticDd(idObj, preTag) {
    //alert('entro' + preTag);
    var obj = document.getElementById(idObj);
    var indice = obj.selectedIndex;
    var valor = obj.options[indice].value;
    var textoEscogido = obj.options[indice].text;
    //alert(textoEscogido);
    _gaq.push(['_trackEvent', preTag, textoEscogido]);
    
}


function taggAnaliticRedirecciona(preTag, tag, url) {
	_gaq.push(['_trackEvent', preTag, tag]);
	//alert('taggeo');
	document.location.href = url;
}






	   
	   


