var imgList = new Array();
var eventName = '';
var categories = '';
var currentCat = '';
var currentImg = '';
var delay = 60000;
var bannerIndex = 0;

var sizeSelect = '';
var sheetSizeSelect = '';
var finishingSelect = '';
var effectsSelect = '';
var mountingSelect = '';
var frameingSelect = '';
var orderForm = '';
var orderFormVisible = false;

var scrnWidth;
var scrnHeight;

var gObj;
var owObj;
var sObj;
var coverObj;
var covered = false;
var abObj;
var imageBorder = true;

var topY = 0;
var topX = 0;

var photoPrice = 0;
var photoName = '';
var photoSKU = '';
var photoQty = 0;

function loaded() {
	currentCat = categories[0];

	owObj = document.getElementById('orderWindow');
	sObj = document.getElementById('shadow');
	gObj = document.getElementById('gallery');
	coverObj = document.getElementById('noClick');

	document.title = 'Christopher Bross Photography - ' + eventName;

	if (bannerDelay) { delay = parseInt(60000 * bannerDelay); }

	evalStrings();

	buildBanner();
	loadGallery();
	positionElements();

	displayWelcome();

	buildSelects();

}

function buildBanner() {
	obj = document.getElementById('eventHolder');
	if (obj) {
		tmp = '';
		bObj = document.getElementById('banner');
		if (bObj) {
			bImg = '../support/grey-fade.jpg';
			if (bannerImg) {
				if (bannerImg.length == 1 || !bannerStyle) { 
					bImg = 'images/' + bannerImg[0]; 
				} else {
					if (bannerStyle == 1) {
						r = parseInt(Math.random(1) * bannerImg.length);
						bImg = 'images/' + bannerImg[r];
					} else {
						bImg = 'images/' + bannerImg[0];
						setTimeout('swapBannerImage()',delay);
					}
				}
			}
			bObj.style.backgroundImage = 'url(' + bImg + ')';
		}
		tmp2 = '<div class=eventContOver>' + eventName;
		if (categories.length > 1) {
			tmp2 += '<br><dd><span class=eventSubOver>' + currentCat + '</span></div>';
		} else { tmp2 += '</div>'; }

		tmp += '<div class=eventCont>' + eventName;
		if (categories.length > 1) {
			tmp += '<br><dd><span class=eventSub>' + currentCat + '</span></div>' + tmp2;
			for (var i = 0 ; i < categories.length; i++) {
				if (currentCat == categories[i]) {
					tmp += '<span class=catBtnSel>&nbsp;' + categories[i] + '&nbsp;</span>&nbsp;';
				} else {
					tmp += '<span onClick="clickCat(\''+categories[i]+'\')" onMouseOver="if (!orderFormVisible) {this.className=\'catBtnOver\';}" onMouseOut="this.className=\'catBtn\'" class=catBtn>&nbsp;' + categories[i] + '&nbsp;</span>&nbsp;';
				}
			}
		} else { tmp += '</div>' + tmp2; }

		obj.innerHTML = tmp;
	}
}

function swapBannerImage() {
	bObj = document.getElementById('banner');
	if (bObj) {
		bannerIndex++;
		if (bannerIndex >= bannerImg.length) { bannerIndex = 0; }
		bObj.style.backgroundImage = 'url(images/' + bannerImg[bannerIndex] + ')';
		setTimeout('swapBannerImage()',delay);
	}
}

