// JavaScript Document

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Standard Scripts -->

var request = {};
function getUrlVars()
//*Used in slide show to get pic to load if needed. Read a page's GET URL variables and return them as an "associative array." Calling the function while at example.html?foo=asdf&bar=jkls sets request['foo']='asdf' and request['bar']='jkls'.  Returns True if no value
{
	var parts = window.location.search.replace(/[?&]+([^=&]+)(=[^&]*)?/gi, function(m,key,value) {
		request[key] = (value === undefined) ? true : value.substring(1); 
	});
	return request;
}

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Breadcrumb Script -->
function brdMouseOver(imgId)
{
	document.getElementById(imgId).src = document.getElementById(imgId).src.replace(".png","2.png");
}
function brdMouseOut(imgId)
{
	document.getElementById(imgId).src = document.getElementById(imgId).src.replace("2.png",".png");
}
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Breadcrumb Script End-->

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Menu Script -->
var menGrowWaitTimer /*Set to wait for menGrow, menGrow1 functions*/
/*
Set height of div's to grow or shrink to shrinked size via inline style of element
	2-line images = 30px hight / 1-line images = 14px height
menArrGrow = menus to grow after page load
menArrShrink = menus to shrink on mouse out (i.e.; don't shrink the menu we want expanded


Functions:
fixOnMouseOut		Stop mouse out event when mousing over nexted dividers in Menu Divider
is_child_of		Used in fixOnMouseOut

getDivTop			Returns top of element in relation to parent element using div tops
getDivLeft		Returns left of element in relation to parent element using div lefts

menSlideDiv		Adjusts height of divider from current height to given height over given amount of time
menSlideDivStep	Used in menSlideDiv

menMouseOver		Adds flower pedal and grows if necessary via menGrow
menMouseOut		removes flower pedal

menGrow			Grow div to height of nexted div's and remove height attribute to allow growing/shrinking with other menGrows
menShrink			Loop through array of menus to shrink and shrink them to height of 1st image element
*/
function fixOnMouseOut(element, event, JavaScript_code) 
/* 
Usage for fixOnMouseOut to stop mouse out event on inner div's
<div onMouseOut="fixOnMouseOut(this, event, 'JavaScript Code');"> 
	So many childs 
</div>
*/
{
	var current_mouse_target = null;
	if( event.toElement ) {				
		current_mouse_target 			 = event.toElement;
	} else if( event.relatedTarget ) {				
		current_mouse_target 			 = event.relatedTarget;
	}
	if( !is_child_of(element, current_mouse_target) && element != current_mouse_target ) {
		eval(JavaScript_code);
	}
}
function is_child_of(parent, child)
{
	if( child != null ) {			
		while( child.parentNode ) {
			if( (child = child.parentNode) == parent ) {
				return true;
			}
		}
	}
	return false;
}

function getDivTop(elemIdParent, elemId)
//Returns the top of element within the parent by adding top position of all parent DIV's
{
	var elemTop = 0;
	while (document.getElementById(elemId).parentNode)
		{
			//alert(elemId + " " + document.getElementById(elemId).parentNode.id);
			if (elemId == elemIdParent)
			{
				return elemTop;
			}
		if (document.getElementById(elemId).tagName == "DIV")
		{
			elemTop = elemTop + document.getElementById(elemId).offsetTop;
		}
		elemId = document.getElementById(elemId).parentNode.id;
		}
}

function getDivLeft(elemIdParent, elemId)
//Returns the left of element within the parent by adding top position of all parent DIV's
{
	var elemLeft = 0;
	while (document.getElementById(elemId).parentNode)
		{
			//alert(elemId + " " + document.getElementById(elemId).parentNode.id);
			if (elemId == elemIdParent)
			{
				return elemLeft;
			}
		if (document.getElementById(elemId).tagName == "DIV")
		{
			elemLeft = elemLeft + document.getElementById(elemId).offsetLeft;
		}
		elemId = document.getElementById(elemId).parentNode.id;
		}
}

function menSlideDiv(elemId, newHeight, time, fps, remHeightWhenDone)
//Slide menu divider up or down to resize (on mouse over) - remHeightWhenDone = 0 or -1 to remove the height of div after sliding
{
	var steps = Math.ceil(fps * (time / 1000));
	var fromHeight = document.getElementById(elemId).offsetHeight;
	var deltaHeight = (newHeight - fromHeight) / steps;
	menSlideDivStep(elemId, 0, steps, fromHeight, deltaHeight, (time / steps), remHeightWhenDone);
}

