var disableKeys=0;

function getkey(e)

{

if (window.event)

   return window.event.keyCode;

else if (e)

   return e.which;

else

   return null;

}


function goReturn(e) {

if (disableKeys==0){
	
	var getEvent = (e.which) ? e.which : event.keyCode
	
	/*
	if (!e) var e = window.event;
	if (e.keyCode) getEvent = e.keyCode;
	else if (e.which) getEvent = e.which;
	*/

     //alert(getEvent);
     
	//lefts
	 if ((getEvent == "37")) {
	 	MoveGalleryNext(-1);
	    return false;
	 }
	
	//right
	 else if ((getEvent == "39")) {
	 	MoveGalleryNext(1);
	 	return false;
	 }
    
    else {
    return true;
    }
	
	}//disable
	
}


var gCurrentGalleryPos=1;
var alertTimerId;

function CoreMove(startPosLeft,startPosTop,endPosLeft,endPosTop,startPosLeftMove,endPosLeftMove){

	ZoomUp(stationaryDiv,0,853,568,startPosLeft,startPosTop,853,568,endPosLeft,endPosTop,0,100,301,stationaryDiv,'','');
	ZoomUp(movingDiv,0,853,568,(startPosLeftMove),startPosTop,853,568,(endPosLeftMove),endPosTop,0,100,301,movingDiv,'','');

	clearTimeout ( alertTimerId );
}

function MoveGalleryNext(inc){
//	alert('next show');

	numberExhibitions=gNumberExhibitions;
	
	chkGalleryPos=gCurrentGalleryPos+inc;
	//alert(chkGalleryPos);
	if ((chkGalleryPos>=1) && (chkGalleryPos<=numberExhibitions))
	{
	 	gCurrentGalleryPos=gCurrentGalleryPos+inc;
	 
	 	incFact=1;
	 	if (inc<0){incFact=-1;}
	 	  	
		var startPosLeft=0;
	 	var startPosTop=0;
	  	var endPosLeft=-1*inc*853;
	 	var endPosTop=0;
	 	
	 	var startPosLeftMove=startPosLeft+inc*853;
	 	var endPosLeftMove=endPosLeft+inc*853;

  		if (gCurrentGalleryPos<1){gCurrentGalleryPos=numberExhibitions;}
  		if (gCurrentGalleryPos>numberExhibitions){gCurrentGalleryPos=1;}
	 	
	 	  		
  		movePic=gCurrentGalleryPos;
  		currentVisPic=movePic-inc;
  		
  		if (currentVisPic<1){currentVisPic=numberExhibitions;}
  		if (currentVisPic>numberExhibitions){currentVisPic=1;}
  		
  		stationaryDiv = "next_content_pane_current";
  		movingDiv = "next_content_pane_next";
/*Divs are otherway round if we move backwards*/
  		if (((gCurrentGalleryPos-inc)%2)==0){
		  		stationaryDiv = "next_content_pane_next";
		  		movingDiv = "next_content_pane_current";  		  		
  			}


/*If increasing then position to right for increasing move */
  		if (inc>0)
  			{xDOM(movingDiv,1).left="853";}
  		else
  			{xDOM(movingDiv,1).left="-853";}			

		//alert(movePic);
/*Load image into div that is off screen*/
  		//xDOM(movingDiv,0).innerHTML='<img  src="backgrounds/LF_Prints_080303_0'+movePic+'_smaller.jpg" alt="Lullin and Ferrari gallery" width="853" height="480" />';
 		xDOM(movingDiv,0).innerHTML='<img  src="'+Pic[movePic]+'" alt="Lullin and Ferrari gallerye"  />';
 		
 		/* width="853" height="480" */
  			

		Objfader(xDOM(movingDiv,0),100);	
		Objfader(xDOM(stationaryDiv,0),100);	
	
 	
	 	/*Delay to allow img load*/
	 	alertTimerId = setTimeout("CoreMove("+startPosLeft+","+startPosTop+","+endPosLeft+","+endPosTop+","+startPosLeftMove+","+endPosLeftMove+")",10);
	 	
	 	
	
	}//>=0

	GalleryButtonStatusCheck();

}


/* Core Inline stuff */


