/*
	4 spaces per tab, monospaced font
*/



// used in the home page

	function setupTheHomePage() {
	
		// setup the main cycle 
		$('#homepagePortfolioDesignSamples').cycle({ 
			fx:				'fade',				// the effect
			pause:  		0,					// pause if the mouse is over the image
			speed:			500,				// speed of the transition
			timeout:		0,					// how long to pause after a transition, 0 creates a manual slideshow
			next:			'#arrowNext',		// id of the next button
			prev:			'#arrowPrevious'	// id of the previous button
		});
	
	
		// manage the Next and Previous buttons' events
		$('#arrowPrevious')	.fadeIn(800);
		$("#arrowPrevious")	.mousedown( function () { $(this).attr({ src: 'resources/miscellaneous/arrowPreviousActive.gif'	});});
		$("#arrowPrevious")	.mouseup(   function () { $(this).attr({ src: 'resources/miscellaneous/arrowPrevious.gif' 		});});
		$("#arrowPrevious")	.hover(
			function () 	{ $(this).attr({ src: 'resources/miscellaneous/arrowPreviousHover.gif' 	});}, 
			function () 	{ $(this).attr({ src: 'resources/miscellaneous/arrowPrevious.gif' 		});}	);
	
		$('#arrowNext')		.fadeIn(800);
		$("#arrowNext")		.mousedown( function () { $(this).attr({ src: 'resources/miscellaneous/arrowNextActive.gif'		});});
		$("#arrowNext")		.mouseup(   function () { $(this).attr({ src: 'resources/miscellaneous/arrowNext.gif'			});});
		$("#arrowNext")		.hover(
			function () 	{ $(this).attr({ src: 'resources/miscellaneous/arrowNextHover.gif'		});}, 
			function () 	{ $(this).attr({ src: 'resources/miscellaneous/arrowNext.gif' 			});}	);
	
	
		// for the mini cycle
		$('#mini-design-web-graphic-interface-portfolio').cycle({ 
			fx:				'fade',				// the effect
			pause:  		1,					// pause if the mouse is over the image
			speed:			750,				// speed of the transition
			timeout:		3000				// how long to pause after a transition
		});
		
	}




// used in the contact page

	function setupTheContactPage() {
		document.forms.LRCommunicationDesignContactForm.elements['name'].focus();
	}
	
	
	var gEmailRegEx				= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/ ;
	
	function validateTheContactForm() {
	
		var invalidFields		= '';
		var fieldToFocus		= '';
	
		if (document.forms.LRCommunicationDesignContactForm.elements['name'].value.length == 0) {
			invalidFields		+= 'FULL NAME\r';
			fieldToFocus		= 'name'; }
	
		var visitorsEmailEntry	= document.forms.LRCommunicationDesignContactForm.elements['email'].value ;
		var emailIsValid        = gEmailRegEx.test(visitorsEmailEntry);
		
		if (!emailIsValid) {
			invalidFields		+= 'EMAIL ADDRESS\r';
			if (!fieldToFocus)	{fieldToFocus	= 'email';}
		}
	
		if (invalidFields == '') {
			return true;
		} else {
			var multipleOrNot = '';
			if (invalidFields.length > 20) {multipleOrNot = 's'}
			var messageToVisitor	= 'Please complete the following field' + multipleOrNot + ':\r\r'
			messageToVisitor += invalidFields

			alert(messageToVisitor);
			
			if (fieldToFocus == 'name') {
				document.forms.LRCommunicationDesignContactForm.elements['name'].focus();
			} else {
				document.forms.LRCommunicationDesignContactForm.elements['email'].focus();
			}
			return false;
		}
	}


	function submitTheContactForm() {
	$('div#footer').css({marginTop: '500px'})
		$('#LRCommunicationDesignContactForm')
			.removeAttr('onSubmit')
			.removeAttr('action')
			.hide('fast', function(){showThankYouPanel()});
	}


	function showThankYouPanel() {
		$('body').scrollTop(0);
		$('#thankYouPanel p').append( '<strong>' + $('#email').val() + '</strong>.');  
		$('#thankYouPanel').fadeIn('fast');
	}



// setupTheBerettaBowdenPage

	function setupTheBerettaBowdenPage() {
		$('#Prev').fadeIn(100);
		$('#Next').fadeIn(100);
		$('#Schermo').cycle({ 
			fx:			'fade', 
			pause:  	1,
			speed:		95,
			timeout:	0,
			next:		'#Next',
			prev:		'#Prev'
		});
	}



