// JavaScript Document
// CONTROL VARIABLE
// state[0]: controls buy/sell
// state[1]: controls part/empr
// state[2]: controls sections (contactar, legal, ayuda)

var state = new Array('sell','part','');

// This function controls the buy/sell buttons
function buyOrSell(status,mouse){
	if (status != state[0]) {
		switch(mouse){
			case 'over':  
				if (status == 'buy'){filter('buy_0','comprar_on');}
				if (status == 'sell'){filter('sell_0','vender_on');}				
				break;
			case 'out':
				if (status == 'buy'){filter('buy_0','comprar_off');}
				if (status == 'sell'){filter('sell_0','vender_off');}
				break;
			case 'click':
				if (status == 'buy'){
					filter('buy_0','comprar_on');
					filter('sell_0','vender_off');
					filter('seccion01','insertar_off');
					filter('seccion02','contactar_off');
					filter('seccion03','legal_off');
					filter('seccion04','ayuda_off');         
					filter('imgXL','comprar_G2');
					state[2]='seccion00';
					state[0]='buy';					
				}
				if (status == 'sell'){
					filter('sell_0','vender_on');			
					filter('buy_0','comprar_off');
					filter('seccion01','insertar_off');
					filter('seccion02','contactar_off');
					filter('seccion03','legal_off');
					filter('seccion04','ayuda_off');			
					filter('imgXL','vender_G2');
					state[2]='seccion00';						
					state[0]='sell';
				}						
				break;														
		}			
	}
}

// This function controls the section buttons
function setSections(status,mouse){
	if (status != state[2]) {
		switch(mouse){
			case 'over':  
				if (status == 'seccion01'){filter('seccion01','insertar_on');}
				if (status == 'seccion02'){filter('seccion02','contactar_on');}
				if (status == 'seccion03'){filter('seccion03','legal_on');}
				if (status == 'seccion04'){filter('seccion04','ayuda_on');}
				break;
			case 'out':
				if (status == 'seccion01'){filter('seccion01','insertar_off');}
				if (status == 'seccion02'){filter('seccion02','contactar_off');}
				if (status == 'seccion03'){filter('seccion03','legal_off');}
				if (status == 'seccion04'){filter('seccion04','ayuda_off');}
				break;
			case 'click':
				if (status == 'seccion01'){
					sectionsOff();
					filter('buy_0','comprar_off');
					filter('sell_0','vender_off');						
					filter('seccion01','insertar_on');
					filter('imgXL','insertar_G2');
					// Reseteamos buy/sell
					state[0]='null';						
					// Actualizamos status con la sección insertar
					state[2]='seccion01';
				}
				if (status == 'seccion02'){
					sectionsOff();				
					filter('buy_0','comprar_off');
					filter('sell_0','vender_off');	
					filter('seccion02','contactar_on');
					filter('imgXL','contactar_G2');
					// Reseteamos buy/sell
					state[0]='null';						
					// Actualizamos status con la sección contactar						
					state[2]='seccion02';
				}
				if (status == 'seccion03'){
					sectionsOff();				
					filter('buy_0','comprar_off');
					filter('sell_0','vender_off');											
					filter('seccion03','legal_on');
					filter('imgXL','legal_G2');
					// Reseteamos buy/sell
					state[0]='null';						
					// Actualizamos status con la sección LEGAL						
					state[2]='seccion03';
				}
				if (status == 'seccion04'){
					sectionsOff();				
					filter('buy_0','comprar_off');
					filter('sell_0','vender_off');											
					filter('seccion04','ayuda_on');
					filter('imgXL','ayuda_G2');
					// Reseteamos buy/sell
					state[0]='null';						
					// Actualizamos status con la sección AYUDA						
					state[2]='seccion04';
				}								
				break;														
		}			
	}
}
// Turns to OFF all the sections
	function sectionsOff(){
	filter('seccion01','insertar_off');
	filter('seccion02','contactar_off');
	filter('seccion03','legal_off');
	filter('seccion04','ayuda_off');
}

// Pre-Load de las imágenes

function filter(imagename,objectsrc){
	document.images[imagename].src=eval(objectsrc+".src")
}

pixel = new Image(1,1)
pixel.src="img/common/1pixel.gif"
// COMPRAR / VENDER	
comprar_off= new Image(49,55)
comprar_off.src="img/common/vender_off.gif"
comprar_on= new Image(49,55)
comprar_on.src="img/common/vender_on.gif"

vender_off= new Image(49,55)
vender_off.src="img/common/comprar_off.gif"
vender_on= new Image(49,55)
vender_on.src="img/common/comprar_on.gif"

// SECCION INSERTAR
insertar_on= new Image(49,55)
insertar_on.src="img/common/insertar_on.gif"
insertar_off= new Image(49,55)
insertar_off.src="img/common/insertar_off.gif"

// SECCION CONTACTAR
contactar_on= new Image(85,28)
contactar_on.src="img/common/contactar_on.gif"
contactar_off= new Image(85,28)
contactar_off.src="img/common/contactar_off.gif"

// SECCION LEGAL
legal_on= new Image(85,28)
legal_on.src="img/common/legal_on.gif"
legal_off= new Image(85,28)
legal_off.src="img/common/legal_off.gif"

// SECCION AYUDA
ayuda_on= new Image(85,28)
ayuda_on.src="img/common/ayuda_on.gif"
ayuda_off= new Image(85,28)
ayuda_off.src="img/common/ayuda_off.gif"

// ICONOS GRANDES
contactar_G2= new Image(92,84)
contactar_G2.src="img/top/contactar_G2.gif"
legal_G2= new Image(92,84)
legal_G2.src="img/top/legal_G2.gif"
ayuda_G2= new Image(92,84)
ayuda_G2.src="img/top/ayuda_G2.gif"

insertar_G2= new Image(92,84)
insertar_G2.src="img/top/insertar_G2.gif"
comprar_G2= new Image(92,84)
comprar_G2.src="img/top/vender_G2.gif"
vender_G2= new Image(92,84)
vender_G2.src="img/top/comprar_G2.gif"