function loadGallery() {
	if (gObj) {
		tmp = '<table cellpadding=4 cellspacing=0 border=0 width=680><tr><td class=inst>' + instructions + '</td><td align=right class=viewCart>';
		tmp += '<span class=btn onMouseOver="if (!orderFormVisible) { btnOver(this); }" onMouseOut="if (!orderFormVisible) { btnOut(this); }" onClick="viewCart()" id=viewBtn> view cart </span></td></tr></table>';
		tmp += '<div id=thumbnails><table cellpadding=0 cellspacing=0 border=0>';
		h = 0;
		for (var i = 0; i < imgList[currentCat].length; i++) {
			tmp2 = imgList[currentCat][i];
			tmp2 = tmp2.split('.');
			tmp2 = tmp2[0];
			tmpImg = imgList[currentCat][i].toLowerCase();
			if (tmpImg.indexOf('.jpg') == -1) { tmpImg += '.jpg'; }
			if (h == 0) { tmp+= '<tr>'; }
			tmp += '<td  onClick="clickThumb(\'' + tmpImg + '\')" onMouseOver="if (!orderFormVisible) {this.className=\'thumbOver\';}" onMouseOut="this.className=\'thumb\'" class=thumb style="';
			if (i > 4) { tmp += 'border-top:1px solid #afafaf;'; }
			if (h != 0) { tmp += 'border-left:1px solid #afafaf;'; }
			tmp += '"><img src="thumbnails/' + tmpImg + '" border=1 alt="' + eventName + ' - ' +currentCat + '(' + tmpImg + ')"><div class=photoNum>' + tmp2 + '</div><div class=photoNumOver>' + tmp2 + '</div></td>';
			h++;
			if (h == 5) { tmp += '</tr>'; h = 0; }
		}
		if (h != 0) { 
			for (var i = 0; i < 5 - h; i++) {
				tmp += '<td style="border-left:1px solid #afafaf;';
				if (imgList[currentCat].length > 5) { tmp += 'border-top:1px solid #afafaf;'; }
				tmp += '"><br></td>';
			}
			tmp += '</tr>'; 
		}
		tmp += '</table></div>';
		gObj.innerHTML = tmp;
		positionElements();
	}

}

function coverUp() {

	obj = document.getElementById('picHolder');
	if (obj && coverObj) {
		tmpX = findPosX(obj);
		tmpY = findPosY(obj);
		coverObj.style.top = tmpY;
		coverObj.style.left = tmpX;
		coverObj.style.width = obj.offsetWidth + 2;
		coverObj.style.height = obj.offsetHeight + 2;
		coverObj.style.display = 'inline';
	}

}

function positionElements() {
	getScreenSize();
	
	if (gObj) {

		var topY = findPosY(gObj);
		var topX = findPosX(gObj) + 1;

		gObj.style.height = scrnHeight - topY - 10;
		if (owObj && sObj) { 

			tmpY = parseInt(scrnHeight / 2) - parseInt(495 /2);
			tmpX = parseInt(scrnWidth / 2) - parseInt(610 /2);
			owObj.style.top = tmpY; 
			owObj.style.left = tmpX; 

			sObj.style.top = tmpY + 8;
			sObj.style.left = tmpX + 8;
		}
		tObj = document.getElementById('thumbnails');
		if (tObj) {
			tmpX = findPosX(tObj);
			tmpY = findPosY(tObj);
			tmpHeight = gObj.offsetHeight - (tmpY-topY);
			tObj.style.height = tmpHeight;
		}
	}
}

function clickCat(which) {
	if (which != '' && orderFormVisible == false) {
		amberObj = document.getElementById('amber');
		if (amberObj) { amberObj.style.display = 'none'; }
		desatObj = document.getElementById('desaturated');
		if (desatObj) { desatObj.style.display = 'none'; }

		currentCat = which;
		buildBanner();
		loadGallery();
		//displayWelcome();
	}
}