function menSlideDivStep(elemId, stepNum, steps, fromHeight, deltaHeight, timePerStep, remHeightWhenDone)
{
	var setHeight = Math.round(parseInt(fromHeight) + (deltaHeight * stepNum));
	document.getElementById(elemId).style.height = setHeight + "px";
	if (stepNum < steps)
	{
		setTimeout("menSlideDivStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromHeight + ", " + deltaHeight + ", " + timePerStep + ", " + remHeightWhenDone + ");", timePerStep);
	}
	else
	{
		if (remHeightWhenDone == -1)
		{
			document.getElementById(elemId).style.height = "";
		}
	}
}

function menMouseOver(imgId, divId)
{
	menGrowTimeStop()
	//Replace image picture source with 2 at end
	document.getElementById(imgId).src = document.getElementById(imgId).src.replace(".png","2.png")
	//If divID sent, display MenuOver
	if (divId != null)
	{
		document.getElementById("MenuOver").style.top = (document.getElementById(imgId).offsetHeight + getDivTop("Menu",divId) - 29) + "px";
		document.getElementById("MenuOver").style.left = (getDivLeft("Menu",divId) - 2) + "px";
		document.getElementById("MenuOver").style.visibility = "visible"
	}
	//Grow Menu if needed
	menGrow(divId,750);
}

function menMouseOut(imgId)
{
	menGrowTimeStop()
	document.getElementById('MenuOver').style.visibility='hidden';
	//Replace picture (img ID should be same as element with pic at end) source with 2 at end
	document.getElementById(imgId).src = document.getElementById(imgId).src.replace("2.png",".png")
}

function menShrink()
{
	//Loop through menArrShrink and for each item:
	//Shrink to height of 1st image (inside <a href <img
	//if divider not equal to 1st element height, shrink it
	
	var newHeight
	//If first element of menArrShrink = "", don't do anything
	
	if (menArrShrink[0] == "") {return}
	//Get menu items to shrink from array and loop
	for (i = 0; i < menArrShrink.length; ++ i)
	{
		newHeight = document.getElementById(menArrShrink[i]).childNodes[0].childNodes[0].offsetHeight;
		if (newHeight < document.getElementById(menArrShrink[i]).offsetHeight)
		{
			menSlideDiv(menArrShrink[i],newHeight,250,16,0);
		}
	}
}

function menGrow(elemId, menWait)
{
	//Set menWait to miliseconds to wait before grow (will check if mouse still over element via var menCurElem
	//Set menWait to 0 to open right away (ie; when page loads

	//Get height of all the children div's for this div (elemId)
	var newHeight = document.getElementById(elemId).childNodes[0].childNodes[0].offsetHeight;
	var children = document.getElementById(elemId).childNodes;
	for (var i = 0; i < children.length; i++) 
	{
		//If child is divider, add height to new height
		if (children[i].tagName == "DIV")
		{
			newHeight = newHeight + children[i].offsetHeight;
		}
	}
	
	if (newHeight <= document.getElementById(elemId).offsetHeight)
	{
		return;
	}
	
	menGrowTimeStart(menWait,elemId,newHeight);
}

function menGrowTimeStart(menWait,elemId,newHeight)
{
	if (menWait > 0)
	{
		document.getElementById("MenuWaiting").style.top = (getDivTop("Menu",elemId)-2) + "px";
		document.getElementById("MenuWaiting").style.left = (document.getElementById(elemId).offsetWidth + getDivLeft("Menu",elemId) - 16) + "px";
		document.getElementById("MenuWaiting").style.visibility = "visible"
		menGrowWaitTimer = setTimeout("menGrow1('" + elemId + "', " + newHeight + ")",menWait);
	}
	else
	{
		menGrow1(elemId,newHeight);
	}
}

function menGrowTimeStop()
{
	clearTimeout(menGrowWaitTimer);
	document.getElementById("MenuWaiting").style.visibility = "hidden";
}

function menGrow1(elemId,newHeight)
{
	document.getElementById("MenuWaiting").style.visibility = "hidden"
	//if(menCurElem == elemId)
	//{
		menSlideDiv(elemId,newHeight,250,16,-1);
	//}
}

function menGrowOnLoad()
{
	if (menArrGrow[0] == "") {return}
	//Get menu items to shrink from array and loop
	for (i = 0; i < menArrGrow.length; ++ i)
	{
		menGrow(menArrGrow[i],0);
	}
}
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Menu Script End-->

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++SlideShow Script-->
var showCurSlide = 0
var showTimeTrans = 1500 //fade in / fade out time
var showTimeWait = 7000 // time to hold between fade in/fade out
var showFPS = 29

var showTop1 = "Slide1a"
var showBot1 = "Slide1b"
var showTop2 = "Slide2a"
var showBot2 = "Slide2b"
var showTop3 = "Slide3a"
var showBot3 = "Slide3b"
var showTop4 = "Slide4a"
var showBot4 = "Slide4b"

