/* Regular Expressions */
var telRegExp = /([0-9-]+){11}|([0-9]+){10}/; 
var timeRegExp = /^(\d{1,2}):(\d{2})$/;
var emailRegExp = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.([a-zA-Z]){2,4})$/;
var postcodeRegExp = /^([0-9]){4}([a-zA-Z]){2}$/;

/* Jquery */
$(document).ready(function(){

	$('#blocks').masonry({
		columnWidth: 243, 
		itemSelector: '.box'
	});

	var colors = ['#ff9bd5','#9ae36e','#ececec', '#8c5ea9', '#ffd857'];

	// .sort(function(){return 0.5 - Math.random()})
	
	$('#header_container, .submenu_tile.sale').css('background-color', colors[Math.floor(Math.random()*4)]);		
	
	/*$('#header_container').colorfader({
		css: 'background-color',
		colors: colors
	});*/
	
	if($('#contact_form').length > 0){
		$('#contact_form').validate();
	}
	if($('#newsletter_form').length > 0){
		$('#newsletter_form').validate();
	}	
	
	var menu = true;
	/*if($.browser.msie && $.browser.version=="7.0"){
		menu = false;
	}*/
	
	if(menu){
		$('#main_menu > ul > li > a').mouseover(function(){
			if(!$(this).hasClass('active')){
				$(this).next('ul').slideDown('fast');
				$(this).addClass('active');
				$(this).addClass('white');
			}
		}).mouseleave(function(){
			$(this).removeClass('active');
			var el = $(this).attr('id');
			close_main_menu(el);
		});
		
		$('#main_menu > ul > li > ul').mouseover(function(){
			$(this).addClass('active');
		}).mouseleave(function(){
			$(this).removeClass('active');
			var el = $(this).prev('.choose').attr('id');
			close_main_menu(el);
		});
	}
	
	/*$('#product_image').mouseover(function(){
		$('#product_image_thumbs').slideDown(500);
	}).mouseleave(function(){
		$('#product_image_thumbs').slideUp(500);
	});*/
	
});

function close_main_menu(el){
	
	setTimeout(function(){
		if(!$('#'+el).next('ul').hasClass('active') && !$('#'+el).hasClass('active')){
			$('#'+el).next('ul').slideUp('fast', function(){
				$('#'+el).removeClass('active');
				$('#'+el).removeClass('white');
			});
		}
	}, 200);
	
}

function initialize() {
	var myLatlng = new google.maps.LatLng(52.298691, 5.234919);
	var myOptions = {
		zoom: 12,
		center: myLatlng,
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map
	}); 
}
