// JavaScript Document
function initGalleryConCuatro ( tempgallery, count, first_id, startwidth, startheight ) {
	imggallery_concuatro = tempgallery;
	if (preloadimg_concuatro=="yes"){
		for (x=0; x<imggallery_concuatro.length; x++){
			var myimage=new Image()
			myimage.src=imggallery_concuatro[x][0]
		}
	}
	
	current_imgid_concuatro = first_id;
	currentwidth_concuatro=startwidth;
	currentheight_concuatro=startheight;
	
	window.addEvent('load', function() {
		var setloadersize = new Fx.Styles('main_image_wrapper_concuatro',{duration:transspeed_concuatro,onComplete: function(){loadfirstimageConCuatro(currentwidth_concuatro,currentheight_concuatro)}});
		
		setloadersize.start({
			'width':imggallery_concuatro[0][1],
			'height':imggallery_concuatro[0][2]	
		});
	});
	
	
}

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

function getstartedConCuatro(width, height, loadarea, imgindex, img_id, current_imgid){
	if(current_imgid!=img_id){
		if(firstimagestart_concuatro==1){
			currentwidth_concuatro=firstimagewidth_concuatro;
			currentheight_concuatro=firstimageheight_concuatro;
			firstimagestart_concuatro=0;		
		}
		if(nextorprev_concuatro==1){
			currentwidth_concuatro=cwidth_concuatro;
			currentheight_concuatro=cheight_concuatro;
			nextorprev_concuatro=0;		
		}
		
		var resizeDivHeight = new Fx.Styles('main_image_wrapper_concuatro',{duration:transspeed_concuatro, onComplete: function(){modifyimage_concuatro(loadarea, imgindex, img_id);currentheight_concuatro=height;currentwidth_concuatro=width;} });
		var fader = new Fx.Style('imgloader_concuatro','opacity', {duration:fadespeed_concuatro, onComplete: function(){	resizeDivHeight.start({'height': [currentheight_concuatro,height],'width': [currentwidth_concuatro,width]});} });
		fader.start(1,0);
		var titlefade = new Fx.Style('desc_concuatro','opacity', {duration:transspeed });
		titlefade.set(0);	
	}
}
function loadfirstimageConCuatro(currentwidth_concuatro,currentheight_concuatro){
	var fadefirst = new Fx.Style('imgloader_concuatro','opacity', {duration:fadespeed_concuatro });
	fadefirst.set(0);
	var firsttitlefade = new Fx.Style('desc_concuatro','opacity', {duration:transspeed });
	firsttitlefade.set(0);
	function setfirstimage(){
		var newHTML = "<a href='"+tempgallery_concuatro[0][7]+"' target='_self'><img src='"+tempgallery_concuatro[0][0]+"' border='0' /></a>";
		$('imgloader_concuatro').setHTML(newHTML);
	
		var firsttitle=document.getElementById('desc_concuatro');
		firsttitle.innerHTML="<strong style='text-transform:uppercase'>"+ tempgallery_concuatro[0][5] +"</strong> <br />"+ tempgallery_concuatro[0][6];
		fadefirst.start(0,1);
		firsttitlefade.start(0,1);
		currentheight_concuatro=imggallery_concuatro[0][2];
		currentwidth_concuatro=imggallery_concuatro[0][1];
	}
	new Asset.image(imggallery_concuatro[0][0], {onload: setfirstimage});
}
function nextimageConCuatro(current_imgid){
    var next = Number(current_imgid)+1;
    if (next >= tempgallery_concuatro.length) next = 0; 
	newimgid_concuatro = Number(current_imgid)+1;
	newwidth_concuatro =imggallery_concuatro[newimgid_concuatro][1]
	newheight_concuatro =imggallery_concuatro[newimgid_concuatro][2]
	newimgindex_concuatro =imggallery_concuatro[newimgid_concuatro][8]
	newimgid_concuatro = imggallery_concuatro[newimgid_concuatro][8]
	cwidth_concuatro=imggallery_concuatro[current_imgid][1]
	cheight_concuatro=imggallery_concuatro[current_imgid][2]
	nextorprev_concuatro=1;
	getstartedConCuatro(Number(newwidth_concuatro), Number(newheight_concuatro), 'imgloader_concuatro',Number(newimgindex_concuatro) ,Number(newimgid_concuatro) , Number(current_imgid), Number(cwidth_concuatro), Number(cheight_concuatro))
	
}

function previmageConCuatro(current_imgid){
	var prev = Number(current_imgid)-1;
    if (prev < 0) prev = tempgallery_concuatro.length-1; 
	newimgid_concuatro = Number(current_imgid)-1;
	newwidth_concuatro =imggallery_concuatro[newimgid_concuatro][1]
	newheight_concuatro =imggallery_concuatro[newimgid_concuatro][2]
	newimgindex_concuatro =imggallery_concuatro[newimgid_concuatro][8]
	newimgid_concuatro = imggallery_concuatro[newimgid_concuatro][8]
	cwidth_concuatro=imggallery_concuatro[current_imgid][1]
	cheight_concuatro=imggallery_concuatro[current_imgid][2]
	nextorprev_concuatro=1;
	getstartedConCuatro(Number(newwidth_concuatro), Number(newheight_concuatro), 'imgloader_concuatro',Number(newimgindex_concuatro) ,Number(newimgid_concuatro) , Number(current_imgid), Number(cwidth_concuatro), Number(cheight_concuatro))
}

