// Javascript for use with Thysse Printing site
// Written by Jeffrey Powell (jeff {with} geebodesign {dot} com)
// Some code copyright of its respective original authors (like the Adobe stuff)

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

/*
 * Yes, I know that these functions are all pretty much the same.  This job was rushed,
 * which is why I didn't do things like combining these functions into something a little
 * more uniform.  Ideally, I'd like to make all portfolios behave identically, regardless
 * of how many elements they contain.  Similarly, let's treat the little pop-up things
 * in the same manner across all pages, not with specific stuff for each page.
 */

function show_team_member(id) {
	// Reset graphics
	document.getElementById('team_jason').style.display="none";
	document.getElementById('team_julie').style.display="none";
	document.getElementById('team_bert').style.display="none";
	document.getElementById('team_patrick').style.display="none";
	document.getElementById('team_steve').style.display="none";
	
	// Reset text
	document.getElementById('team_name_jason').className="team_name";
	document.getElementById('team_name_julie').className="team_name";
	document.getElementById('team_name_bert').className="team_name";
	document.getElementById('team_name_patrick').className="team_name";
	document.getElementById('team_name_steve').className="team_name";
	
	if (id != '')
	{
		document.getElementById('team_' + id).style.display="block";
		document.getElementById('team_bubble').style.backgroundImage='url(images/team_office_bubble_' + id + '.gif)';
		document.getElementById('team_name_' + id).className="team_name_active";
	}
}

function show_shop_member(id) {
	// Reset graphics
	document.getElementById('shop_img_gary').src="images/shop_gary_off.jpg";
	document.getElementById('shop_img_shawn').src="images/shop_shawn_off.jpg";
	document.getElementById('shop_img_robert').src="images/shop_robert_off.jpg";
	document.getElementById('shop_img_scott').src="images/shop_scott_off.jpg";
	document.getElementById('shop_img_bill').src="images/shop_bill_off.jpg";
	document.getElementById('shop_img_steve').src="images/shop_steve_off.jpg";
	
	// Reset text
	document.getElementById('shop_name_gary').className="team_name static tan";
	document.getElementById('shop_name_shawn').className="team_name static tan";
	document.getElementById('shop_name_robert').className="team_name static tan";
	document.getElementById('shop_name_scott').className="team_name static tan";
	document.getElementById('shop_name_bill').className="team_name static tan";
	document.getElementById('shop_name_steve').className="team_name static tan";
	
	if (id != '')
	{
		document.getElementById('shop_img_' + id).src='images/shop_' + id + '_on.jpg';
		document.getElementById('shop_name_' + id).className="team_name_active static";
	}
}

function show_mascot(id) {
	// Reset images
	document.getElementById('mascot_lucy').style.display="none";
	document.getElementById('mascot_sadie').style.display="none";
	
	// Reset text
	document.getElementById('mascot_name_lucy').className="team_name";
	document.getElementById('mascot_name_sadie').className="team_name";
	
	if (id != '')
	{
		document.getElementById('mascot_' + id).style.display="block";
		document.getElementById('mascots_bubble').style.backgroundImage='url(images/team_mascots_bubble_' + id + '.gif)';
		document.getElementById('mascot_name_' + id).className="team_name_active";
	}
}
	
function show_history(id, caption) {
	
	// Update the hidden photo/caption
	document.getElementById(inactive + '_img').src='images/history/' + id + '.jpg';
	document.getElementById(inactive + '_text').innerHTML = caption;
	
	// Crossfade
	Effect.Queues.get('history').invoke('cancel');
	Effect.Fade(active, { duration: 1.5, from: 1.5, to: 0.0, queue: { scope: 'history' }});
	Effect.Appear(inactive, { duration: 1.5, from: 0.0, to: 1.5, queue: { scope: 'history' }});
	
	var tmpInactive = inactive;
	if (active == 'history_00')
	{
		inactive = 'history_01';
	}
	else
	{
		inactive = active;
	}
		
	active = tmpInactive;
}

function show_portfolio(id, caption) {
	// Reset selectors
	document.getElementById('portfolio_selector_01').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_02').src="images/portfolio/selector_off.gif";
//	document.getElementById('portfolio_selector_03').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_04').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_05').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_06').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_07').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_08').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_09').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_10').src="images/portfolio/selector_off.gif";
	
	// Pick selector
	document.getElementById('portfolio_selector_' + id).src="images/portfolio/selector_on.gif";
	
	// Update the hidden photo/caption
	document.getElementById(inactive + '_img').src='images/portfolio/' + id + '.jpg';
	document.getElementById(inactive + '_text').innerHTML = caption;
	
	
	// Crossfade
	Effect.Queues.get('portfolio').invoke('cancel');
	Effect.Fade(active, { duration: 1.0, from: 1.0, to: 0.0, queue: { scope: 'portfolio' }});
	Effect.Appear(inactive, { duration: 1.0, from: 0.0, to: 1.0, queue: { scope: 'portfolio' }});
	
	var tmpInactive = inactive;
	inactive = active;
	active = tmpInactive;
}

function show_letterpress_portfolio(id, caption) {
	// Reset selectors
	document.getElementById('portfolio_selector_01').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_02').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_03').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_04').src="images/portfolio/selector_off.gif";
	document.getElementById('portfolio_selector_05').src="images/portfolio/selector_off.gif";
	
	// Pick selector
	document.getElementById('portfolio_selector_' + id).src="images/portfolio/selector_on.gif";
	
	// Update the hidden photo/caption
	document.getElementById(inactive + '_img').src='images/letterpress_portfolio/' + id + '.jpg';
	document.getElementById(inactive + '_text').innerHTML = caption;
	
	
	// Crossfade
	Effect.Queues.get('portfolio').invoke('cancel');
	Effect.Fade(active, { duration: 1.0, from: 1.0, to: 0.0, queue: { scope: 'portfolio' }});
	Effect.Appear(inactive, { duration: 1.0, from: 0.0, to: 1.0, queue: { scope: 'portfolio' }});
	
	var tmpInactive = inactive;
	inactive = active;
	active = tmpInactive;
}

function validate_contact()
{
	// Check the length of the fields
	if ((document.contact_form.name.value == "") ||
		(document.contact_form.email.value == "") ||
		(document.contact_form.comments.value == ""))
	{
		alert("Please complete all fields.");
		return false;
	}
	
 	document.contact_form.submit();
	return true;
}
