var i = 0;
var interval;
var target;
$(document).ready(function(){
	target = $('#slideshow li');
	
	interval = setInterval(function (){fade()}, 3000);
	$('#slideshow').mouseover(function(){clearInterval(interval)});
	$('#slideshow').mouseout(function(){interval = setInterval(function (){fade()}, 3000);});
	$('#slideshow li').hide();
	$('#slideshow li:first-child').show();
	
	$('ul li:last-child').addClass('lastchild');
	
	$('.product-photo a, #main-product-photo').lightBox({});
	
	$('#navigation').superfish(); 
	
	$('.delte-link').click(function(){
		var answer = confirm("Are you sure?")
		if (answer){
			
		}
		else{
			return false;
		}
	});
	$('input[type="submit"]').click(function(event){
		var formError = false;
		$('input.required, textarea.required').each(function(key, value){
			if(value.value == '') {
				$(value).addClass('form-error');
				formError = true;
			}
			else $(value).removeClass('form-error');
		});
		if (formError) event.preventDefault();
	});
	
	$('#clientEmail').click(function(){
		if($(this).is(':checked')) {
			notice_clientEmail = mainEmail;
			$('#addEmails').css('display', 'block');
		}
		else {
			notice_clientEmail = '';
			$('#addEmails').css('display', 'none');
		}
	});
});

function fade() {
	$(target[i]).fadeOut('slow');
	i++;
	if (i >= target.length) i = 0;
	$(target[i]).fadeIn('slow');
}
