// JavaScript Document
// 
// copyright Bogdan Keric, 12 Mar 2009

function zoom_loading() {
	$('zoom').setStyle({opacity: 0});
	$('loading_art').update("Please wait&hellip;");
	
}

function zoom_loadeD() {
	$('loading_art').update("");
	var srt = new Effect.Opacity('zoom', { from: 0, to: 1, duration: 2, transition: Effect.Transitions.sinoidal });
}

function loading() {
	
	$('presentation').setStyle({opacity: 0});
	$('loading_art').update("Please wait&hellip;");
	$('gallery_meni').stopObserving('click');
}
function loadeD() {
	$('loader').setStyle({opacity: 1});
	var fade = new Effect.Opacity('presentation', { from: 0, to: 1, duration: 1, transition: Effect.Transitions.sinoidal });
	$('loading_art').update("");
	$('gallery_meni').observe('click', art);
	//$('enlarge').observe('click', grow);
	//return ;
	zoom();
}
/* function grow() {
	new Effect.Scale('loader_img', 100, {scaleFromCenter: true,  scaleFrom:55, scaleMode: { originalWidth: 450 }});
	$('enlarge').stopObserving('click');
	$('enlarge').update("");
	$('detail').update("");
} */

function art(event) {
	  
	  $('loader').setStyle({opacity: 0, 'display': 'none'});
	  
	  
	  get = $('loader_img').readAttribute('name');
	  tag = Event.element(event);
	  id = tag.readAttribute('id');
  		
		  if ('A' == tag.tagName && 'next' == id) {
			  var get = ++get;
			  if(get>25) {var get = 1};
	  		 };
		  if ('A' == tag.tagName && 'previous' == id) {
			  var get = --get;
			  if(get<1) {var get = 25};
	  		 };
		
		new Ajax.Updater('presentation', 'art_img.php', {
			evalScripts: true,
			method: 'get',
			parameters: { img: get },
			onCreate: loading()
			//onComplete: zoom(get),
			
		});
		//event.preventDefault();
		
}

function zoom() {
	  
	 //$('zoom').setStyle({opacity: 0});
	  //var get = get;
	  
	  getit = $('loader_img').readAttribute('name');
	  //tag = Event.element(event);
	  //id = tag.readAttribute('id');
		
		new Ajax.Updater('zoom', 'zoom_img.php', {
			method: 'get',
			parameters: { img: getit },
			evalScripts: true,
			onCreate: zoom_loading()
			});
		
		//event.preventDefault();
		
}
// JavaScript Document

// Browser Window Size and Position
// copyright Stephen Chapman, 3rd Jan 2005, 8th Dec 2005
// you may copy these functions but please keep the copyright notice as well
function pageWidth() {
	
	return window.innerWidth != null? 
	window.innerWidth : document.documentElement && document.documentElement.clientWidth ?       
	document.documentElement.clientWidth : 
	document.body != null ? document.body.clientWidth : null;} 
	
function pageHeight() {
	
	return  window.innerHeight != null? 
	window.innerHeight : document.documentElement && document.documentElement.clientHeight ?  
	document.documentElement.clientHeight : 
	document.body != null? document.body.clientHeight : null;} 

// Browser Window Size and Position
// copyright Bogdan Keric, 8 Mar 2009
// you may copy these functions but please keep the copyright notice as well

function mover(event) {
  //Remove scrollbars
  // $('wrapper').setStyle({overflow: 'hidden'});
	
	pW = pageWidth();
	pH = pageHeight();
	
	wt0 = (pW-882)/2;
	wt0 = wt0+620;
	ht0 = 147;
	
	wt = $('loader_img').getWidth()+50;
	ht = $('loader_img').getHeight()+25;
	
	w = $('slider').getWidth();
	h = $('slider').getHeight();

	
	new Effect.Move('slider', {
	  x: -(Event.pointerX(event)-wt0)*((w-wt)/wt), y: -(Event.pointerY(event)-ht0)*((h-ht)/ht), 
	  mode: 'absolute',
	  transition: Effect.Transitions.linear
	})
};



function addObservers() {
$('gallery_meni').observe('click', art);
$('loader_img').observe('mousemove', mover);
}

Event.observe(window, 'load', addObservers);

