// Home page testimonial snippet rotation

function randTestimonial() {
	var testimonial=new Array()
	testimonial[0] = "Alcrea is a trusted partner, and we consider them an extension of our team...";
	testimonial[1] = "A fun and competent group &mdash; responsive to our needs. Their team goes beyond...";
	testimonial[2] = "We love trusting Alcrea for our products. We know we're working with a company...";
	testimonial[3] = "What separates Alcrea Health from others in the sector is its people...";
	testimonial[4] = "We have been successfully working with Alcrea Health as one of our primary...";
	var testNum = testimonial.length;
	var whichtestimonial=Math.round(Math.random()*(testNum-1));
	document.write(testimonial[whichtestimonial]);
}


// Home page testimonial snippet rotation (Long Version)

function randTestimonial_long() {
	var testimonial=new Array()
	testimonial[0] = "Alcrea is a trusted partner, and we consider them an extension of our team. Our two organizations share the same commitment to quality. We appreciate that the sales team and the on-staff team of Ph.D. scientists collaborate to suggest science-based, creative and innovative ideas.";
	testimonial[1] = "A fun and competent group &mdash; responsive to our needs. Their team goes beyond building the professional relationship and adds a personal touch.";
	testimonial[2] = "We love trusting Alcrea for our products. We know we're working with a company who doesn't cut corners in product quality, which puts our mind at ease for the sake of our customers. Alcrea is committed to our relationship. They don't see us as just a customer, but as a partner.";
	testimonial[3] = "What separates Alcrea Health from others in the sector is its people and its manufacturing quality. The Alcrea team is incredibly professional and competent. We compete in a business built around meeting deadlines, and we couldn't be successful without the people at Alcrea.";
	testimonial[4] = "We have been successfully working with Alcrea Health as one of our primary supplement manufacturers for more than eight years. We originally chose Alcrea because of the company's commitment to quality manufacturing processes and customer service. ";
	var testNum = testimonial.length;
	var whichtestimonial=Math.round(Math.random()*(testNum-1));
	document.write(testimonial[whichtestimonial]);
}





// Form validation for contact page

function validate_email(field,alerttxt) {
	with (field) {
		apos=value.indexOf("@");
		dotpos=value.lastIndexOf(".");
		if ( apos < 1 || dotpos - apos < 2 ) { alert(alerttxt); return false; }
		else { return true; }
	}
}

function validate_field(field,alerttxt) {
	with (field) {
		if ( field.value == "" ) { alert(alerttxt); return false; } 
		else { return true; }
	}
}

function validate_form(thisform) {
	with (thisform) {
		if ( validate_email(email,"Please enter a valid email address.") == false ) { return false; }
		if ( validate_field(firstname,"Please enter your first name") == false ) { return false; }
		if ( validate_field(lastname,"Please enter your last name") == false ) { return false; }
		if ( validate_field(company,"Please enter your company name") == false ) { return false; }
	}
}

// Raptcha - Key & Lock

function raptcha() { var rndm = Math.floor(Math.random()*1000); document.contact.ivory.value = rndm; document.cookie = 'ebony=' + rndm  +';'; }

// Detect mobile devices for disabling of submenu animation

var isMobile = "false";
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/android/i)) || (navigator.userAgent.match(/blackberry/i))) { var isMobile = "true" }

// Gentlemen, start your engines...

$(document).ready(function(){

	$(".alcrea_header_default").fadeIn(1000);
	$(".alcrea_header_experience_developments").fadeIn(1000);
	$(".alcrea_header_products_commitment").fadeIn(1000);
	$(".alcrea_header_capabilities").fadeIn(1000);
	$(".alcrea_header_blog").fadeIn(1000);
	$("li.collaborative_experience").hover(
		function () { $("li.collaborative_experience .inactive").animate( { opacity: 0 }, 200 ); if (isMobile == "false"){ $("li.collaborative_experience .inner").animate( { marginTop: "-100px" }, 200 );} },
		function () { $("li.collaborative_experience div").animate( { opacity: 1 }, 200 ); if (isMobile == "false"){ $("li.collaborative_experience .inner").animate( { marginTop: "0px" }, 200 );} }
	);
	$("li.product_range").hover(
		function () { $("li.product_range .inactive").animate( { opacity: 0 }, 200 ); if (isMobile == "false"){ $("li.product_range .inner").animate( { marginTop: "-125px" }, 200 );} },
		function () { $("li.product_range div").animate( { opacity: 1 }, 200 ); if (isMobile == "false"){ $("li.product_range .inner").animate( { marginTop: "0px" }, 200 );} }
	);
	$("li.capacity_capabilities").hover(
		function () { $("li.capacity_capabilities .inactive").animate( { opacity: 0 }, 200 ); if (isMobile == "false"){ $("li.capacity_capabilities .inner").animate( { marginTop: "-75px" }, 200 );} },
		function () { $("li.capacity_capabilities div").animate( { opacity: 1 }, 200 ); if (isMobile == "false"){ $("li.capacity_capabilities .inner").animate( { marginTop: "0px" }, 200 );} }
	);
	$("li.new_developments").hover(
		function () { $("li.new_developments .inactive").animate( { opacity: 0 }, 200 ); },
		function () { $("li.new_developments div").animate( { opacity: 1 }, 200 ); }
	);
	$("li.commitment").hover(
		function () { $("li.commitment .inactive").animate( { opacity: 0 }, 200 ); },
		function () { $("li.commitment div").animate( { opacity: 1 }, 200 ); }
	);
	$("li.blog").hover(
		function () { $("li.blog .inactive").animate( { opacity: 0 }, 200 ); },
		function () { $("li.blog div").animate( { opacity: 1 }, 200 ); }
	);
	$("ul.inner li a").hover(
		function () { 
			$(this).find('img.navArrow').attr("src", "/images/nav/arrow_over.gif");
			$(this).find('img.navArrow').animate( { opacity: 1, marginLeft: "6px" }, 250 ); 
		},
		function () { 
			$(this).find('img.navArrow').attr("src", "/images/nav/arrow.gif");
			$(this).find('img.navArrow').animate( { opacity: 0, marginLeft: "0px" }, 250 ); 
		}
	);

	// Contact form slide

	var fboxHeight = ( $('.fboxInner').height() - 40 );
	function revealContact() { 
		$('.fboxOuter').animate( { height: fboxHeight, width: 508 }, 800, function() {} ); 
		$('.formFoot').animate( { width: 530 }, 800, function() {} ); 
	};
	function hideContact() { 
		$('.fboxOuter').animate( { height: 15, width: 308 }, 800, function() {} );
		$('.formFoot').animate( { width: 340 }, 800, function() {} );
	};
	$('.more').click(function() {
		$('.more').hide();
		$('.moreActive').show();
		revealContact();
	});
	$('.moreActive').click(function() {
		$('.more').show();
		$('.moreActive').hide();
		hideContact();
		$('html, body').animate({scrollTop:0}, 800);
	});
	$('.less').click(function() {
		$('.more').show();
		$('.moreActive').hide();
		hideContact();
		$('html, body').animate({scrollTop:0}, 800);
	});
		
//-- End document ready
});

