var currentPage = ( ie4 ) ? location.pathname.split(/\/|\./)[0] : location.pathname.split(/\/|\./)[1], gallery;

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

var Links = [
	new Link( '/',				'blog' ),
	new Link( '/bio.html',		'bio' ),
	new Link( '/resume.html',	'resume' ),
	new Link( '/smartbeauty',	'smart beauty' ),
	new Link( '/press',			'press' ),
// 	new Link( '/gallery',		'gallery' ),
	new Link( '/contact.html',	'contact' )
];

function showHeader()
{
	var out = '\n<div id="page">'
			+ '\n	<div id="header">'
// 			+ '\n		<a href="/" title="paige padgett blog"><img src="/img/logo_header_white.gif" width="260" height="92" alt="PAIGE PADGETT" id="headerLogo" border="0" /></a>'
			+ '\n		<h1>Green Beauty Expert</h1>'
			+ '\n		<div id="navbar" align="right">' + showNav() + '</div>'
			+ '\n	</div>'
			+ '\n	<div id="mainContent">';
	document.write( out );
// 	Debug( out );
}

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

function showNav()
{
	var noURLmatch = true,
		thisLink,
		out = '\n			<div id="search">'
			+ '\n				<form method="get" id="searchform" action="http://paigepadgett.com/">'
			+ '\n				<input type="text" value="search" name="s" id="s" class="textField" onfocus="this.value=\'\'" />'
			+ '\n				<input type="submit" id="searchsubmit" value="Go" />'
			+ '\n				</form></div>\n			';
	for ( var x=0; x < Links.length; x++ )
	{
		thisLink = Links[x];
		if ( currentPage == thisLink.name.replace(/ /, '') )
		{
			noURLmatch = false;
			out += '<div class="active">' + thisLink.name + '</div>';
		}
		else
		{
			out += '<a href="' + thisLink.href + '">' + thisLink.name + '</a>';
		}
	}
	return out;
}

function updateNav()
{
	if ( this != parent )
	{
		d("page", parent).style.height = 40 + d("pageHeight").offsetHeight + "px";
		window.resizeBy(-1,0);
		window.resizeBy(1,0);
	}

	d( top.previousTab, top ).className = "";
	d( currentPage, top ).className = "active";
	top.previousTab = currentPage;
}

var testimonialsObj,
	testimonials = 
	[
	"<br /><br />&quot;I look fantastic Paige. Thank You.&quot;",
	"Tim Gunn, Project Runway",

	"<br /><br />&quot;Paige is a purveyor of beauty and taste.&quot;",
	"Jillian Michaels, Health &amp; Wellness Coach",

	"&quot;Paige Padgett is remarkably talented. When it came time to launch my debut collection of cosmetics I knew that I needed her to collaborate on the product. Paige's unique vision, amazing color sense, attention to detail, and meticulous presentation has helped me realize a truly beautiful product.&quot;",
	'Randolph Duke, Designer',

	"<br />&quot;Paige has a unique sense of professionalism. She understands what is required from production while being sensitive to her subjects' needs.&quot;",
	"Carol Terranova MacDonal, EIC, The Biggest Loser",

	"<br /><br />&quot;What's so great about Paige is that she truly believes every woman is beautiful.&quot;",
	"Nina Davis, Makeup Artist",

	"<br />&quot;I instantly adored Paige.  I can call her for Print, Film or Broadcast, and know, without a doubt, that she will do an amazing job.  She is focused, fast, and clients love her!&quot;",
	"Michelle Bagnato, Producer",

	"<br />&quot;Paige instinctively knows what women want, but what sets her apart is that she knows exactly what they need!&quot;",
	"Randolph Duke, Designer",

	"&quot;Paige is on the pulse of the beauty scene. She is a pioneer in eco-friendly and safe cosmetics with an uncanny ability to forecast and predict trends. Paige revitalized and updated my makeup with her signature style giving me a fresh, modern and youthful look that helped catapult my career!&quot;",
	"Jillian Michaels, Health &amp; Wellness Coach",

	"<br /><br />&quot;The girls look fabulous!&quot;",
	"Blanca Gonzalez, Director of Sportswear, Nike"
	];

function buildTestimonials()
{
	var out = '';
	for ( var x=0; x < testimonials.length-1; x++ )
	{
		out += '\n\n<div>' + testimonials[x] + '\n<b>' + testimonials[x+1] + '</b></div>';
		x++;
	}
	d('testimonials').innerHTML = out;
}

function init()
{
// 	buildTestimonials();
// 	setTimeout( function() { testimonialsObj = new SlideshowObject( 'testimonials', 'div', 6, 6, smoothFade ) }, 1000 );
}

var totalGalleryWidth = 0;
function showGallery( galleryIndex )
{
	var out = '', currentGallery = gallery[ galleryIndex ];
	for ( var x=0; x < currentGallery.length; x++ )
		out += '<img id="' + currentGallery[x].replace(/(\.jpg)|-/gi, '') + '" src="/img/' + currentPage + '/' + currentGallery[x] + '" alt="" onload="expandGalleryPage(this)" />';
	d('gallery').innerHTML = out;
//Debug( out );
}

function expandGalleryPage( img )
{
	totalGalleryWidth += img.width + 90;
	document.body.style.width = totalGalleryWidth + 'px';
	d("gallery").style.width = totalGalleryWidth + 'px';

	fadeObj[ img.id ] = new FadeObj(img, quickFade );
	fadeObj[ img.id ].snapOff();
	fadeObj[ img.id ].fadeUp();

}

function showGalleryFrame()
{
	if ( ( mac && ie4 ) || (navigator.userAgent.indexOf( "iPhone" ) > -1 ) )
	{
		out = '<iframe id="galleryFrame" name="galleryFrame" src="galleryPix.html?gIndex=0" width="100%" height="440" frameborder="0" scrolling="auto"></iframe>';
	}
	else out = '<iframe id="galleryFrame" name="galleryFrame" src="galleryPix.html?gIndex=0" width="100%" height="400" frameborder="0" scrolling="no"></iframe>';
	out += '<br />\n<span class="help">move your mouse over the images to scroll</span>';
	document.write( out );
}