function RunShow() {
    SetOpacity(document.getElementById(showTop1), 0);
    SetOpacity(document.getElementById(showTop2), 0);
    SetOpacity(document.getElementById(showTop3), 0);
    SetOpacity(document.getElementById(showTop4), 0);
    document.getElementById(showTop1).style.backgroundImage = "url(" + imgArr1[showCurSlide] + ")";
    document.getElementById(showTop2).style.backgroundImage = "url(" + imgArr2[showCurSlide] + ")";
    document.getElementById(showTop3).style.backgroundImage = "url(" + imgArr3[showCurSlide] + ")";
    document.getElementById(showTop4).style.backgroundImage = "url(" + imgArr4[showCurSlide] + ")";
    RunShowTrans1();   
}
function RunShowTrans1() {
    //start slide top, fade in top, load bottom
    SlideDiv(showTop1,0,-100,0,0,(showTimeTrans * 2) + showTimeWait + 250,showFPS); //add 250ms just in case
    FadeOpacity(showTop1,0,100,showTimeTrans,showFPS)
    setTimeout("FadeOpacity(showTop2,0,100,showTimeTrans,showFPS)",showTimeTrans);
	setTimeout("FadeOpacity(showTop3,0,100,showTimeTrans,showFPS)",showTimeTrans * 2);
	setTimeout("FadeOpacity(showTop4,0,100,showTimeTrans,showFPS)",showTimeTrans * 3);

    showCurSlide = (showCurSlide >= (imgArr1.length - 1)) ? 0 : showCurSlide + 1;
    setTimeout("RunShowLoadImage(showBot1,'" + imgArr1[showCurSlide] + "')", showTimeTrans + 250)
    setTimeout("RunShowLoadImage(showBot2,'" + imgArr2[showCurSlide] + "')", (showTimeTrans*2) + 250)
    setTimeout("RunShowLoadImage(showBot3,'" + imgArr3[showCurSlide] + "')", (showTimeTrans*3) + 250)
    setTimeout("RunShowLoadImage(showBot4,'" + imgArr4[showCurSlide] + "')", (showTimeTrans*4) + 250)

    setTimeout("RunShowTrans2()", showTimeWait + showTimeTrans)
}
function RunShowTrans2() {
    SlideDiv(showBot1,0,-100,0,0,(showTimeTrans * 2) + showTimeWait + 250,showFPS); //add 250ms just in case
    FadeOpacity(showTop1,100,0,showTimeTrans,showFPS)
    setTimeout("FadeOpacity(showTop2,100,0,showTimeTrans,showFPS)",showTimeTrans);
	setTimeout("FadeOpacity(showTop3,100,0,showTimeTrans,showFPS)",showTimeTrans * 2);
	setTimeout("FadeOpacity(showTop4,100,0,showTimeTrans,showFPS)",showTimeTrans * 3);

    showCurSlide = (showCurSlide >= (imgArr1.length - 1)) ? 0 : showCurSlide + 1;
    setTimeout("RunShowLoadImage(showTop1,'" + imgArr1[showCurSlide] + "')", showTimeTrans + 250)
    setTimeout("RunShowLoadImage(showTop2,'" + imgArr2[showCurSlide] + "')", (showTimeTrans*2) + 250)
    setTimeout("RunShowLoadImage(showTop3,'" + imgArr3[showCurSlide] + "')", (showTimeTrans*3) + 250)
    setTimeout("RunShowLoadImage(showTop4,'" + imgArr4[showCurSlide] + "')", (showTimeTrans*4) + 250)

    setTimeout("RunShowTrans1()", showTimeWait + showTimeTrans)
}
function RunShowTrans2Step(stepNum, steps, delta, timePerStep) {
    //fade out top then load next pic into top - wait and go to RunShowTrans1
    SetOpacity(document.getElementById(showTop1), 100 - Math.round(delta * stepNum));
    if (stepNum < steps) {
        setTimeout("RunShowTrans2Step(" + (stepNum + 1) + ", " + steps + ", " + delta + ", " + timePerStep + ");", timePerStep);
    }
    else {
        showCurSlide = (showCurSlide >= (imgArr1.length - 1)) ? 0 : showCurSlide + 1;
        document.getElementById(showTop1).style.backgroundImage = "url(" + imgArr1[showCurSlide] + ")";
        setTimeout("RunShowLoadImage234Top(" + showCurSlide + ")", showTimeTrans * 3)
        setTimeout("RunShowTrans1()", showTimeWait)
    }
}
function RunShowLoadImage(imgdiv, imgurl) {
    document.getElementById(imgdiv).style.backgroundImage = "url(" + imgurl + ")";
}


function FadeOpacity(elemId, fromOpacity, toOpacity, time, fps)
{
	var steps = Math.ceil(fps * (time / 1000));
	var delta = (toOpacity - fromOpacity) / steps;
    
	FadeOpacityStep(elemId, 0, steps, fromOpacity, delta, (time / steps));
}

