$(document).ready(function() {
		 
	var validate = $("#mailingForm").validate({
		errorClass: "error2",					
		rules: {
			email: {
				required: true,
				email: true
			}
		},
		messages: {
			email: {
				required: "Vul uw email adres in.",
				minlength: "Gebruik een geldig email."
			}                
		}, 
		submitHandler: function() {
			$("#mailingForm").ajaxSubmit({
				success: function() { 
					var email = document.getElementById("email").value;
					var companyurl = document.getElementById("companyurl").value;
					$("#edituser_feedback").load("/fiberplast.nl/index.php", { 	
						'loadRequestFront'	: 'loadRequestFront', 
						'object'			: 'loadRequestFront', 
						'function'			: 'addMailToDb',
						'email'				: email
					});
				} 
			});
		}
	});

	$("#topMenu").lavaLamp({
		fx: 'easeOutBack',
		speed: 600
	});
	
	$("#switcher #title").toggle(function() {
		$('#switcher').stop().animate( {marginBottom: "0px"}, 500, function() {
			$("#switcher #title").html('Enviro websites <img src="/fiberplast.nl/cfsystem/layout/images/min.png" />');
		});
	}, function(){
		$('#switcher').stop().animate( {marginBottom: "-340px"}, 500, function() {
			$("#switcher #title").html('Enviro websites <img src="/fiberplast.nl/cfsystem/layout/images/plus.png" />');
		});
	});
	
	$("#quicklinks img").hover(function() {
		$("#quicklinks img").not(this).stop().fadeTo('slow', 0.3);
	}, function(){
		$("#quicklinks img").not(this).stop().fadeTo('slow', 1);
	});
	
	$(".lightbox").fancybox({
		'titlePosition' : 'over',
		'transitionIn'	: 'elastic',
		'transitionOut'	: 'elastic',
		'titleFormat'   : function(title, currentArray, currentIndex, currentOpts) {
			return '<span id="fancybox-title-over">' + title + '</span>';
		}
	});

	if(is_mobile_device()){    
		$("#switcher").css('display', 'none');
	}

});

function is_mobile_device() {
    if (typeof window.onorientationchange != "undefined") {
        return true;
    }
    else {
        return false;
    }
}

function isiPhone(){     
	return (         
		(userAgent.indexOf("iPhone") != -1) ||         
		(userAgent.indexOf("iPad") != -1) ||         
		(userAgent.indexOf("iPod") != -1)    
	); 
} 

function slideSwitch() {
    var $active = $('#headerImage IMG.active');

    if ( $active.length == 0 ) $active = $('#headerImage IMG:last');

    // use this to pull the images in the order they appear in the markup
    var $next =  $active.next().length ? $active.next()
        : $('#headerImage IMG:first');

    $active.addClass('last-active');

    $next.css({opacity: 0.0})
        .addClass('active')
        .animate({opacity: 1.0}, 1000, function() {
            $active.removeClass('active last-active');
        });
}

$(function() {
    setInterval( "slideSwitch()", 5000 );
});

Cufon.replace('h1', { fontFamily: 'Helvetica Neue LT Std' });
Cufon.replace('h3', { fontFamily: 'Helvetica Neue LT Std' });
Cufon.replace('#slogan', { fontFamily: 'Helvetica Neue LT Light' });
Cufon.replace('.category_product h1', { fontFamily: 'Helvetica Neue LT Std', textShadow: '1px 1px #666666' });
Cufon.replace('.moreInfo_link a', { fontFamily: 'Helvetica Neue LT Std', textShadow: '1px 1px #333' });
Cufon.replace('.galleryContainer #contentTitle', { fontFamily: 'Helvetica Neue LT Std', textShadow: '1px 1px #333' });