function clickThumb(which) {
	if (which != '' && orderFormVisible == false) {
		currentImg = which;
		ndx= -1;
		for (var i = 0; imgList[currentCat].length; i++) {
			if (imgList[currentCat][i] == which) {
				ndx = i;
				break;
			}
		}
		if (ndx > -1) {
			hideEffects();
			// build form
			tmp2 = imgList[currentCat][ndx];
			tmp2 = tmp2.split('.');
			tmp2 = tmp2[0];
			photoName = tmp2;
			specialPicture = false;
			specialType = eventType;
			if (tmp2.indexOf('-') > -1) {
				specialNdx = tmp2.split('-');
				specialPicture = true;
			}
			orderForm = '<div style="width:95%;"onClick="toggleOrder(this)" id=order class=orderNotes onMouseOver="this.className=\'orderNotesOver\'" onMouseOut="this.className=\'orderNotes\'" title="Click here to view the notes about photos.">View Photo Notes</div>';
			if (eventType) {
				if (eventType == 1) {
					orderForm += '<input type=hidden name="IorS" value="I" checked>';
				} else if (eventType == 2) {
					orderForm += '<input type=hidden name="IorS" value="S" checked>';
				} else {
					orderForm += '<input type=radio name="IorS" value="I" checked onClick="hideOrShow()">&nbsp;Individual <input type=radio name="IorS" value="S" onClick="hideOrShow()">&nbsp;Sheet<br>';
				}
			} else {
				eventType = 3;
				orderForm += '<input type=radio name="IorS" value="I" checked onClick="hideOrShow()">&nbsp;Individual <input type=radio name="IorS" value="S" onClick="hideOrShow()">&nbsp;Sheet<br>';
			}
			//orderForm += 'Photo Number: ' + tmp2 + '<input type=hidden value="' + tmp2 + '"><br>';
			orderForm += '<input type=hidden value="' + tmp2 + '">';
			orderForm += 'Qty:&nbsp;<input name=qty size=3 maxlength=3 value=1 onBlur="checkQty(this)"><br>';
			orderForm += '<span class=small>Size:</span><br>'
			if (eventType == 1) {
				orderForm += '<span id=iSize>' + sizeSelect + '</span>';
			} else if (eventType == 2) {
				orderForm += '<span id=sSize>' + sheetSizeSelect + '</span>';
			} else {
				orderForm += '<span id=iSize>' + sizeSelect + '</span>';
				orderForm += '<span id=sSize style="display:none;">' + sheetSizeSelect + '</span>';
			}
			orderForm += '<br>';
			orderForm += '<span class=small>Finish:</span><br>' + finishingSelect + '<br>';
			orderForm += '<span class=small>Effects:</span><br>' + effectsSelect + '<br>';
			if (eventType != 2) {
				orderForm += '<div id=iOnly><span id=mount style="display:none;"><span class=small>Mounting:</span><br>' + mountingSelect + '</span>';
				orderForm += '<br>';
				// no frames just yet
				//orderForm += '<span class=small>Frame:</span><br>' + frameingSelect
				orderForm += '</div>';
			}

			tmp = '<table width=100% cellpadding=2 cellspacing=0 border=0><tr><td class=orderLeft>Photo Number: ' + tmp2 + '</td><td class=orderRight><div class=closeBtn onMouseOver="this.className=\'closeBtnOver\'" onMouseOut="this.className=\'closeBtn\'" onClick="closeOrderForm()">X</div></td></tr></table>';
			tmp += '<div class=orderArea>';
			tmp += '<table width=100% cellpadding=2 cellspacing=0 border=0><tr>';
			tmp += '<td width=50%><div style="width:424px;height:424px;" align=center valign=middle id=picHolder><img src="images/' + imgList[currentCat][ndx] + '" border=2 id=photo><div class=bigPhotoNum>' + tmp2 + '</div><div class=bigPhotoNumOver>' + tmp2 + '</div></div><div id=disclaimer></div></td>';
			//tmp += '<td><i><li>Cropping is done at no additional cost.<br><br><li>Touchups done at an additional cost.<BR><br><li>*Square crops may not be possible on some images.<br><br><li>Images shown are optimized for web display and do not reflect the true quality of the image.<br><br><li>Final images are professionally cropped and color balanced.<br></i></td>';
			tmp += '<td valign=top width=50%><div>';
			tmp += orderForm;
			tmp += '<br><br><br><br><span class=small>*,** Additional cost</span><br><div class=bottomLine><table border=0 cellspacing=1 width=95%><tr><td>Price:</td><td align=right id=priceBox>$0.00</td><td>&nbsp;</td><td nowrap align=right><span class=btn onMouseOver="btnOver(this)" onMouseOut="btnOut(this)" onClick="addToCart()" id=addBtn> add to cart </span></td></tr></table>';
			tmp += '<br><table border=0 width=95% style="border:none;"><tr><td width=50%>';
			if (ndx == 0) {
				tmp += '<span class=navBtnDisabled>&lt;&lt; previous</span>';
			} else {
				tmp += '<span class=navBtn onClick="moveToImage(ndx - 1)" onMouseOver="this.className=\'navBtnOver\'" onMouseOut="this.className=\'navBtn\'">&lt;&lt; previous</span>';
			}
			tmp += '</td><td width=50% align=right>';
			if (ndx == imgList[currentCat].length - 1) {
				tmp += '<span class=navBtnDisabled>next &gt;&gt;</span>';
			} else {
				tmp += '<span class=navBtn onClick="moveToImage(ndx + 1)" onMouseOver="this.className=\'navBtnOver\'" onMouseOut="this.className=\'navBtn\'">next &gt;&gt;</span>';
			}
			tmp += '</td></tr></table>';
			//tmp += '<br><input type=button value="Close Window" onClick="closeOrderForm()"></div></td></tr></table>';
			tmp += '<br><span> </span><span class=navBtn onClick="closeOrderForm()" onMouseOver="this.className=\'navBtnOver\'" onMouseOut="this.className=\'navBtn\'">Close</span></div></td></tr></table>';
			tmp += '</div></div>';

			desatObj = document.getElementById('desaturated');
			if (desatObj) { desatObj.src = 'images/' + imgList[currentCat][ndx]; }
		
			if (owObj && sObj) { 
				owObj.innerHTML =  tmp;
				sObj.style.display = 'inline';
				owObj.style.display = 'inline';
				orderFormVisible = true;
			}	

			if (!covered) {
				coverUp();
				covered = true;
			}
		}
	}
}

