// JavaScript Document
function initGalleryConDos ( tempgallery, count, first_id, startwidth, startheight ) {
	imggallery_condos = tempgallery;
	if (preloadimg_condos=="yes"){
		for (x=0; x<imggallery_condos.length; x++){
			var myimage=new Image()
			myimage.src=imggallery_condos[x][0]
		}
	}
	
	current_imgid_condos = first_id;
	currentwidth_condos=startwidth;
	currentheight_condos=startheight;
	
	window.addEvent('load', function() {
		var setloadersize = new Fx.Styles('main_image_wrapper_condos',{duration:transspeed_condos,onComplete: function(){loadfirstimageConDos(currentwidth_condos,currentheight_condos)}});
		
		setloadersize.start({
			'width':imggallery_condos[0][1],
			'height':imggallery_condos[0][2]	
		});
	});
	
	
}

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

function getstartedConDos(width, height, loadarea, imgindex, img_id, current_imgid){
	if(current_imgid!=img_id){
		if(firstimagestart_condos==1){
			currentwidth_condos=firstimagewidth_condos;
			currentheight_condos=firstimageheight_condos;
			firstimagestart_condos=0;		
		}
		if(nextorprev_condos==1){
			currentwidth_condos=cwidth_condos;
			currentheight_condos=cheight_condos;
			nextorprev_condos=0;		
		}
		
		var resizeDivHeight = new Fx.Styles('main_image_wrapper_condos',{duration:transspeed_condos, onComplete: function(){modifyimage_condos(loadarea, imgindex, img_id);currentheight_condos=height;currentwidth_condos=width;} });
		var fader = new Fx.Style('imgloader_condos','opacity', {duration:fadespeed_condos, onComplete: function(){	resizeDivHeight.start({'height': [currentheight_condos,height],'width': [currentwidth_condos,width]});} });
		fader.start(1,0);
		var titlefade = new Fx.Style('desc_condos','opacity', {duration:transspeed });
		titlefade.set(0);	
	}
}
function loadfirstimageConDos(currentwidth_condos,currentheight_condos){
	var fadefirst = new Fx.Style('imgloader_condos','opacity', {duration:fadespeed_condos });
	fadefirst.set(0);
	var firsttitlefade = new Fx.Style('desc_condos','opacity', {duration:transspeed });
	firsttitlefade.set(0);
	function setfirstimage(){
		var newHTML = "<a href='"+tempgallery_condos[0][7]+"' target='_self'><img src='"+tempgallery_condos[0][0]+"' border='0' /></a>";
		$('imgloader_condos').setHTML(newHTML);
	
		var firsttitle=document.getElementById('desc_condos');
		firsttitle.innerHTML="<strong style='text-transform:uppercase'>"+ tempgallery_condos[0][5] +"</strong> <br />"+ tempgallery_condos[0][6];
		fadefirst.start(0,1);
		firsttitlefade.start(0,1);
		currentheight_condos=imggallery_condos[0][2];
		currentwidth_condos=imggallery_condos[0][1];
	}
	new Asset.image(imggallery_condos[0][0], {onload: setfirstimage});
}
function nextimageConDos(current_imgid){
    var next = Number(current_imgid)+1;
    if (next >= tempgallery_condos.length) next = 0; 
	newimgid_condos = Number(current_imgid)+1;
	newwidth_condos =imggallery_condos[newimgid_condos][1]
	newheight_condos =imggallery_condos[newimgid_condos][2]
	newimgindex_condos =imggallery_condos[newimgid_condos][8]
	newimgid_condos = imggallery_condos[newimgid_condos][8]
	cwidth_condos=imggallery_condos[current_imgid][1]
	cheight_condos=imggallery_condos[current_imgid][2]
	nextorprev_condos=1;
	getstartedConDos(Number(newwidth_condos), Number(newheight_condos), 'imgloader_condos',Number(newimgindex_condos) ,Number(newimgid_condos) , Number(current_imgid), Number(cwidth_condos), Number(cheight_condos))
	
}

function previmageConDos(current_imgid){
	var prev = Number(current_imgid)-1;
    if (prev < 0) prev = tempgallery_condos.length-1; 
	newimgid_condos = Number(current_imgid)-1;
	newwidth_condos =imggallery_condos[newimgid_condos][1]
	newheight_condos =imggallery_condos[newimgid_condos][2]
	newimgindex_condos =imggallery_condos[newimgid_condos][8]
	newimgid_condos = imggallery_condos[newimgid_condos][8]
	cwidth_condos=imggallery_condos[current_imgid][1]
	cheight_condos=imggallery_condos[current_imgid][2]
	nextorprev_condos=1;
	getstartedConDos(Number(newwidth_condos), Number(newheight_condos), 'imgloader_condos',Number(newimgindex_condos) ,Number(newimgid_condos) , Number(current_imgid), Number(cwidth_condos), Number(cheight_condos))
}