function MM_preloadImages() { //v3.0

  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

MM_preloadImages('assets/Lullin+Ferrari_logo.gif');


for (loopV=1; loopV<Pic.length; loopV=loopV+1){
		MM_preloadImages(Pic[loopV]);
  	}
  	


var gNumberExhibitions=Pic.length-1; /*starts at zero*/


function ClickIntro(){

//FadeOutIntroBits(65,0);

FadeDownObj('tint_overlay',45,0);
FadeDownObj('intro_text',50,0);

GalleryButtonStatusCheck();
//FadeUpObj('prev_button',0,100);
//FadeUpObj('next_button',0,100);


//setObjVis('current_exhibition_footer','visible');
setObjVis('menu_exhibitions','visible');
setObjVis('menu_artists','visible');


}

function GoHome(){

xDOM('menu_exhibitions_tab',0).className='menu_tab';
xDOM('menu_artists_tab',0).className='menu_tab';

/*
if (gCurrentGalleryPos!=0){FadeDownObj('prev_button',50,0);}
if (gCurrentGalleryPos!=<?=$numberExhibitions;?>-1){FadeDownObj('next_button',50,0);}
*/
gCurrentGalleryPos=1;
	FadeDownObj('prev_button',20,0);
	FadeDownObj('next_button',20,0);
 	xDOM("prev_button",1).visibility='hidden';
 	xDOM("next_button",1).visibility='hidden';




FadeDownObj('next_content_pane_current',50,0);
FadeDownObj('next_content_pane_next',50,0);

setObjVis('content_artists','hidden');
setObjVis('content_exhibitions','hidden');
setObjVis('content_pane_background','hidden');

setObjVis('main_picture','visible');
FadeUpObj('tint_overlay',0,45);
FadeUpObj('intro_text',0,100);

//setObjVis('current_exhibition_footer','hidden');
setObjVis('menu_exhibitions','visible');
setObjVis('menu_artists','visible');

}

function GoArtists(){

xDOM('menu_exhibitions_tab',0).className='menu_tab';
xDOM('menu_artists_tab',0).className='hit_menu_tab';

/*
if (gCurrentGalleryPos!=0){FadeDownObj('prev_button',50,0);}
if (gCurrentGalleryPos!=<?=$numberExhibitions;?>-1){FadeDownObj('next_button',50,0);}
*/
gCurrentGalleryPos=1;

FadeDownObj('prev_button',10,0);
FadeDownObj('next_button',10,0);

FadeDownObj('next_content_pane_current',0,0);
FadeDownObj('next_content_pane_next',0,0);

setObjVis('content_artists','visible');
setObjVis('content_exhibitions','hidden');
setObjVis('content_pane_background','visible');

setObjVis('main_picture','hidden');

setObjVis('tint_overlay','hidden');
setObjVis('intro_text','hidden');

//setObjVis('current_exhibition_footer','visible');


}


function GoExhibitions(){
	
xDOM('menu_exhibitions_tab',0).className='hit_menu_tab';
xDOM('menu_artists_tab',0).className='menu_tab';

/*
if (gCurrentGalleryPos!=0){FadeDownObj('prev_button',50,0);}
if (gCurrentGalleryPos!=<?=$numberExhibitions;?>-1){FadeDownObj('next_button',50,0);}
*/
gCurrentGalleryPos=1;

FadeDownObj('prev_button',10,0);
FadeDownObj('next_button',10,0);

FadeDownObj('next_content_pane_current',0,0);
FadeDownObj('next_content_pane_next',0,0);

setObjVis('content_artists','hidden');
setObjVis('content_exhibitions','visible');
setObjVis('content_pane_background','visible');

setObjVis('main_picture','hidden');

setObjVis('tint_overlay','hidden');
setObjVis('intro_text','hidden');

//setObjVis('current_exhibition_footer','visible');


}


function GalleryButtonStatusCheck(){
	
//alert(gCurrentGalleryPos);
 if (gCurrentGalleryPos<=1){
 	xDOM("prev_button",1).visibility='hidden';
 	}
 else
  	{xDOM("prev_button",1).visibility='visible';
  	FadeUpObj('prev_button',0,100);
  	}

 if (gCurrentGalleryPos>=gNumberExhibitions){
 	xDOM("next_button",1).visibility='hidden';
 	}
 else
  	{xDOM("next_button",1).visibility='visible';
  	  FadeUpObj('next_button',0,100);
  	}

 


}