function getScreenSize() {
	obj = document.body;
	if (document.all) {
		scrnHeight = obj.clientHeight;
		scrnWidth = obj.clientWidth;	
	} else {
		scrnHeight = window.innerHeight;
		scrnWidth = window.innerWidth;
	}
}

function findPosX(obj) {
	var curleft = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	else if (obj.x) { curleft += obj.x; }
	return curleft;
}

function findPosY(obj) {
	var curtop = 0;
	if (obj.offsetParent) {
		while (obj.offsetParent) {
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	else if (obj.y) { curtop += obj.y; }
	return curtop;
}

function buildSelects() {
	sizeSelect = buildSingleSelect(sizeList,'size',-1);
	sheetSizeSelect = buildSingleSelect(sheetSizeList,'sheetSize',-1);
	finishingSelect = buildSingleSelect(finishingList,'finishing',0);
	effectsSelect = buildSingleSelect(effectsList,'effects',0);
	mountingSelect = buildSingleSelect(mountingList,'mounting',0);
	frameingSelect = buildSingleSelect(frameingList,'frameing',0);
}

function buildSingleSelect(whichList,whichName,whichSelected) {
	whichSelect = '';
	if (whichList) {
		if (whichList.length > 0) {
			whichSelect = '<select name=' + whichName;
			if (whichName == 'sheetSize') { whichSelect += ' style="width:145px;"'; }
			whichSelect += ' onChange="changedSel(this);';
			if (whichName == 'effects') { whichSelect += ' applyEffect(this)'; }
			whichSelect += '">';
			if (whichSelected == -1) { whichSelect += '<option value="-">- select one -'; }
			for (var i = 0; i < whichList.length; i++) {
				if (whichList[i].indexOf('~') == -1) { whichList[i] = whichList[i] + '~' + whichList[i]; }
				work = whichList[i].split('~');
				whichSelect += '<option value="' + work[0] + '"'
				if (whichSelected == i) { whichSelect += ' selected'; }
				whichSelect += '>' + work[1];
				if (whichName == 'sheetSize') {
					if (sheetPricing[work[0]]) {
						tmp = sheetPricing[work[0]][0];
						whichSelect += '$' + formatNum(tmp);
					}
				} else if (whichName == 'size') {
					if (indPricing[work[0]]) {
						tmp = indPricing[work[0]][0];
						whichSelect += '$' + formatNum(tmp);
					}
				}
			}
			whichSelect += '</select>';
		}
	}
	return whichSelect;
}

function formatNum(numToFormat) {
	retNum = numToFormat + '';
	if (retNum != '') {
		hold = retNum.split('.');
		if (hold.length == 2) {
			if (hold[1].length == 1) { hold[1] += '0'; }
			hold[1] = hold[1].substr(0,1);
			retNum = hold[0] + '.' + hold[1]
		} else {
			retNum = hold[0] + '.00';
		}
	}
	return retNum;
}

function changedSel(obj) {
	if (obj) {
		if (obj.name ==	'size') {
			tmp = obj.options[obj.selectedIndex].value;
			if (tmp != '-') {
				mObj = document.getElementById('mount');
				if (indPricing[tmp][2] != 0 || indPricing[tmp][3] != 0) {
					if (mObj) { mObj.style.display = 'inline'; }
				} else {
					if (mObj) { mObj.style.display = 'none'; }
				}
			}
		}
		calculatePrice()
	}
}

function calculatePrice() {
	f = document.addCart;
	tags = document.getElementsByName('IorS');
	if (tags.length == 1) {
		whichPricing = tags[0].value;
	} else {
		if (tags[0].checked) { whichPricing = 'I'; } else { whichPricing = 'S'; }
	}
	cQty = getFieldValue('qty');
	photoQty = parseInt(cQty);
	cFinish = getDropDownValue('finishing');
	cFinishText = getDropDownText('finishing');
	cEffect = getDropDownValue('effects');
	cEffectText = getDropDownText('effects');
	cMount = getDropDownValue('mounting');
	cMountText = getDropDownText('mounting');
	//cFrame = getDropDownValue('frameing');
	//cFrameText = getDropDownText('frameing');
	// place holder until frameing is added
	cFrame = '0';
	cFrameText = 'none'
	// place holder until borders are added
	cBorder = '00';
	cBorderText = 'none';
	if (whichPricing == 'I') {
		cSize = getDropDownValue('size');
		cSizeText = getDropDownText('size');
		tmp = cSizeText.split('|');
		cSizeText = tmp[0];
		if (cSize != '-') {
			tmpPrice = indPricing[cSize][0];
			if (cFinish == 'ME') { tmpPrice += indPricing[cSize][1]; }
			if (cMount == 'C' && indPricing[cSize][2] != 0) { tmpPrice += indPricing[cSize][2]; }
			if (cMount == 'M' && indPricing[cSize][3] != 0) { tmpPrice += indPricing[cSize][3]; }
		}
	} else {
		cSize = getDropDownValue('sheetSize');
		cSizeText = getDropDownText('sheetSize');
		tmp = cSizeText.split('|');
		cSizeText = tmp[0];
		if (cSize != '-') {
			tmpPrice = sheetPricing[cSize][0];
			if (cFinish == 'ME') { tmpPrice += sheetPricing[cSize][1]; }
		}
	}
	tmpObj = document.getElementById('priceBox');
	if (!abObj) { abObj = document.getElementById('addBtn'); }
	if (cSize != '-') {
		basePrice = tmpPrice;
		tmpPrice = tmpPrice * parseInt(cQty);
		photoPrice = tmpPrice;
		if (tmpObj) {
			tmp = formatNum(tmpPrice);
			tmpObj.innerHTML = '$' + tmp;
		}
		photoSKU = '';
		if (eventCode) {
			if (eventCode != '') { photoSKU = eventCode.toUpperCase() + '-'; }
		}
		photoSKU += photoName + '-' + cSize + cFinish + cEffect + cMount + cFrame + cBorder;
		if (abObj) { abObj.className = 'addBtn'; }
		if (f) {
			if (f.quantity) { f.quantity.value = cQty; }
			if (f.item_number) { f.item_number.value = photoSKU; }
			if (f.item_name) { 
				tmp = photoName + ': ' + cSizeText + ', ' + cFinishText + ' finish';
				tmp += ', ' + cEffectText + ' effect';
				if (cBorder != '' && cBorder != '00') { tmp += ', ' + cBorderText + ' border'; }
				if (whichPricing == 'I') {
					if (cMount != '' && cMount != '0') { tmp += ', ' + cMountText + ' mounting'; }
					if (cFrame != '' && cFrame != '0') { tmp += ', ' + cFrameText + ' frame'; }
				}
				f.item_name.value = tmp;
			}
			if (f.amount) { f.amount.value = basePrice ; }
		}
	} else {
		photoPrice = 0;
		photoSKU = '';
		if (tmpObj) { tmpObj.innerHTML = '$0.00'; }
		if (abObj) { abObj.className = 'addBtnDisabled'; }
		if (f) {
			if (f.quantity) { f.quantity.value = 1; }
			if (f.item_number) { f.item_number.value = ''; }
			if (f.item_name) { f.item_name.value = ''; }
			if (f.amount) { f.amount.value = 0 ; }
		}
	}
}

function checkQty(obj) {
	if (obj) {
		if (obj.value == '') {
			obj.value = 1;
		} else {
			numberList = '0123456789';
			tmp = obj.value + '';
			for (var i = 0; i < tmp.length; i++) {
				if (numberList.indexOf(tmp.charAt(i)) == -1) {
					tmp = '1';
					break;
				}
			}
			i = parseInt(tmp);
			if (i > maxQty) { 
				i = maxQty; 
				alert('Sorry, but the maximum you can order of a single shot is ' + maxQty +'.\n\nIf you need more, please contact Christopher Bross Photography.')
			}
			obj.value = i
		}
		calculatePrice();
	}
}

function displayWelcome() {
	if (owObj && sObj) {
		if (welcomeText != '') { 
			if (coverObj) { 
				coverObj.style.display = 'none'; 
				covered = false;
			}
			tmp2 = '';
			if (welcomeTitle != '') { tmp2 = welcomeTitle; } else { tmp2 = '&nbsp;'; }
			tmp = '<table width=100% cellpadding=2 cellspacing=0 border=0><tr><td class=orderLeft>'+tmp2+'</td><td class=orderRight><div class=closeBtn onMouseOver="this.className=\'closeBtnOver\'" onMouseOut="this.className=\'closeBtn\'" onClick="closeOrderForm()">X</div></td></tr></table>';
			tmp += '<div class=orderArea>' + welcomeText + '</div>';
			owObj.innerHTML = tmp; 
			sObj.style.display = 'inline';
			owObj.style.display = 'inline';
			orderFormVisible = true;
			orderForm = '';
		}
	}
}

function toggleOrder(obj) {
	if (obj) {
		obj2 = obj.parentNode;
		if (obj2) {
			if (obj.id == 'notes') {
				obj2.innerHTML = orderForm;
			} else {
				orderForm = obj2.innerHTML;
				obj2.innerHTML = notes;
			}
		}
	}
}

function hideOrShow() {
	tmp = document.getElementsByTagName('input');
	if (tmp) {
		if (tmp.length > 0) {
			which = '';
			for (var i = 0; i < tmp.length; i++) {
				if (tmp[i].name == 'IorS') {
					if (tmp[i].checked) {
						which = tmp[i].value;
						break;
					}
				}
			}
			if (which != '') {
				obj = document.getElementById('iOnly');
				iSizeObj = document.getElementById('iSize');
				sSizeObj = document.getElementById('sSize');
				qtyObj = document.getElementById('qty');
				if (obj && iSizeObj && sSizeObj) {
					sSizeObj.selectedIndex = -1;
					iSizeObj.selectedIndex = -1;
					photoSKU = '';
					photoPrice = 0;
					photoQty = 1;
					if (qtyObj) { qtyObj.value = photoQty; }
					if (which == 'I') {
						obj.style.display = 'inline';
						sSizeObj.style.display = 'none';
						iSizeObj.style.display = 'inline';
					} else {
						obj.style.display = 'none';
						iSizeObj.style.display = 'none';
						sSizeObj.style.display = 'inline';
					}
					calculatePrice();
				}
			}
		}
	}
}

function applyEffect(obj) {
	if (obj) {
		if (document.all && navigator.appName.indexOf('Microsoft') > -1) {
			photoObj = document.getElementById('photo');
			amberObj = document.getElementById('amber');
			desatObj = document.getElementById('desaturated');
			if (photoObj && amberObj && desatObj) {
				tmpX = findPosX(photoObj);
				tmpY = findPosY(photoObj);

				disObj = document.getElementById('disclaimer');

				selEffect = obj.selectedIndex;
				switch (obj.options[selEffect].value) {
					case 'FC' :
						photoObj.className = '';
						amberObj.style.display = 'none';
						desatObj.style.display = 'none';
						if (disObj) { disObj.innerHTML = ''; }
						break;
					case 'BW' :
						photoObj.className = 'gray';
						amberObj.style.display = 'none';
						desatObj.style.display = 'none';
						if (disObj) { disObj.innerHTML = disclaimerText; }
						break;
					case 'WT' :
						desatObj.style.display = 'none';
						adjCorner = 13;
						adjSize = 23;
						if (!imageBorder) {
							adjCorner = 2;
							adjSize = 3;
						}
						amberObj.style.top = tmpY + adjCorner;
						amberObj.style.left = tmpX + adjCorner;
						amberObj.style.width = photoObj.offsetWidth - adjSize;
						amberObj.style.height = photoObj.offsetHeight - adjSize;
						photoObj.className = 'gray';
						amberObj.style.display = 'inline';
						if (disObj) { disObj.innerHTML = disclaimerText; }
						break;
					case 'DC' :
						amberObj.style.display = 'none';
						desatObj.style.top = tmpY + 2;
						desatObj.style.left = tmpX + 2;
						desatObj.style.width = photoObj.offsetWidth - 3;
						desatObj.style.height = photoObj.offsetHeight - 3;
						photoObj.className = 'gray';
						desatObj.style.display = 'inline';
						if (disObj) { disObj.innerHTML = disclaimerText; }
						break;
				}
			}
		}
	}
}

function getFieldValue(fieldName) {
	ret = ''
	if (fieldName != '') {
		tags = document.getElementsByName(fieldName);
		if (tags) { ret = tags[0].value; }
	}
	return ret;
}

function getDropDownValue(fieldName) {
	ret = '';
	if (fieldName != '') {
		tags = document.getElementsByName(fieldName);
		if (tags) {
			ret = tags[0].options[tags[0].selectedIndex].value;
		}
	}
	return ret;
}


function getDropDownText(fieldName) {
	ret = '';
	if (fieldName != '') {
		tags = document.getElementsByName(fieldName);
		if (tags) {
			ret = tags[0].options[tags[0].selectedIndex].text;
		}
	}
	return ret;
}

function btnOver(obj) {
	if (obj) {
		if (obj.className != 'btnDisabled') { obj.className = 'btnOver'; }
	}
}

function btnOut(obj) {
	if (obj) {
		if (obj.className != 'btnDisabled') { obj.className = 'btn'; }
	}
}

function addToCart() {
	if (photoSKU != '') {
		f = document.addCart;
		if (f) { f.submit(); }
	} else {
		alert('You need to select a size in which to order.');
	}
}

function viewCart() {
	if (!orderFormVisible) {
		f = document.vwCart;
		if (f) {
			f.submit();
		} else {
			alert('Error on page while accessing the cart.');
		}
	}
}

function closeOrderForm() {
	if (owObj && sObj) {
		owObj.style.display = 'none';
		sObj.style.display = 'none';
		if (coverObj) { coverObj.style.display = 'none'; covered = false; }
		orderFormVisible = false;
		hideEffects();
	}
}

function replaceEmbeddedTags(source) {
	ret = source;
	if (ret != '') {
		ret = '[' + ret + ']';
		for (var i = 0; i < embeddedTags.length; i++) {
			pattern = new RegExp(embeddedTags[i][0],'gi');
			tmpArray = ret.split(pattern);
			ret = tmpArray[0];
			wordLength = embeddedTags[i][0].length
			for (var h = 1; h < tmpArray.length; h++) {
				ret += eval(embeddedTags[i][1]) + '';
				ret += tmpArray[h];
			}
		}
		ret = ret.substring(1,ret.length - 1);
	}
	return ret;
}

function evalStrings() {
	if (welcomeTitle) { welcomeTitle = replaceEmbeddedTags(welcomeTitle); }
	if (welcomeText) { welcomeText = replaceEmbeddedTags(welcomeText); }
	if (notes) { notes = replaceEmbeddedTags(notes); }
}

function moveToImage(newIndex) {
	tmpImg = imgList[currentCat][newIndex];
	orderFormVisible = false;
	clickThumb(tmpImg);
}

function hideEffects() {
	amberObj = document.getElementById('amber');
	desatObj = document.getElementById('desaturated');
	if (amberObj && desatObj) {
		amberObj.style.display = 'none';
		desatObj.style.display = 'none';
	}
}