function FadeOpacityStep(elemId, stepNum, steps, fromOpacity, delta, timePerStep)
{
	SetOpacity(document.getElementById(elemId), Math.round(parseInt(fromOpacity) + (delta * stepNum)));

	if (stepNum < steps)
		setTimeout("FadeOpacityStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromOpacity + ", "+ delta + ", " + timePerStep + ");", timePerStep);
}

function SetOpacity(elem, opacityAsInt)
{
	var opacityAsDecimal = opacityAsInt;
 
	if (opacityAsInt > 100)
		opacityAsInt = opacityAsDecimal = 100; 
	else if (opacityAsInt < 0)
		opacityAsInt = opacityAsDecimal = 0;
 
	opacityAsDecimal /= 100;
	//if (opacityAsInt < 1)
	//	opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0

	if (navigator.appName == 'Microsoft Internet Explorer')
	{
		elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
	}
	else
	{
		elem.style.opacity = (opacityAsDecimal);
	}
}

function SlideDiv(elemId, fromLeftPos, toLeftPos, fromTopPos, toTopPos, time, fps)
{
	var steps = Math.ceil(fps * (time / 1000));
	var deltaLeft = (toLeftPos - fromLeftPos) / steps;
	var deltaTop = (toTopPos - fromTopPos) / steps;

	SlideDivStep(elemId, 0, steps, fromLeftPos, deltaLeft, fromTopPos, deltaTop, (time / steps));
}

function SlideDivStep(elemId, stepNum, steps, fromLeftPos, deltaLeft, fromTopPos, deltaTop, timePerStep)
{
	var setLeft = Math.round(parseInt(fromLeftPos) + (deltaLeft * stepNum));
	var setTop = Math.round(parseInt(fromTopPos) + (deltaTop * stepNum));
	document.getElementById(elemId).style.backgroundPosition = setLeft + "px " + setTop + "px";
	if (stepNum < steps)
		setTimeout("SlideDivStep('" + elemId + "', " + (stepNum+1) + ", " + steps + ", " + fromLeftPos + ", " + deltaLeft + ", " + fromTopPos + ", " + deltaTop + ", " + timePerStep + ");", timePerStep);
}




<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++SlideShow Script End-->

<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Gallery Script Start-->
//==================================================================================================Gallery Script
//Text file contains 5 lines each item: small file location, large file location, title, description, price
//Leave 0 for blank item
//ie; var galTextFileLocation = window.location.protocol + "//" + window.location.host + "/images/floralarrangements_gal/gal.txt" - load in document

var galTextFileLocation
var galArr = new Array();
function galReadTextFile()
{
	var galTextFile = new XMLHttpRequest();
	galTextFile.open("GET", galTextFileLocation, true);
	galTextFile.onreadystatechange = function(){
		if (galTextFile.readyState === 4) // Makes sure the document is ready to parse.
		{
			if (galTextFile.status === 200) // Makes sure it's found the file.
			{
				galArr = galTextFile.responseText.split("\n"); // Will separate each line into an array
				//Write to div galLeft
				var linWrite = "";
				for (i = 0; i < galArr.length; i=i+5)
				{
					linWrite = linWrite + "<a href=\"javascript:galLoadImg(" + i + ")\" class=\"galLinkThumb\"><img src=\"" + galArr[i] + "\" class=\"galImgThumb\" alt = \"" + galArr[i+2] + "\"/></a>";
				}
				document.getElementById("galLeft").innerHTML=linWrite;
				getUrlVars();
				if (request['pic'])
				{
					galLoadImg(request['pic'] * 1) //load image from URL value of pic
				}
				else
				{
					galLoadImg(0) //load 1st image
				}
			}
		}
	}
	galTextFile.send(null);
}

function galLoadImg(galI)
{
	var galTitle = galArr[galI + 2];
	var galTitleWrite = "<a href=\"" + window.location.protocol + "//" + window.location.host + window.location.pathname + "?pic=" + galI + "\">" + galArr[galI + 2] + "</a>"
	var galDescription = galArr[galI + 3];
	var galPrice = galArr[galI + 4];
	var galImg = galArr[galI + 1];
	
	var linWrite = "<img src=\"" + galImg + "\"/>"
	if (galTitle != 0)
	{
		linWrite = linWrite + "<p>" + galTitleWrite + "</p>";
	}
	if (galDescription != 0)
	{
	linWrite = linWrite + "<p>" + galDescription + "</p>"
	}
	if (galPrice != 0)
	{
		linWrite = linWrite + "<p>" + galPrice + "</p>";
	}
	document.getElementById("galRight").innerHTML=linWrite;
}
<!--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Gallery Script End-->
