function randomFromInterval(from,to)
{
    return Math.floor(Math.random()*(to-from+1)+from);
}


$(document).ready(function(){
	
	$('div.bannerelement').rand().show();

	$('.bannertext').css({
		opacity: 0,
		left: (($(window).width() - $('.bannertext').outerWidth()) / 2) + $(window).scrollLeft() + ($('.bannertext').outerWidth() / 2) + "px"
	});
		
	$('.bannertext').animate({
		opacity: 1,
		top: "+=" + randomFromInterval(20,40)
	}, 3000);

	$('.bannerimg').animate({
		marginLeft: "+=" + randomFromInterval(80, 100),
		marginTop: "+=" + randomFromInterval(50,80)
	}, 3000);

	$('div#email-error').hide();
	$('div#title-error').hide();
	
	$('form#contact-form').submit(function(event) {
		$('input#email').css('backgroundColor', "#FFFFFF");
		$('div#email-error').hide();
		
		var re = new RegExp("^[a-zA-Z0-9\-_]+[a-zA-Z0-9\.\-_]*@[a-zA-Z0-9\-_]+\.[a-zA-Z\.\-_]{1,}[a-zA-Z\-_]+","i");
		if(!re.test($('input#email').val())) {
			$('input#email').css('backgroundColor', "#FBE3E4");
			$('div#email-error').show('slow');
			return (false);
		}
		
		if ($('input#email').val() == 'you@yourcompany.com') {
			$('input#email').css('backgroundColor', "#FBE3E4");
			$('div#email-error').show('slow');
			return (false);
		}
		
		if (!$('input#title').val()) {
			$('input#title').css('backgroundColor', "#FBE3E4");
			$('div#title-error').show('slow');
			return (false);
		}
		
		return (true);
	});
	
	if ($.browser.msie && $.browser.version == 6){
		$('div#no-ie').show();
	}
	
	$("#main").accordion({});
	
	$('a.show-image').colorbox({
		width: '70%',
		height: '70%'
	});
	
});
