var fxGeneral, fxResponse, prevOpacity=0;
var toContact, currentItem = 0;

function alertResults(){	
	fxResponse.start({
		'opacity':[1,0]
	}).addEvent('onComplete', function(){
		$('sbContact').disabled = false;
	});
}


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

	var theProducts= new iCarousel("products", {  
    idPrevious: "leftArrow",  
    idNext: "rightArrow",
		idToggle: "undefined", 
		item: {
			klass: "productBox",
			size: 960 
		},
		animation: {  
				type: "scroll",  
				duration: 500,  
				amount: 1  
		}		
	});
	
	$('icon1').setStyle('opacity', 1);
	theProducts.goTo(0);
	$('generalTab0').setStyle('opacity', 1);
	
	
	$ES('li', 'iconNavigation').addEvent('click', function(e){
		new Event(e).stop();
		theProducts.goTo(this.value);
		currentItem = this.value;
	}); 
	
	$('rightArrow').addEvent('click', function(){
		currentItem++;
		if(currentItem>5) currentItem=0;
	});
	
	$('leftArrow').addEvent('click', function(){
		currentItem--;
		if(currentItem<0) currentItem=5;			 
	});
	
	
	$ES('li', 'generalInformationNavigation').addEvent('click', function(e){
		$$('.generalSet').setStyle('display', 'none');
		$ES('li', 'generalInformationNavigation').setStyle('opacity', .5);
		this.setStyle('opacity', 1);
		
		fxGeneral.start({
			'background-color': ['#fff040', '#fff'],
			'opacity':[.2,1]
		});
		$('generalSet'+this.value).setStyle('display', 'block');				
	});
	
	
	$$('.generalSet').setStyle('display', 'none');
	$('generalSet0').setStyle('display', 'block');
	
	fxGeneral = new Fx.Styles($('generalInformation'), {
		duration: 1000,
		wait: false,
		transition:  Fx.Transitions.Sine.easeInOut
	});
	
	fxResponse = new Fx.Styles($('contactFormResponse'), {
		duration: 10000,
		wait: false,
		transition:  Fx.Transitions.Sine.easeInOut
	});
	
	myShow = new Slideshow('theSlideshow', {hu: 'images/galeria/', images: ['cuponera.jpg','salon.jpg','galeria.jpg','menu.jpg', 'ratings.jpg', 'map.jpg'], type: 'combo', pan: 'rand', zoom: 'rand', navigation: 'thumbnails', height:200, width:300});
	
	var contactFormSlider =  new Fx.Slide('contactForm', { duration: 1000, transition: Fx.Transitions.Bounce.easeOut}).show();
	toContact = new Fx.Scroll(window, {wait: true});
	
	$('buyNow').addEvent('click', function(e){
		new Event(e).stop();
		$('product_'+currentItem).checked = true;		
		contactFormSlider.slideIn().addEvent('onComplete', function(){
			toContact.toElement('contactForm');
		});
		$('txName').focus();
	});
	
	$('contactUs').cloneEvents($('buyNow'), 'click');
	
	$('closeContactForm').addEvent('click', function(){
		contactFormSlider.slideOut().addEvent('onComplete', function(){
			toContact.toTop();
		});
	});
	
	$('frmContact').addEvent('submit', function(e){
		new Event(e).stop();
		$('sbContact').disabled = 'disabled';
		var frmDiloCommentsErrors = '';
		if($('txName').value =='' || $('txName').value =='nombre') frmDiloCommentsErrors = 'Por favor escriba su Nombre.';
		if (frmDiloCommentsErrors == ''){
			this.send({
				onComplete: alertResults,
				update: 'contactFormResponse',
				evalScripts:'true'				
			});				
		} else {
			alert(frmDiloCommentsErrors);
		}
	});
	

		
	
	
});
