<ja:if test=<%=chameleon.voiceAnnotations && !chameleon.isMovie%>><script type="text/javascript" src="$resPath/embedmovie.js"></script></ja:if>
<ja:if test=<%=chameleon.includeGuestBookTop || chameleon.includeGuestBookBottom%>><script type="text/javascript" src="$resPath/embedguestbook.js"></script></ja:if>
<script type="text/javascript">
/* <![CDATA[ */
<ja:if test=<%=!chameleon.fitImageNone%>>
function getRatio() {
	if (ww = window.innerWidth) wh = window.innerHeight;
	else if(document.documentElement) {
		ww = document.documentElement.clientWidth;
		wh = document.documentElement.clientHeight;
	} 
	else return 1;
	rw = (ww - ${widthDecr}) / ${mImageWidth}; 
	rh = (wh - ${heightDecr}) / ${mImageHeight};
	if (rw > rh) rw = rh;
<ja:if test=${fitImageEnlarge}>	if (rw <= 1.0) return 1;</ja:if>
<ja:if test=${fitImageShrink}>	if (rw >= 1.0) return 1;</ja:if>
	return rw;
}
function correctImage() {
	var ratio = getRatio();
	if ((el = document.getElementById("slide")) != null) {
		el.width *= ratio;
		el.height *= ratio;
	}
	if ((el = document.getElementById("imap")) != null) {
		for (i = 0; i < el.areas.length; i++) {
			coords = el.areas[i].coords.split(',');
			for (cs = "", j = 0; j < coords.length; j++) {
				if (j > 0) cs += ','; cs += parseInt(coords[j] * ratio);
			}
			el.areas[i].coords = cs;
		}
	}
}
</ja:if>
function keypress(e) {
	if(!e) var e=window.event;
	if(e.keyCode) keyCode=e.keyCode; 
	else if(e.which) keyCode=e.which;
	switch(keyCode) {
		case 8: window.location="../$indexPage"; return false; break;
		<ja:if exists="nextPage">case 63235: case 39: window.location="$nextPage"; return false; break;</ja:if>
		<ja:if exists="previousPage">case 63234: case 37: window.location="$previousPage"; return false; break;</ja:if>
		<ja:if exists="firstPage">case 63273: case 36: window.location="$firstPage"; return false; break;</ja:if>
		<ja:if exists="lastPage">case 63275: case 35: window.location="$lastPage"; return false; break;</ja:if>
		<ja:if test=${doSlideShow}>case 32: show_down(); setTimeout('show_out()', 200); return false; break;</ja:if>
	}
	return true;
}
function keypresslistener() {
  if(document.all) { document.onkeydown = keypress; }
  else if(document.layers || document.getElementById) { document.onkeypress = keypress; }
}
idx0 = new Image(31,31); idx0.src = "$resPath/idx.gif";
idx1 = new Image(31,31); idx1.src = "$resPath/idx1.gif";
next0 = new Image(31,31);next0.src = "$resPath/next.gif";
next1 = new Image(31,31);next1.src = "$resPath/next1.gif";
prev0 = new Image(31,31);prev0.src = "$resPath/prev.gif";
prev1 = new Image(31,31);prev1.src = "$resPath/prev1.gif";
<ja:if test=${doSlideShow}>
show0 = new Image(31,31);show0.src = "$resPath/show.gif";
show1 = new Image(31,31);show1.src = "$resPath/show1.gif";
stop0 = new Image(31,31);stop0.src = "$resPath/stop.gif";
stop1 = new Image(31,31);stop1.src = "$resPath/stop1.gif";

var show_param = -1;
if (window.location.search.length > 1) {
	var parms = window.location.search.substring(1,location.search.length).split("&");
	for (var i = 0; i < parms.length; i++) {		
		if(parms[i].substring(0, parms[i].indexOf("=")) == "show_param") 
			delay = show_param = parms[i].substring(parms[i].indexOf("=") + 1, parms[i].length);
	}
}
var show_delay = show_param;
function show_timer() {
	if (show_delay >= 0) {
		show_delay--;
		if (show_delay < 0 && show_param > 0) {
			<ja:if exists="nextPage">window.location="$nextPage?show_param=" + show_param;</ja:if>
			<ja:else><ja:if test=${slideShowLoop}>window.location="$firstPage?show_param=" + show_param;</ja:if><ja:else>show_down(); setTimeout('show_out()', 200);</ja:else></ja:else>
		}
		else if(show_param > 0) 
			window.status='Time left: '+(show_delay + 1)+' s';
	}
	setTimeout('show_timer()', 1000);	
}
function show_over() {
	document.getElementById("show").src = (show_param >= 0)? stop1.src : show1.src;
	window.status = '$text.startStopSlideShow - $text.changeSpeed';
}
function show_out() {
	document.getElementById("show").src = (show_param >= 0)? stop0.src : show0.src;
}
function show_down() {
	el = document.getElementById("show");
	if (show_param >= 0) { 
		show_param = -1; 
		el.src = stop1.src; 
		window.status=''; 
	} 
	else { 
		show_param = ${slideShowDelay}; 
		el.src = show1.src; 
	} 
	show_delay = show_param; 
}
function change_delay() {
	delay = prompt('$text.delay', (show_param < 0)? ${slideShowDelay} : show_param);
	show_param = show_delay = delay; 
	document.getElementById("show").src = show1.src;
}
</ja:if>
<ja:if test=${newLabel}>
function generatenew(fDays) {
  now = new Date();
  nDays = now.getTime() / 86400000;
  if((nDays - fDays) <= ${newLabelDaysCount})
    document.write('<span class="newlabel">&nbsp;$text.new&nbsp;<\/span><%=("$text.new".length() > 4)? "<br />":"&nbsp;"%>');
}
</ja:if>
<ja:if test=<%=(chameleon.includeGuestBookTop || chameleon.includeGuestBookBottom)%>>
var color = "#999999";
var bgcolor = "#333333";
function rgb2hex(c) {
	if(c.charAt(0) == '#') return c;
	else if(c.indexOf('rgb') == 0) {
		var hex = '';
		var array = /([0-9]+)[, ]+([0-9]+)[, ]+([0-9]+)/.exec(c);
		for(i = 1; i < 4; i++) hex += ('0' + parseInt(array[i]).toString(16)).slice(-2);
		return '#' + hex;
	}
	else return '#000000';
}

