// JavaScript Document

var currentpos_agenda=0;
var current_imgid_agenda=0;
var moving_agenda = false;
var finishedsizing_agenda=0;
var preloadimg_agenda="no"//Preload images ("yes" or "no"):
var myloadedimage_agenda = new Array();
     myloadedimage_agenda[0]=1;
var imggallery_agenda=new Array()
var firstimagestart_agenda=1;
var nextorprev_agenda=0;
var fadeout_agenda=1;

function areweready_agenda(loadarea, imgindex, img_id){
	if ( finishedsizing_agenda++ ) { 
		modifyimage_agenda(loadarea, imgindex, img_id);
		finishedsizing_agenda = 0;
	}
}

function modifyimage_agenda(loadarea, imgindex, img_id ){
	function loadimagenow(){
		if (document.getElementById) {
			
				if(current_imgid_agenda!=img_id){
					
					var imgobj=document.getElementById(loadarea);
					var photoforg_dia=document.getElementById('forg_dia')
					var photoforg_mon=document.getElementById('forg_mon')
					var photoforg_yea=document.getElementById('forg_yea')
					
					imgobj.innerHTML=returnimgcode_agenda(imggallery_agenda[imgindex]);
					photoforg_dia.innerHTML=tempgallery_agenda[imgindex][4];
					photoforg_mon.innerHTML=tempgallery_agenda[imgindex][5];
					photoforg_yea.innerHTML=tempgallery_agenda[imgindex][6];
					initImage_agenda(loadarea);
					current_imgid_agenda=img_id;
					myloadedimage_agenda[imgindex]=1;
				}
			}
		return false
	}
	if(myloadedimage_agenda[imgindex]==null){	
		new Asset.image(imggallery_agenda[imgindex][0], {onload: loadimagenow});
		
	}else{
		loadimagenow();
	}
	
}

function returnimgcode_agenda(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_agenda(imageId) {
	
	var fader = new Fx.Style(imageId,'opacity', {duration:fadespeed});
	fader.set(0);
	fader.start(0,1);
	
	var forg_diafade = new Fx.Style('forg_dia','opacity', {duration:transspeed });
	forg_diafade.set(0);
	forg_diafade.start(0,1);
	var forg_monfade = new Fx.Style('forg_mon','opacity', {duration:transspeed });
	forg_monfade.set(0);
	forg_monfade.start(0,1);
	var forg_yeafade = new Fx.Style('forg_yea','opacity', {duration:transspeed });
	forg_yeafade.set(0);
	forg_yeafade.start(0,1);
}

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

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

	
function timedMsg_agenda()
{
	if (window.t_bool_agenda) {
		if (tempgallery_agenda.length > 1) {
			if (current_imgid_agenda + 1 >= tempgallery_agenda.length ) {
				current_imgid_agenda = 1;
				previmageAgenda(current_imgid_agenda);
			} 
			else nextimageAgenda(current_imgid_agenda);
		}
	}
}

function cleartimedMsg_agenda(reload_trans) {
	window.t_bool_agenda = false;
	var x = window.setTimeout("reloadtimedMsg_agenda();", reload_trans);
}

function reloadtimedMsg_agenda() {
	window.t_bool_agenda = true;
}

