	/*
		4 spaces per tab, monospaced font
	*/



	// set the local namespace

	lrcd					= {}
	lrcd.vEmailRegEx		= /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/ ;



	lrcd.fSetupTheHomePage	= function () {

		// 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
		});

	}



	lrcd.fSetupTheContactPage = function () {
		$('form#LRCommunicationDesignContactForm').attr({'action': "http://www.lrcommunicationdesign.com/cgi-bin/xlsx2_tlj_lrcd.pl"});
		// the above is a decoy url. It won't send anything. Just before the actual submit via javascript the action is set to the real cgi script.
		document.forms.LRCommunicationDesignContactForm.elements['name'].focus();
	}

	
	lrcd.fValidateTheContactForm = function () {

		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        = lrcd.vEmailRegEx.test(visitorsEmailEntry);

		var visitorsnospamEntry	= document.forms.LRCommunicationDesignContactForm.elements['zsr74'].value ;
		var noSpamIsValid       = visitorsnospamEntry.toLowerCase() == "nospam";

		if (!emailIsValid) {
			invalidFields		+= 'EMAIL ADDRESS\r';
			if (!fieldToFocus)	{fieldToFocus	= 'email';}
		}

		if (!noSpamIsValid) {
			invalidFields		+= 'NOSPAM TEXT BOX\r';
			if (!fieldToFocus)	{fieldToFocus	= 'zsr74';}
		} else {
			$('#zsr74').val('nospam') ;
		}

		if (invalidFields == '') {		
			lrcd.fAddJSMarker();
			lrcd.fFixCommentsIfNecessary();
			$('form#LRCommunicationDesignContactForm').attr({'action': "http://www.lrcommunicationdesign.com/cgi-bin/gTZ37W-lrcd.pl"});
			return true;

		} else {
			var multipleOrNot = '';
			if (invalidFields.length > 20) {multipleOrNot = 's'}	// allows for all the checkboxes
			var messageToVisitor	= 'Please complete the following field' + multipleOrNot + ':\r\r'
			messageToVisitor += invalidFields

			alert(messageToVisitor);

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


		lrcd.fAddJSMarker = function () {
			var newInput								= $('<input type="hidden" name="jsval" value="js was used" />');
			$('form#LRCommunicationDesignContactForm')	.append(newInput);
		}


		lrcd.fFixCommentsIfNecessary = function () {

			var theirInput = $('textarea#comments').val();
			var flush = false;

			if (theirInput.indexOf('porn') != -1) {
				flush = true;
			};
			if (theirInput.indexOf('sex') != -1) {
				flush = true;
			};
			if (theirInput.length > 1999) {
				flush = true;
			};

			if (flush) {
				$('textarea#comments')						.val('---')
				var newInput								= $('<input type="hidden" name="spamNotice" value="This is probably spam" />');
				$('form#LRCommunicationDesignContactForm')	.append(newInput);
			}

		}

	

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

	


