// JavaScript Document

function checkForFlorida(obj)
{
	if (obj.options[obj.selectedIndex].value=='FL')
	{
		document.getElementById('city_input').style.display='none'
		document.getElementById('city_select').style.display='block'
	}
	else
		{
			document.getElementById('city_input').style.display='block'
			document.getElementById('city_select').style.display='none'
		}
}

function copyShippingAddress(source,dest,check) {
    if (check.checked) {
        document.getElementById(dest+'_firstname').value = document.getElementById(source+'_firstname').value;
        document.getElementById(dest+'_lastname').value = document.getElementById(source+'_lastname').value;
        document.getElementById(dest+'_address').value = document.getElementById(source+'_address').value;
        document.getElementById(dest+'_city').value = document.getElementById(source+'_city').value;
        document.getElementById(dest+'_zipcode').value = document.getElementById(source+'_zipcode').value;
        document.getElementById(dest+'_state_id').selectedIndex = document.getElementById(source+'_state_id').selectedIndex;
    }
}


// JavaScript Document
function addEffectMenuProduct()
{
	var links = $('menu_product').getElements('a');
	
	for(var i=0; i<links.length; i++)
	{
		links[i].effect('margin-left', { 'duration': 400, transition: Fx.Transitions.backOut }).start(-200, 0);
		if (links[i].className!='selected')
		{			
			links[i].addEvent('mouseover', function(){ 
				this.effect('padding-left', { 'duration': 200 }).start(20, 25); 
				this.effect('color', { 'duration': 200 }).start('34c4c8', '8F725A');
			});
			links[i].addEvent('mouseout', function(){ 
				this.effect('padding-left', { 'duration': 200 }).start(25, 0); 
				this.effect('color', { 'duration': 200 }).start('8F725A', '34c4c8');
			});																																			
		}
	}
}

if (window.addEvent) // uso mootools
{
	window.addEvent( 'domready', function(){
		$$( '.moreInfoWrapper' ).each(function(item){
			var thisSlider = new Fx.Slide( item.getElement( '.moreInfo' ), { duration: 500 } );
			thisSlider.hide();
			item.getElement( '.divToggle' ).addEvent( 'click', function(){ thisSlider.toggle(); } );
		} );
		$$( '.homeInfoWrapper' ).each(function(item){
			var style= new Fx.Style(item.getElement('.moreInfo'), 'opacity', {duration:500})			
			style.hide()
			item.getElement( '.divToggle' ).addEvent( 'click', function(){ 			
				if (item.getElement('.moreInfo').style.opacity==0)			
					style.start(0,1)
				if (item.getElement('.moreInfo').style.opacity==1)			
					style.start(1,0)
			} 
			);
		} );	
		
		$$(".highlight").each( function (item) {			
			if (item.id!="contact" && item.id!="products" && item.id!="product")
			{			
				var fx= new Fx.Style(item, 'opacity', {duration:500})
				item.addEvent("mouseover",function() {
					fx.stop()
					fx.start(1,0.3)
				})
				item.addEvent("mouseout",function() {
					fx.stop()
					fx.start(0.3,1)
				})			
			}
		})
        if ($('training_form')) 
        {
            var tfs = new Fx.Slide('training_form')
                if ($$('div.error_list').length==0)
                    tfs.hide()
                $('button_training').addEvent('click',function (ev) {
                  new Event(ev).stop()
                  tfs.toggle()
                })
        }
       });
       
    
}
else { //uso prototype/scriptaculous
	window.onload = function () {
		$$(".moreInfoWrapper").each(function (itemParent)
		{				
			itemParent.select(".divToggle").each(function (item)	{													
				item.up().select(".moreInfo")[0].parentNode.style.display="none";				
				Event.observe(item,"click",function(event) {																				
					if (item.up().select(".moreInfo")[0].parentNode.style.display=="none")
					{
						new Effect.SlideDown(item.up().select(".moreInfo")[0].parentNode)					
					}
					else {
						new Effect.SlideUp(item.up().select(".moreInfo")[0].parentNode)					
					}
				})							
			})
		})	
		$$(".highlight").each( function (item) {			
			if (item.id!="contact" && item.id!="products" && item.id!="product")
			{
				Event.observe(item,"mouseover", function(event){				
					new Effect.Fade(item.id,{duration:0.5,from:1,to:0.3})
					}							
				)			
				Event.observe(item,"mouseout", function(event){
					new Effect.Fade(item.id,{duration:0.5,from:0.3,to:1})
					}							
				)			
			}
		})					
	}
}


function changeTabOption(option) {
	eval('textos = '+"textos_"+option);
	$$(".optionTab").each(function (item) {
		item.className="optionTab"
		}
	)
	$$(".summaryOption").each(function (item) {
		item.style.display="none"
		}
	)	
	$("summary_option"+option).style.display="block"
	$("text").innerHTML = ""
	$("option"+option).parentNode.className= "optionTab selected";
}

function selectPhoto(elem,nro) {
	
	$('text').innerHTML='<h3>DESCRIPTION:</h3>'+textos[nro]
	$$('.menuItem').each(function (item) {
		item.className="menuItem"
	}
	)	
	myGallerySet.goTo(nro);
	elem.className="menuItem selected";	
}

function prevPhoto()
{
    nextIter = myGallerySet.currentIter-1;
    if (nextIter <= 0)
          nextIter = myGallerySet.maxIter - 1;
	selectPhoto($('photo'+nextIter),nextIter )
}

function nextPhoto()
{
    nextIter = myGallerySet.currentIter+1;
    if (nextIter >= myGallerySet.maxIter)
            nextIter = 1;
	selectPhoto($('photo'+nextIter),nextIter )
}