// JavaScript Document
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_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_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];}
}

function putAllInfo(vName, vSize, vInfo)
{
	document.formInfo.name.value = vName;
	document.formInfo.size.value = vSize;
	document.formInfo.info.value = vInfo;
}

function cssHorScrolls(val)
{
  document.body.style.overflowX = val
}

function cssIFrameHorScrolls(val, name)
{
  document.name.style.overflowX = val
}


//In The Studio Page Script
function swapInTheStudio (count)
{	
	var pic_array = new Array(
	   "images/in_the_studio_01.jpg",
	   "images/in_the_studio_02.jpg",
	   "images/in_the_studio_03.jpg",
	   "images/in_the_studio_04.jpg",
	   "images/in_the_studio_05.jpg",
	   "images/in_the_studio_06.jpg",
	   "images/in_the_studio_07.jpg",
	   "images/in_the_studio_08.jpg",
	   "images/in_the_studio_09.jpg"
  );
	var info_array = new Array(
		 "Shipment of glass in crate",
		 "Eric cutting glass in loft",
		 "Jillian mosaicing a table top",
		 "Eric detail mosaicing a table top",
		 "Mosaics in the loft studio",
		 "Eric and Jillian next to shipment of glass in crate",
		 "Mosaics in gallery",
		 "Eric unloading glass from crate",
		 "Mosaics in gallery"
	);
	
	MM_swapImage('bigImage','',pic_array[count],1);
	document.formInfo.info.value = info_array[count];
}

var c;
var cFin = 8;
function nextStudio()
{	
	if(!c)
		c = 1;
	else
		c = c+1;
	
	if(c > cFin)
		c = 0;

	//alert("value: "+c);
	swapInTheStudio(c);
}

function prevStudio()
{
	if(!c)
		c = cFin;
	else
		c = c-1;
		
	if(c < 0)
		c = cFin;

	//alert("value: "+c);
	swapInTheStudio(c);	
}


//Work In Prograss Page Script
function swapWorkInProgress (count)
{	
	var pic_array = new Array(
	   "images/work_in_progress_01.jpg",
	   "images/work_in_progress_02.jpg",
	   "images/work_in_progress_03.jpg",
	   "images/work_in_progress_04.jpg"
  );
	
	MM_swapImage('bigImage','',pic_array[count],1);
}

var cwp;
var cwpFin = 3;
function nextWProgress()
{	
	if(!cwp)
		cwp = 1;
	else
		cwp = cwp+1;
	
	if(cwp > cwpFin)
		cwp = 0;

	//alert("value: "+c);
	swapWorkInProgress(cwp);
}

function prevWProgress()
{
	if(!cwp)
		cwp = cwpFin;
	else
		cwp = cwp-1;
		
	if(cwp < 0)
		cwp = cwpFin;

	//alert("value: "+c);
	swapWorkInProgress(cwp);	
}

//Giving Back Page Script
function swapGivingBack(count)
{	
	var pic_array = new Array(
	   "images/giving_back_mercy_01.jpg",
	   "images/giving_back_mercy_02.jpg",
	   "images/giving_back_mercy_03.jpg",
	   "images/giving_back_mercy_04.jpg",
	   "images/giving_back_mercy_05.jpg",
	   "images/giving_back_mercy_06.jpg",
	   "images/giving_back_mercy_07.jpg"
  );
	
	MM_swapImage('bigImage','',pic_array[count],1);
}

var cgbMercy;
var cgbMercyFin = 6;
function nextGBack()
{	
	if(!cgbMercy)
		cgbMercy = 1;
	else
		cgbMercy = cgbMercy+1;
	
	if(cgbMercy > cgbMercyFin)
		cgbMercy = 0;

	swapGivingBack(cgbMercy);
}

function prevGBack()
{
	if(!cgbMercy)
		cgbMercy = cgbMercyFin;
	else
		cgbMercy = cgbMercy-1;
		
	if(cgbMercy < 0)
		cgbMercy = cgbMercyFin;

	swapGivingBack(cgbMercy);	
}


//Giving Back Joilet Page Script
function swapGivingBackJoilet(count)
{	
	var pic_array = new Array(
	   "images/giving_back_joilet_01.jpg",
	   "images/giving_back_joilet_02.jpg",
	   "images/giving_back_joilet_03.jpg",
	   "images/giving_back_joilet_04.jpg"
  );
	
	MM_swapImage('bigImage','',pic_array[count],1);
}

var cgbJoilet;
var cgbJoiletFin = 3;
function nextGBackJoilet()
{	
	if(!cgbJoilet)
		cgbJoilet = 1;
	else
		cgbJoilet = cgbJoilet+1;
	
	if(cgbJoilet > cgbJoiletFin)
		cgbJoilet = 0;

	swapGivingBackJoilet(cgbJoilet);
}

function prevGBackJoilet()
{
	if(!cgbJoilet)
		cgbJoilet = cgbJoiletFin;
	else
		cgbJoilet = cgbJoilet-1;
		
	if(cgbJoilet < 0)
		cgbJoilet = cgbJoiletFin;

	swapGivingBackJoilet(cgbJoilet);	
}

