// JavaScript Document
function initGallery ( tempgallery, count, first_id, startwidth, startheight ) {
	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;
	thumbstripwidth = (document.getElementById('thumbbox').clientWidth) - 64;

	if(ready==false) {
		window.addEvent('load', function() {
			writeDivs();
	//		var setloadersize = new Fx.Styles('main_image_wrapper',{duration:transspeed,onComplete: function(){loadfirstimage(currentwidth,currentheight)}});
	//		setloadersize.start({
	//			'width':imggallery[0][1],
	//			'height':imggallery[0][2]	
	//		});
		});
	} else {
		writeDivs();
	}
	
	
}
var ready = false;
window.addEvent('load', function(){
	ready = true;
});
window.addEvent('domready', function() {
	initGallery( tempgallery, tempgallery.length, tempgallery[0][10], tempgallery[0][1], tempgallery[0][2], 0 );
});
function writeDivs()
{
	total_thumbswidth = document.getElementById('thumbgall').clientWidth;
	$('loading_picturestrip').style.visibility = 'hidden';
	$('picturestrip').style.visibility = 'visible';

	if(thumbstripwidth< total_thumbswidth){
		lefthtml = "<div id='leftmore'><ul><li><a href=\"javascript:checkbutton(addposition('minus'));movethumbs('plus');\"><img src='images/style/buttonblank.gif' width='32' height='145' border='0' /></a></li></ul></div>";
		righthtml = "<div id='rightmore'><ul><li><a href=\"javascript:checkbutton(addposition('plus'));movethumbs('minus');\"><img src='images/style/buttonblank.gif' width='32' height='145' border='0' /></a></li></ul></div>";
		$('back').setHTML(lefthtml);
		$('more').setHTML(righthtml);
	}
}

function getstarted(width, height, loadarea, imgindex, img_id, current_imgid){
	checknext(img_id);
	if(current_imgid!=img_id){
		if(firstimagestart==1){
			currentwidth=firstimagewidth;
			currentheight=firstimageheight;
			firstimagestart=0;		
		}
		if(nextorprev==1){
			currentwidth=cwidth;
			currentheight=cheight;
			nextorprev=0;		
		}
		
		var resizeDivHeight = new Fx.Styles('main_image_wrapper',{duration:transspeed, onComplete: function(){modifyimage(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 fadeiptc = new Fx.Style('iptc_btn','opacity', {duration:transspeed });
		fadeiptc.set(0);
		var titlefade = new Fx.Style('imgtitle','opacity', {duration:transspeed });
		titlefade.set(0);
		fadeout=0
		if(fadeout==0){
		var fademe = new Fx.Style('iptc_info','opacity', {duration:transspeed });
		fademe.set(0);
		fadeout=0;
		}else{
			var fademe = new Fx.Style('iptc_info','opacity', {duration:transspeed });
			fademe.start(1,0);
			fadeout=0
		}
	}
}


