if (document.images) {
 hom_on =new Image();  hom_on.src ="./img/menu/home2.jpg"; 
 hom_off=new Image();  hom_off.src="./img/menu/home.jpg";
 about_on =new Image();  about_on.src ="./img/menu/about2.jpg"; 
 about_off=new Image();  about_off.src="./img/menu/about.jpg"; 
 plants_on =new Image();  plants_on.src ="./img/menu/plants2.jpg"; 
 plants_off=new Image();  plants_off.src="./img/menu/plants.jpg";
 products_on =new Image();  products_on.src ="./img/menu/prod2.jpg"; 
 products_off=new Image();  products_off.src="./img/menu/prod.jpg"; 
 certificates_on =new Image();  certificates_on.src ="./img/menu/cert2.jpg"; 
 certificates_off=new Image();  certificates_off.src="./img/menu/cert.jpg";
 contact_on =new Image();  contact_on.src ="./img/menu/contact2.jpg"; 
 contact_off=new Image();  contact_off.src="./img/menu/contact.jpg"; 
 
}

function handleOver1() {
 	if (document.images) document.hom.src=hom_on.src;
}
function handleOver2() {
 	if (document.images) document.about.src=about_on.src;
}
function handleOver3() {
 	if (document.images) document.plants.src=plants_on.src;
}
function handleOver4() {
 	if (document.images) document.products.src=products_on.src;
}
function handleOver5() {
 	if (document.images) document.certificates.src=certificates_on.src;
}
function handleOver6() {
 	if (document.images) document.contact.src=contact_on.src;
}

function handleOut1() {
 	if (document.images) document.hom.src=hom_off.src;
}
function handleOut2() {
 	if (document.images) document.about.src=about_off.src;
}
function handleOut3() {
 	if (document.images) document.plants.src=plants_off.src;
}
function handleOut4() {
 	if (document.images) document.products.src=products_off.src;
}
function handleOut5() {
 	if (document.images) document.certificates.src=certificates_off.src;
}
function handleOut6() {
 	if (document.images) document.contact.src=contact_off.src;
}

window.addEvent('domready', function(){
new MultiBox('calendar', {useOverlay: 'true'});
new MultiBox('listado', {useOverlay: 'true'});

});

function ajax (url,div){
	$(div).load(url);	
}

function error (mensaje){
	$('alerta').innerHTML=mensaje+' <img src="img/error.png" />';
}

function exito (mensaje){
	$('alerta').innerHTML=mensaje+' <img src="img/exito.png" />';
}

function envia_contacto(){
	var regEmail = /^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/;
	name = $('name').get('value');
	lastname = $('lastname').get('value');
	mail = $('mail').get('value');
	
	country = $('country').get('value');
	city = $('city').get('value');
	
	subject = $('subject').get('value');
	other = $('other').get('value');
	comments = $('comments').get('value');
	word = $('word').get('value');
	verificador = $('verificador').get('value');
	
	if(name.trim() == '') {
		error('Please enter your Name');
		$('name').focus();
		return false;
	}
	else if(lastname.trim() == '') {
		error('Please enter your Lastname');
		$('lastname').focus();
		return false;
	}
	else if(mail.trim() == '') {
		error('Please enter your Mail');
		$('mail').focus();
		return false;
	}
	else if(!(mail.toUpperCase().match(regEmail))){
		error('Please enter a valid Mail');
		$('mail').focus();
		return false;
	}
	else if(subject.trim() == '') {
		error('Please select the subject to your contact');
		$('subject').focus();
		return false;
	}
	else if(subject == 'Other') {
		if (other.trim() == '') {
		error('Please select the subject to your contact');
		$('other').focus();
		return false;
		}
	}
	if(comments.trim() == '') {
		error('Please enter your comments');
		$('comments').focus();
		return false;
	}
	else if(word.trim() == '') {
		error('Please enter the Verification Word');
		$('word').focus();
		return false;
	}
	else if(word != verificador) {
		error('Please enter the Correct Verification Word');
		$('word').focus();
		return false;
	}
	else {
			var url = 'ajax/sendcontact.php?name=' + name + '&lastname=' + lastname + '&mail=' + mail + '&subject=' + subject + '&other=' + other + '&comments=' + comments + '&country=' + country + '&city=' + city;  
            var request = new Request({  
                    	url:url,  
                    	method:'post',  
                    	onComplete: function() {  
                        	exito('Your contact has been sent successfully'); 
                    }  
                 }).send();
		
	}

}

function estado_other(state){
	$('other').setProperty('disabled',state);
}

function enblanco(){
	$('other').setProperty('value','');
}

