$().ready(function() {
	
	$("ul.sf-menu").supersubs({ 
        minWidth:    15,   // minimum width of sub-menus in em units 
        maxWidth:    25,   // maximum width of sub-menus in em units 
        extraWidth:  1     // extra width can ensure lines don't sometimes turn over 
                           // due to slight rounding differences and font-family 
    }).superfish({
		delay:       500,                            // one second delay on mouseout 
        animation:   {
			opacity:'show',
			height:'show'
		},  // fade-in and slide-down animation 
        speed:       'fast',                          // faster animation speed 
        autoArrows:  false,                           // disable generation of arrow mark-up 
        dropShadows: true                             // disable drop shadows 	
	});
	
	$("ul.sf-menu > li a").each(function() { 
		if($(this).html().length >	20) {
			$(this).addClass('double');
		}
	});
	$("ul.sf-menu > li:last-child").addClass('last');
	
	//$(".pain").addClass("ui-corner-all");
	
	// round the curves
	if(!$.browser.msie) $("#content img").addClass("corner");
	$("#content img").addClass("iradius10");
	
	$("#form1").submit(function() {
		var email = $(".newsletter-email").val();
		
		// Validate
		if(validateEmail(email)){
			$("#form1").attr("action", "newsletter.php");
			return true;
		} 
		
		alert("Voer een geldig e-mailadres in");
		return false;
	});
	
	$("a[rel^='prettyPhoto']").prettyPhoto();
	$("a[rel^='lightbox']").prettyPhoto();
	
	// add styles
	$("#content img").css("margin-bottom", "5px");
	$("#content img").css("border", "1px solid #f19300");
	$("#content img").css("vertical-align", "top");
	$("#content img").css("-moz-border-radius", "10px");
	$("#content img").css("-webkit-border-radius", "10px");
	$("#content img").css("border-radius", "10px");
	
	//$("#wrapper, #newsletter, .pain").corner("20px");
	//$("#header").corner("top 20px");
	//$("#content").corner("bottom 20px");
	
	DD_roundies.addRule('#wrapper, #newsletter, .pain', '20px', true);
	DD_roundies.addRule('#header', '20px 20px 0 0', true);
	DD_roundies.addRule('#content', '0 0 20px 20px', true);
	DD_roundies.addRule('#content img', '10px', false);
});

/**
 * validate e-mail
 * 
 * @param elementValue
 * @returns
 */
function validateEmail(elementValue){
	var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
	return emailPattern.test(elementValue);
 }
