
/* --------------------------------------------------- */
/* PRELOAD IMAGES */
/* --------------------------------------------------- */
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];}}
}


/* --------------------------------------------------- */
/* POP-UP WINDOW */
/* --------------------------------------------------- */
function openwin(URL,theHeight,theWidth,addScroll) {
	var nXpos = (screen.availWidth - theWidth) / 2; 
	var nYpos = (screen.availHeight - theHeight) / 2; 
	var win = window.open(URL, 'popupWin', 'top=' + nYpos + ',left=' + nXpos + ',screenY=' + nYpos + ',screenX=' + nXpos + ',height=' + theHeight + ',width=' + theWidth + 'toolbar=0,scrollbars=' + addScroll + ',location=0,statusbar=0,menubar=0');
	win.focus();
}


/* --------------------------------------
FLASH FIX FOR IE
--------------------------------------- */
function ieFix(filePath, theHeight, theWidth, varName, cookieVar, bgColor)
{
  document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="' + theWidth + '" height="' + theHeight + '" id="' + filePath + '" align="middle">\n');
	document.write('<param name="allowScriptAccess" value="sameDomain">\n');
	document.write('<PARAM NAME=movie VALUE="' + filePath + '.swf">\n');
  document.write('<PARAM NAME=quality VALUE=high>\n');
  document.write('<param name="flashvars" value="' + varName + '=' + cookieVar + '">\n');
	document.write('<PARAM NAME=scale VALUE=noborder>\n');
	document.write('<PARAM NAME=menu VALUE=false>\n');
	document.write('<param name="wmode" value="transparent" />\n');
	document.write('<PARAM NAME=bgcolor VALUE=#' + bgColor + '>\n');
	document.write('<embed src="' + filePath + '.swf" wmode="transparent" quality="high" flashvars="' + varName + '=' + cookieVar + '" bgcolor="#' + bgColor + '" width="' + theWidth + '" height="' + theHeight + '" name="' + filePath + '" align="center" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer">\n');
	document.write('</object>\n');
}


/* --------------------------------------------------- */
/* NAVIGATE IMAGE ARRAY */
/* --------------------------------------------------- */
function showDefault() {
	document.getElementById('galleryPics').innerHTML = '<img src="' + imageArray[0] + '">';
}

function next(keyValue) {
	if (currentKey < (imageArray.length - 1)) {
		keyValue = keyValue + 1;
		currentKey++;
	} else {
		keyValue = 0;
		currentKey = 0;
	}
	
	document.getElementById('galleryPics').innerHTML = '<img src="' + imageArray[keyValue] + '">';
}

function previous(keyValue) {
	if (currentKey <= (imageArray.length - 1) && currentKey !== 0) {
		keyValue = keyValue - 1;
		currentKey--;
	} else {
		keyValue = (imageArray.length - 1);
		currentKey = (imageArray.length - 1);
	}
	
	document.getElementById('galleryPics').innerHTML = '<img src="' + imageArray[keyValue] + '">';
}