function getColors() {
	if((el = document.getElementById("body")) != null) {
		if(window.getComputedStyle) {
			color = rgb2hex(document.defaultView.getComputedStyle(el, null).getPropertyValue('color'));
			bgcolor = rgb2hex(document.defaultView.getComputedStyle(el, null).getPropertyValue('background-color'));
		}
		else if(el.currentStyle != null) {
			color = el.currentStyle['color'];
			bgcolor = el.currentStyle['backgroundColor'];
		}
	}
}

function showGuestbook() {
	getColors();
	embedGuestbook("${guestBookPath}/guestbook.swf", ${guestBookWidth}, ${guestBookHeight}, "xmlfile=${guestBookFile}.xml&xmlphp_path=${guestBookPath}/&width=${guestBookWidth}&width=${guestBookHeight}&basefontsize=${guestbookBaseFontSize}&bgcolor=" + bgcolor + "&countcolor=" + color + "&usercolor=${guestbookHighlightColor}&commentscolor=" + color + "&pagelabel=$text.page&namelabel=$text.name&msglabel=$text.message&nameerror=$text.enterName&msgerror=$text.enterMessage&welcomemsg=$text.welcomeMessage&showrating=${guestBookRating}&ratinglabel=$text.rating&avgratinglabel=$text.avgRating&ascending=${guestbookAscending}&dateFormat=${gbDateFormat}&msgscount=${guestbookEntries}");
}
</ja:if>
<ja:if test=<%=!chameleon.paypalCustom && chameleon.paypalTop || chameleon.paypalBottom%>>
var ppitems = new Array(${paypalItemsArray});

<ja:if test=${paypalInline}>
function submitPaypal() {
	form = document.forms['paypal'];
<ja:if test=<%=chameleon.paypalItemsCount > 1%>>
	for (sel = 0; sel < ${paypalItemsCount}; sel++)
		if (form.options[sel].checked)
			break;
	if (sel == ${paypalItemsCount}) {
		alert("$text.noneSelectedAlert");
		return;
	}
</ja:if><ja:else>
	var sel = 0;
</ja:else>

	form['item_name'].value = ppitems[sel][0];
	form['item_number'].value = "<%=chameleon.stripNonWeb(chameleon.simplePath) + "/" + label%> (" + ppitems[sel][3] + ")";
	form['amount'].value = ppitems[sel][1];
<ja:if test=${paypalShippingUsed}>	form['shipping'].value = ppitems[sel][2];</ja:if>
	form['add'].value = "1";
	form.target = "paypal";
	form.submit();
}

<ja:if test=<%=chameleon.paypalItemsCount > 1%>>
function updatePrice(sel) {
	form = document.forms['paypal'];
	if (form.options[sel].checked) {
		if (ppitems[sel][2].length > 0)
			form['price'].value = "${paypalCurrency} " + ppitems[sel][1] + " (+" + ppitems[sel][2] + ")";
		else
			form['price'].value = "${paypalCurrency} " + ppitems[sel][1];
	}
}</ja:if>
</ja:if><ja:else>
function submitPaypal(sel) {
	form = document.forms['paypal'];
	form['item_name'].value = ppitems[sel][0];
	form['item_number'].value = "<%=chameleon.stripNonWeb(chameleon.simplePath + "/" + label)%> (" + ppitems[sel][3] + ")";
	form['amount'].value = ppitems[sel][1];
	form['add'].value = "1";
<ja:if test=${paypalUseSelect}>	form['os0'].value = form['select' + sel].value;</ja:if>
<ja:if test=${paypalShippingUsed}>	form['shipping'].value = ppitems[sel][2];</ja:if>
<ja:if test=${paypalUseQuantity}>	form['quantity'].value = form['quantity' + sel].value;</ja:if>
	form.target = "paypal";
	form.submit();
}
</ja:else>
function viewPaypal() {
	form = document.forms['paypalview'];
	form.target = "paypal";
	form.submit();
}
</ja:if>
/* ]]> */
</script>
<ja:if test=<%=chameleon.printingPhotobox && chameleon.printOrderOn%>><script type="text/javascript" src="http://printbutton.com/${companyId}.js"></script></ja:if>

