var currentPage = '/' + location.pathname.split( "/" )[1],
	links = [
		new Link( 'Portfolio 1',	'/' ),
		new Link( 'Portfolio 2',	'/portfolio2.html' ),
		new Link( 'Portfolio 3',	'/portfolio3.html' ),
		new Link( 'Portfolio 4',	'/portfolio4.html' ),
		new Link( 'Who am I?',		'/bio.html' ),
		new Link( 'Contact',		'/contact.html' )
	];

function Link( name, href )
{
	this.name = name;
	this.href = href;
	return this;
}

function listLinks()
{
	var out = '', thisLink, x;
	for ( x=0; x<links.length; x++ )
	{
		thisLink = links[x];
		out += '\n				<a href="' + thisLink.href + '">' + thisLink.name + '</a><br />';
	}
// Debug( out );
	return out;
}

function showHeader()
{
	var out = '\n<h1>JB<span>MAKE</span>UP</h1>'
			+ '\n<div id="page">'
			+ '\n	<div id="sandbox">'
			+ '\n		<div id="leftbar"><h2>Joanna Berdzinska</h2>' + listLinks() + '</div>';
	document.write( out );
// Debug( out );
}

function showFooter()
{
	var out = '</div></div>\n<div id="footer">site design  <a href="http://samrod.com">samrod shenassa</a></div>';
	document.write( out );
// Debug( out );
}

function populatePhotoSlideshows()
{
	sr.Slideshow(
		{
			container:	'jbMakeup',
			imgDir:		"/img/photos/",
			fadeRamp:	sr.Faders.smoothFade,
			arrows: 	[ '&lt;&lt;', '&gt;&gt;' ],
			autoplay:	true,
			delay:		4,
			counter:	'counter',
 			draggable:	false,
 			syncURL:	true,
			shortcuts:	true,
			slides:		slides
		}
	);
}


/*  C O N T A C T    F O R M */
function submitContact()
{
	var contactForm = document.forms.contactForm,
		emailField = contactForm.email.value;

	if ( contactForm.message.value.replace(/ /gi, '').length == 0 || contactForm.message.value == initialLabel )
	{
		alert( "Hey Einstein, you forgot to write a comment.");
		contactForm.message.select();
		return false;
	}
	else if ( emailField.length == 0 )
	{
		alert( "Please provide an email address." );
		contactForm.email.focus();
		return false;
	}
	else if ( emailField.search(/[0-9a-z\.\-]{1,64}@([a-z\d]\.|\-?[a-z\d])+\.[a-z]{2,4}$/gi) != 0 )
	{
		alert( "Invalid email address. Please check your entry.");
		contactForm.email.select();
		return false;
	}
	else contactForm.submit();
}

var initialLabel;
function initForm()
{
	var contactForm = document.forms.contactForm;
	initialLabel = contactForm.message.value + '';

	contactForm.message.select();
	bindEvent( contactForm.message, 'blur', function()
		{
			if ( contactForm.message.value.replace(/ /gi, '').length == 0 )
				contactForm.message.value = initialLabel;
		});
	bindEvent( contactForm.message, 'focus', function()
		{
			if ( contactForm.message.value = initialLabel )
				contactForm.message.select();
		});
}

