$(window).load(function() {
	$('#slider').nivoSlider({
		effect:'fade',
		slices:15,
		animSpeed:900,
		pauseTime:4000,
		startSlide:0, //Set starting Slide (0 index)
		directionNav:true, //Next & Prev
		directionNavHide:false, //Only show on hover
		controlNav:false, //1,2,3...
		controlNavThumbs:false, //Use thumbnails for Control Nav
		controlNavThumbsSearch: '.jpg', //Replace this with...
		controlNavThumbsReplace: '_thumb.jpg', //...this in thumb Image src
		keyboardNav:false, //Use left & right arrows
		pauseOnHover:true, //Stop animation while hovering
		manualAdvance:false, //Force manual transitions
		captionOpacity:0.8, //Universal caption opacity
		beforeChange: function(){},
		afterChange: function(){},
		slideshowEnd: function(){} //Triggers after all slides have been shown
	});
});

$(function() {
	$('.press-item-img a').lightBox();
	$('.press-item-img-flat a').lightBox();
	$('#product-img a').lightBox();
});

function validateForm () {
	var valid = true;
	var error_string = "";

	/* validate name */
	if (window.document.emailForm.message.value.length < 1) {
		error_string = "Please fill in your inquiry.\n";
		valid = false;		
	}

	/* check email */
	var regexp_email = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	if (!regexp_email.test(window.document.emailForm.email.value)) {
		error_string = "Please enter a valid email address.\n";
		valid = false;		
	}

	/* validate name */
	if (window.document.emailForm.name.value.length < 1) {
		error_string = "Please enter your name.\n";
		valid = false;		
	}

	if (valid == false) {
		alert (error_string);
	} else {
		document.emailForm.submit()
	}
}

// function for onfocus in contact page
$(document).ready(function() {
	$('.inputfield, .inputfield_text').addClass("idleField");
	$('.inputfield, .inputfield_text').focus(function() {
		$(this).removeClass("idleField").addClass("focusField");
		if (this.value == this.defaultValue){ 
			this.value = '';
		}
		if(this.value != this.defaultValue){
			this.select();
		}
	});
	$('.inputfield, .inputfield_text').blur(function() {
		$(this).removeClass("focusField").addClass("idleField");
		if ($.trim(this.value) == ''){
			this.value = (this.defaultValue ? this.defaultValue : '');
		}
	});
});			



