// JavaScript Document
var trig = 1;// trigger for div with image
var img_href;// href for new image

$(document).ready(function(){

						   $('div#img2').animate({'opacity':'0'},2);
						   $('div#preloader').animate({'opacity':'0'},2);
						 
						 
						 function anim1(){
						   
							   $('div#img1').animate({'top':'0px', 'left':'0px', 'opacity':'0'}, 1100);
							   $('div#img2').animate({'top':'0px', 'left':'0px', 'opacity':'1'}, 1100); trig = 2;
							   }
						   function anim2(){
						 
							   $('div#img2').animate({'top':'0px', 'left':'0px', 'opacity':'0'},1100);
							   $('div#img1').animate({'top':'0px', 'left':'0px', 'opacity':'1'}, 1100); trig = 1;
							
							}
						
						
						
						   $('a.aimg').click(function(){
															  $('a.aimg').attr('id','');
															  $(this).attr('id', 'select');
															  img_href = $(this).attr('href');
															  $('div#preloader').animate({'opacity':'0.8'},500); 
															  if(trig == 1){
															  $('#image2').attr('src',img_href);
															  $('#image2').parent().attr('href',img_href);
															  $.elementReady('image1',  function(){  $('div#preloader').animate({'opacity':'0'},500);anim1(); });
																	

																 }
																 else{
																	 $('#image1').attr('src',img_href);
																	 $('#image1').parent().attr('href',img_href);
																	 $.elementReady('image2',  function(){ $('div#preloader').animate({'opacity':'0'},500);anim2(); }); 
																	 }
															  return false;
															  
															  });
						   
						   
						   /******************************/
						   
$('#img1 a').html('<img id="image1" src="'+$('.items > div > a:first').attr('href')+'"  alt="" />');
$('#img2 a').html('<img id="image2" src="'+$('.items > div > a:first').next().attr('href')+'"  alt="" />');					   
						   
						   });
