// JavaScript Document

var currentpos_contres=0;
var current_imgid_contres=0;
var moving_contres = false;
var finishedsizing_contres=0;
var preloadimg_contres="no"//Preload images ("yes" or "no"):
var myloadedimage_contres = new Array();
     myloadedimage_contres[0]=1;
var imggallery_contres=new Array()
var firstimagestart_contres=1;
var nextorprev_contres=0;
var fadeout_contres=1;

function areweready_contres(loadarea, imgindex, img_id){
	if ( finishedsizing_contres++ ) { 
		modifyimage_contres(loadarea, imgindex, img_id);
		finishedsizing_contres = 0;
	}
}

function modifyimage_contres(loadarea, imgindex, img_id ){
	function loadimagenow(){
		if (document.getElementById) {
			
				if(current_imgid_contres!=img_id){
					
					var imgobj=document.getElementById(loadarea);
					var phototitle=document.getElementById('desc_contres')
					
					imgobj.innerHTML=returnimgcode_contres(imggallery_contres[imgindex]);
					phototitle.innerHTML="<strong style='text-transform:uppercase'>"+ tempgallery_contres[imgindex][5] +"</strong> <br />"+ tempgallery_contres[imgindex][6];
					initImage_contres(loadarea);
					current_imgid_contres=img_id;
					myloadedimage_contres[imgindex]=1;
				}
			}
		return false
	}
	if(myloadedimage_contres[imgindex]==null){	
		new Asset.image(imggallery_contres[imgindex][0], {onload: loadimagenow});
		
	}else{
		loadimagenow();
	}
	
}

function returnimgcode_contres(theimg){
	var imghtml=""
	if (theimg[1]!="")
		imghtml=''
	imghtml+='<a href="'+theimg[7]+'" target="_self"><img src="'+theimg[0]+'" border="0" id="'+theimg[8]+'" /></a>'
	if (theimg[1]!="")
		imghtml+=''
	return imghtml
}


function initImage_contres(imageId) {
	
	var fader = new Fx.Style(imageId,'opacity', {duration:fadespeed});
	fader.set(0);
	fader.start(0,1);
	
	var titlefade = new Fx.Style('desc_contres','opacity', {duration:transspeed });
		titlefade.set(0);
		titlefade.start(0,1);
}

function addposition_contres(addwidth){
	if ( !moving_contres ) {
		 // if animagic is still moving_contres the image..don't update the current position till it's done
		if(addwidth=="minus"){
			currentpos_contres-=1;
		}else if(addwidth=="plus"){
			currentpos_contres+=1;
		}
	}
	return currentpos_contres;
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

	
function timedMsg_contres()
{
	if (window.t_bool_contres) {
		if (tempgallery_contres.length > 1) {
			if (current_imgid_contres + 1 >= tempgallery_contres.length ) {
				current_imgid_contres = 1;
				previmageConTres(current_imgid_contres);
			} 
			else nextimageConTres(current_imgid_contres);
		}
	}
}

function cleartimedMsg_contres(reload_trans) {
	window.t_bool_contres = false;
	var x = window.setTimeout("reloadtimedMsg_contres();", reload_trans);
}

function reloadtimedMsg_contres() {
	window.t_bool_contres = true;
}