//Events Nine Restaurant In Chicago Page Script
function swapEventsNine(count)
{	
	var pic_array = new Array(
	   "images/events_nine_01.jpg",
	   "images/events_nine_02.jpg",
	   "images/events_nine_03.jpg",
	   "images/events_nine_04.jpg",
	   "images/events_nine_05.jpg",
	   "images/events_nine_06.jpg",
	   "images/events_nine_07.jpg",
	   "images/events_nine_08.jpg",
	   "images/events_nine_09.jpg",
	   "images/events_nine_010.jpg",
	   "images/events_nine_011.jpg",
	   "images/events_nine_012.jpg",
	   "images/events_nine_013.jpg",
	   "images/events_nine_014.jpg",
	   "images/events_nine_015.jpg",
	   "images/events_nine_016.jpg",
	   "images/events_nine_017.jpg"
  );
	var info_array = new Array(
		 "Art/Jazz Night invitation - Front",
		 "Art/Jazz Night invitation - Back",
		 "",
		 "Jillian Riley and Eric Periu",
		 "",
		 "",
		 "",
		 "Donna Melnuk and Peggy Periu (the moms)",
		 "Rachel Stockhausen, Emily Morse, Jillian Riley and Jen Mauch",
		 "Peggy Periu and Pete & Julie McMahon",
		 "Ed Periu and Paul Melnuk (the dads)",
		 "",
		 "Kami McLochlin, Jillian Riley, Jayme Buda",
		 "Jillian Riley, Tara Turney, Melanie Metzger",
		 "DJ Hendrick",
		 "",
		 "Matt Price, and Alex Kolokythas"		 
	);
	//16 - "Matt Cushing and friend, Mark Day, Matt and Ava Allen",
	MM_swapImage('bigImage','',pic_array[count],1);
	document.formInfo.info.value = info_array[count];
}

var ceNine;
var ceNineFin = 16;
function nextEventsNine()
{	
	if(!ceNine)
		ceNine = 1;
	else
		ceNine = ceNine+1;
	
	if(ceNine > ceNineFin)
		ceNine = 0;

	swapEventsNine(ceNine);
}

function prevEventsNine()
{
	if(!ceNine)
		ceNine = ceNineFin;
	else
		ceNine = ceNine-1;
		
	if(ceNine < 0)
		ceNine = ceNineFin;

	swapEventsNine(ceNine);	
}


//Events Wynwood Page Script
function swapEventsWynwood(count)
{	
	var pic_array = new Array(
	   "images/events_wynwood_01.jpg",
	   "images/events_wynwood_02.jpg",
	   "images/events_wynwood_03.jpg"
  );
	var info_array = new Array(
		 "Mosaics in the making invitation - Front",
		 "Mosaics in the making invitation - Back",
		 "Socialite Magazine Article"
	);
	
	MM_swapImage('bigImage','',pic_array[count],1);
	document.formInfo.info.value = info_array[count];
}

var ceWynwood;
var ceWynwoodFin = 2;
function nextEventsWynwood()
{	
	if(!ceWynwood)
		ceWynwood = 1;
	else
		ceWynwood = ceWynwood+1;
	
	if(ceWynwood > ceWynwoodFin)
		ceWynwood = 0;

	//Show Hide Link layer
	if(ceWynwood == 2)
		showLayer("lnkLayer");
	else
		hideLayer("lnkLayer");
	
	swapEventsWynwood(ceWynwood);
}

function prevEventsWynwood()
{
	if(!ceWynwood)
		ceWynwood = ceWynwoodFin;
	else
		ceWynwood = ceWynwood-1;
		
	if(ceWynwood < 0)
		ceWynwood = ceWynwoodFin;

	//Show Hide Link layer
	if(ceWynwood == 2)
		showLayer("lnkLayer");
	else
		hideLayer("lnkLayer");
		
	swapEventsWynwood(ceWynwood);	
}


// Show Hide Layers
var origWidth, origHeight;
if (document.layers) {
	origWidth = window.innerWidth; origHeight = window.innerHeight;
	window.onresize = function() { if (window.innerWidth != origWidth || window.innerHeight != origHeight) history.go(0); }
}

var cur_lyr;	// holds id of currently visible layer
function swapLayers(id) {
  if (cur_lyr) hideLayer(cur_lyr);
  showLayer(id);
  cur_lyr = id;
}

function showLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) 
  {
	lyr.css.visibility = "visible";
	lyr.css.position = "static";
  }
}

function hideLayer(id) {
  var lyr = getElemRefs(id);
  if (lyr && lyr.css) 
  {
	lyr.css.visibility = "hidden";
	lyr.css.position = "absolute";
  }
}

function getElemRefs(id) {
	var el = (document.getElementById)? document.getElementById(id): (document.all)? document.all[id]: (document.layers)? document.layers[id]: null;
	if (el) el.css = (el.style)? el.style: el;
	return el;
}
