// JavaScript Document
function initGalleryConUno ( tempgallery, count, first_id, startwidth, startheight ) {
	imggallery_conuno = tempgallery;
	if (preloadimg_conuno=="yes"){
		for (x=0; x<imggallery_conuno.length; x++){
			var myimage=new Image()
			myimage.src=imggallery_conuno[x][0]
		}
	}
	
	current_imgid_conuno = first_id;
	currentwidth_conuno=startwidth;
	currentheight_conuno=startheight;
	
	window.addEvent('load', function() {
		var setloadersize = new Fx.Styles('main_image_wrapper_conuno',{duration:transspeed_conuno,onComplete: function(){loadfirstimageConUno(currentwidth_conuno,currentheight_conuno)}});
		
		setloadersize.start({
			'width':imggallery_conuno[0][1],
			'height':imggallery_conuno[0][2]	
		});
	});
	
	
}

window.addEvent('domready', function() {
	if (tempgallery_conuno.length > 0) initGalleryConUno( tempgallery_conuno, tempgallery_conuno.length, tempgallery_conuno[0][8], tempgallery_conuno[0][1], tempgallery_conuno[0][2], 0 );
});

function getstartedConUno(width, height, loadarea, imgindex, img_id, current_imgid){
	if(current_imgid!=img_id){
		if(firstimagestart_conuno==1){
			currentwidth_conuno=firstimagewidth_conuno;
			currentheight_conuno=firstimageheight_conuno;
			firstimagestart_conuno=0;		
		}
		if(nextorprev_conuno==1){
			currentwidth_conuno=cwidth_conuno;
			currentheight_conuno=cheight_conuno;
			nextorprev_conuno=0;		
		}
		
		var resizeDivHeight = new Fx.Styles('main_image_wrapper_conuno',{duration:transspeed_conuno, onComplete: function(){modifyimage_conuno(loadarea, imgindex, img_id);currentheight_conuno=height;currentwidth_conuno=width;} });
		var fader = new Fx.Style('imgloader_conuno','opacity', {duration:fadespeed_conuno, onComplete: function(){	resizeDivHeight.start({'height': [currentheight_conuno,height],'width': [currentwidth_conuno,width]});} });
		fader.start(1,0);
		var titlefade = new Fx.Style('desc_conuno','opacity', {duration:transspeed });
		titlefade.set(0);	
	}
}
function loadfirstimageConUno(currentwidth_conuno,currentheight_conuno){
	var fadefirst = new Fx.Style('imgloader_conuno','opacity', {duration:fadespeed_conuno });
	fadefirst.set(0);
	var firsttitlefade = new Fx.Style('desc_conuno','opacity', {duration:transspeed });
	firsttitlefade.set(0);
	function setfirstimage(){
		var newHTML = "<a href='"+tempgallery_conuno[0][7]+"' target='_self'><img src='"+tempgallery_conuno[0][0]+"' border='0' /></a>";
		$('imgloader_conuno').setHTML(newHTML);
	
		var firsttitle=document.getElementById('desc_conuno');
		firsttitle.innerHTML="<strong style='text-transform:uppercase'>"+ tempgallery_conuno[0][5] +"</strong> <br />"+ tempgallery_conuno[0][6];
		fadefirst.start(0,1);
		firsttitlefade.start(0,1);
		currentheight_conuno=imggallery_conuno[0][2];
		currentwidth_conuno=imggallery_conuno[0][1];
	}
	new Asset.image(imggallery_conuno[0][0], {onload: setfirstimage});
}
function nextimageConUno(current_imgid){
    var next = Number(current_imgid)+1;
    if (next >= tempgallery_conuno.length) next = 0; 
	newimgid_conuno = Number(current_imgid)+1;
	newwidth_conuno =imggallery_conuno[newimgid_conuno][1]
	newheight_conuno =imggallery_conuno[newimgid_conuno][2]
	newimgindex_conuno =imggallery_conuno[newimgid_conuno][8]
	newimgid_conuno = imggallery_conuno[newimgid_conuno][8]
	cwidth_conuno=imggallery_conuno[current_imgid][1]
	cheight_conuno=imggallery_conuno[current_imgid][2]
	nextorprev_conuno=1;
	getstartedConUno(Number(newwidth_conuno), Number(newheight_conuno), 'imgloader_conuno',Number(newimgindex_conuno) ,Number(newimgid_conuno) , Number(current_imgid), Number(cwidth_conuno), Number(cheight_conuno))
	
}

function previmageConUno(current_imgid){
	var prev = Number(current_imgid)-1;
    if (prev < 0) prev = tempgallery_conuno.length-1; 
	newimgid_conuno = Number(current_imgid)-1;
	newwidth_conuno =imggallery_conuno[newimgid_conuno][1]
	newheight_conuno =imggallery_conuno[newimgid_conuno][2]
	newimgindex_conuno =imggallery_conuno[newimgid_conuno][8]
	newimgid_conuno = imggallery_conuno[newimgid_conuno][8]
	cwidth_conuno=imggallery_conuno[current_imgid][1]
	cheight_conuno=imggallery_conuno[current_imgid][2]
	nextorprev_conuno=1;
	getstartedConUno(Number(newwidth_conuno), Number(newheight_conuno), 'imgloader_conuno',Number(newimgindex_conuno) ,Number(newimgid_conuno) , Number(current_imgid), Number(cwidth_conuno), Number(cheight_conuno))
}

