// JavaScript Documentvar currentpos=0;var currentthumbpos=0;var moveamount=106;var thumbnailnum;var maxthumbvisible = 5; //Define how many thumbnails will be visible at one time in the thumbbox--for now this should only be 3 since it's actually the css that controls the size of the viewable boxvar current_imgid=0;var moving = false;var finishedsizing=0;var preloadimg="no"//Preload images ("yes" or "no"):var myloadedimage = new Array();     myloadedimage[0]=1;var imggallery=new Array()var firstimagestart=1;var nextorprev=0;var fadeout=1;function areweready(loadarea, imgindex, img_id){	if ( finishedsizing++ ) { 		modifyimage(loadarea, imgindex, img_id);		finishedsizing = 0;	}}function modifyimage(loadarea, imgindex, img_id ){			loadimagenow(loadarea, imgindex, img_id);}function loadimagenow(loadarea, imgindex, img_id){	if (document.getElementById) {			if(current_imgid!=img_id){								if(imggallery[imgindex][9] == 2){					var imgobj=document.getElementById(loadarea);					var photonum=document.getElementById('photocount')					var phototitle=document.getElementById('imgtitle')										imgobj.innerHTML= '';										if(myObj = document.getElementById('pn_overlay')){						myObj.parentNode.removeChild(myObj);											}										imgobj.innerHTML=returnswfcode(imggallery[imgindex]);					swfobject.removeSWF("swfobject");					swfobject.embedSWF(imggallery[imgindex][0], "swfobject", imggallery[imgindex][1], imggallery[imgindex][2], "9.0.0");					photonum.innerHTML=(Number(imgindex)+1)+" von "+imggallery.length;					phototitle.innerHTML="<strong>"+tempgallery[img_id][4]+"</strong> "+tempgallery[img_id][7];					initImage(loadarea);					current_imgid=img_id;					myloadedimage[imgindex]=1;					}else{					var imgobj=document.getElementById(loadarea);					var photonum=document.getElementById('photocount')					var phototitle=document.getElementById('imgtitle')									imgobj.innerHTML=returnimgcode(imggallery[imgindex]);									photonum.innerHTML=(Number(imgindex)+1)+" von "+imggallery.length;					phototitle.innerHTML="<strong>"+tempgallery[img_id][4]+"</strong> "+tempgallery[img_id][7];					initImage(loadarea);					current_imgid=img_id;					myloadedimage[imgindex]=1;				}			}		}	return false}function returnimgcode(theimg){	var imghtml=""	if (theimg[1]!="")		imghtml=''	imghtml+='<img src="'+theimg[0]+'" border="0" id="'+theimg[8]+'" />'	if (theimg[1]!="")		imghtml+=''	return imghtml}function returnswfcode(theimg){	var swfhtml=""	if (theimg[1]!="")		imghtml=''	swfhtml+='<div id="swfobject" border="0"/>'	if (theimg[1]!="")		swfhtml+=''	return swfhtml}function initImage(imageId) {	var fader = new Fx.Style(imageId,'opacity', {duration:fadespeed});	fader.set(0);	fader.start(0,1);	var titlefade = new Fx.Style('imgtitle','opacity', {duration:transspeed });		titlefade.set(0);		titlefade.start(0,1);}function checkbutton(mynum){	if ( mynum == 0 ) {		mm_shl('back','hidden');		mm_shl('more','visible');	} else if ( mynum < thumbnailnum - maxthumbvisible ) {		mm_shl('back','visible');		mm_shl('more','visible');	} else {		mm_shl('back','visible');		mm_shl('more','hidden');	}}function mm_shl() { //v6.0	var obj,args=arguments;	if ((obj=MM_findObj(args[0]))!=null) {		if (obj.style) {			obj=obj.style;		}		obj.visibility=args[1];	}}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 addposition(addwidth){	if ( !moving ) {		 // if animagic is still moving the image..don't update the current position till it's done		if(addwidth=="minus"){			currentpos-=1;			alert(currentpos);		}else if(addwidth=="plus"){			currentpos+=1;		}	}	return currentpos;}function MM_openBrWindow(theURL,winName,features) { //v2.0  window.open(theURL,winName,features);}	// JavaScript Documentfunction initGallery ( tempgallery, count, first_id, startwidth, startheight, type ) {	imggallery = tempgallery;	if (preloadimg=="yes"){		for (x=0; x<imggallery.length; x++){			var myimage=new Image()			myimage.src=imggallery[x][0]		}	}	thumbnailnum = imggallery.length;	current_imgid = first_id;	currentwidth=startwidth;	currentheight=startheight;		window.onload=function(){loadfirstimage(type)}}	function getstarted(width, height, loadarea, imgindex, img_id, current_imgid, cwidth, cheight){		checknext(img_id);		if(current_imgid!=img_id){			if(firstimagestart==1){				//currentwidth=firstimagewidth;				//currentheight=firstimageheight;				currentwidth=cwidth;				currentheight=cheight;				firstimagestart=0;				}			if(nextorprev==1){				currentwidth=cwidth;				currentheight=cheight;				nextorprev=0;			}						var resizeDivHeight = new Fx.Styles('main_image_wrapper',{duration:transspeed, onComplete: function(){loadimagenow(loadarea, imgindex, img_id);currentheight=height;currentwidth=width;} });			var fader = new Fx.Style('imgloader','opacity', {duration:fadespeed, onComplete: function(){	resizeDivHeight.start({'height': [currentheight,height],'width': [currentwidth,width]});} });			fader.start(1,0);							var titlefade = new Fx.Style('imgtitle','opacity', {duration:transspeed });			titlefade.set(0);			fadeout=0			var linkfade = new Fx.Style('external_link','opacity', {duration:transspeed });			linkfade.set(0);						if(imggallery[imgindex][10] != ""){				$('external_link').innerHTML = '<a href="'+imggallery[imgindex][10]+'" target="_blank">'+imggallery[imgindex][10]+'</a>';				linkfade.start(0,1);			}else{				$('external_link').innerHTML ="";			}					}			}	function loadfirstimage(type){						if(type == 2){			var imgobj=document.getElementById('imgloader');						imgobj.innerHTML=returnswfcode(imggallery[0]);						swfobject.embedSWF(imggallery[0][0], "swfobject", imggallery[0][1], imggallery[0][2], "9.0.0", "expressInstall.swf");			if(myObj = document.getElementById('pn_overlay')){				myObj.parentNode.removeChild(myObj);							}					}		else{			var firstimageload = new Image();			firstimageload.src = null;			firstimageload.src = imggallery[0][0];			var fadefirst = new Fx.Style('imgloader','opacity', {duration:fadespeed });			fadefirst.set(0);			var firsttitlefade = new Fx.Style('imgtitle','opacity', {duration:transspeed });			firsttitlefade.set(0);			var linkfade = new Fx.Style('external_link','opacity', {duration:transspeed });			linkfade.set(0);			if($('external_link') != ""){				$('external_link').innerHTML = '<a href="'+imggallery[0][10]+'" target="_blank">'+imggallery[0][10]+'</a>'							}						var setfirstheight = new Fx.Style('main_image_wrapper','height',{duration:transspeed});			var setfirstwidth =  new Fx.Style ('main_image_wrapper','width',{duration:transspeed});			setfirstwidth.start(currentwidth,imggallery[0][1]);			setfirstheight.start(currentheight,imggallery[0][2]);							fadefirst.start(0,1);				firsttitlefade.start(0,1);				linkfade.start(0,1);				currentheight=imggallery[0][2];				currentwidth=imggallery[0][1];		}			}	function nextimage(current_imgid){		newimgid = Number(current_imgid)+1;		newwidth =imggallery[newimgid][1]		newheight =imggallery[newimgid][2]		newimgindex =imggallery[newimgid][8]		newimgid = imggallery[newimgid][8]		cwidth=imggallery[current_imgid][1]		cheight=imggallery[current_imgid][2]		checknext(newimgid);		nextorprev=1;		getstarted(Number(newwidth), Number(newheight), 'imgloader',Number(newimgindex) ,Number(newimgid) , Number(current_imgid), Number(cwidth), Number(cheight))	}	function previmage(current_imgid){		newimgid = Number(current_imgid)-1;		newwidth =imggallery[newimgid][1]		newheight =imggallery[newimgid][2]		newimgindex =imggallery[newimgid][8]		newimgid = imggallery[newimgid][8]		cwidth=imggallery[current_imgid][1]		cheight=imggallery[current_imgid][2]		checknext(newimgid);		nextorprev=1;		getstarted(Number(newwidth), Number(newheight), 'imgloader',Number(newimgindex) ,Number(newimgid) , Number(current_imgid), Number(cwidth), Number(cheight))	}		function checknext(mynum){		thumbmax=(Number(thumbnailnum)-1);		if ( mynum < 1 ) {			mm_shl('prev','hidden');			mm_shl('next','visible');		} else if ( mynum <  thumbmax ) {			mm_shl('prev','visible');			mm_shl('next','visible');		} else {			mm_shl('prev','visible');			mm_shl('next','hidden');		}	}
