try {
  document.execCommand("BackgroundImageCache", false, true);
} catch(err) {}

function addDOMLoadEvent(f){if(!window.__ADLE){var n=function(){if(arguments.callee.d)return;arguments.callee.d=true;if(window.__ADLET){clearInterval(window.__ADLET);window.__ADLET=null}for(var i=0;i<window.__ADLE.length;i++){window.__ADLE[i]()}window.__ADLE=null};if(document.addEventListener)document.addEventListener("DOMContentLoaded",n,false);/*@cc_on @*//*@if (@_win32)document.write("<scr"+"ipt id=__ie_onload defer src=//0><\/scr"+"ipt>");var s=document.getElementById("__ie_onload");s.onreadystatechange=function(){if(this.readyState=="complete")n()};/*@end @*/if(/WebKit/i.test(navigator.userAgent)){window.__ADLET=setInterval(function(){if(/loaded|complete/.test(document.readyState)){n()}},10)}window.onload=n;window.__ADLE=[]}window.__ADLE.push(f)}


function scroll_it (){
	var scroller = document.getElementById('scroller');
	if(!scroller) {return false;}
	info_scroll = new ScrollObj(6,29,130,"track","up","down","drag","masca","continut");

    }; 
	
 Fx.Properties = Fx.Styles.extend({	
			increase: function(){for (	var p in this.now) this.element[p] = this.now[p];	}	
		});

		Fx.FlyingScroller = Fx.Properties.extend({
			initialize: function(el, options){
				this.parent(el, options);
				this.options = Object.extend(this.options || {}, Object.extend({
					paddingLeft: 0,
					paddingTop: 0
				}, options || {}));
			},
			toElement: function(el, paddingLeft, paddingTop){
				this.goTo(el.offsetLeft - (paddingLeft || this.options.paddingLeft || 0), el.offsetTop - (paddingTop || this.options.paddingTop || 0));
			},
			goTo: function(x, y){
				this.start({
					'scrollLeft': [this.element.scrollLeft, x],
					'scrollTop': [this.element.scrollTop, y-180]
				})
			}
		});
		

function disable_text_select() {
	document.onselectstart = function() {return false;}
	
	}
function highlight_poze ()
{
 var poze = document.getElementById('poze');
 if(!poze) {return false;}
 var poze_span = poze.getElementsByTagName('span');
 var poze_span = poze_span[0];
 poze_span.setAttribute('id','poze_span');
 poze.onmouseover = function () {poze_span.style.visibility = 'visible'; $('poze_span').setStyle('opacity',1);}
 poze.onmouseout = function () {poze_span.style.visibility = 'hidden'; $('poze_span').setStyle('opacity',0);}
 $('poze_span').setStyle('opacity',1);
 $('poze_span').effect('opacity', {duration: 500, transition:Fx.Transitions.quadInOut, onComplete: function () {$('poze_span').effect('opacity', {duration: 500, transition:Fx.Transitions.quadInOut}).start(1,0);}}).start(0,1);
 
 
}
	
function galerie() {
	/*
	if(window.webkit) {
   $('nav_container').style.backgroundColor = '#34190B';
	$('thumb_nav').style.backgroundColor = '#34190B';
	
	}
	*/
	var thumb_wrapper = document.getElementById('thumb_wrapper');
	if(!thumb_wrapper) {return false;}
	var nav_wrapper = document.getElementById('nav_wrapper');
	var thumb_nav = document.getElementById('thumb_nav');
	
	var placeholder = document.getElementById('placeholder');

	var inchide_nav = document.getElementById('inchide_nav');
	var poze = document.getElementById('poze');
	var thumb_wrapper_lks = thumb_wrapper.getElementsByTagName('a');
	var selectat =  document.getElementById('selectat');
	var thumb_up =  document.getElementById('thumb_up');
	var thumb_down = document.getElementById('thumb_down');
	var bk = document.getElementById('bk');
	var fw = document.getElementById('fw');
	var nav_pag = document.getElementById('nav_pag').getElementsByTagName('dd')[0];
	var current_foto = 0;
	placeholder.setAttribute('src',thumb_wrapper_lks[0].getAttribute('href'));
	var total_poze;
	if(thumb_wrapper_lks.length<10) {total_poze = '0' + thumb_wrapper_lks.length} else {total_poze = thumb_wrapper_lks.length }
	nav_pag.innerHTML = '01'+'/'+total_poze;
	if(thumb_wrapper_lks.length>1) {thumb_down.style.visibility = 'visible'; fw.style.visibility = 'visible';}
	var gutter = document.getElementById('gutter');
	gutter.style.top = thumb_wrapper_lks.length*60 + 180 + 'px';
	
   for(z=0; z<thumb_wrapper_lks.length; z++)
   {
	 thumb_wrapper_lks[z].style.top = 180 + 60*z + 'px';  
	}
   
   var main_nav = new Fx.FlyingScroller($('thumb_wrapper'), {
		transition: Fx.Transitions.quadInOut,
		duration: 500,
		paddingLeft: 0,
		paddingTop: 0
	
	});
  main_nav.clearTimer().goTo(0,180);   
	 
	
	for(i=0; i<thumb_wrapper_lks.length; i++)
	 {
	   
	  thumb_wrapper_lks[i].onclick = function ()
	  { 
	  
		selectat =  document.getElementById('selectat');
	    selectat.removeAttribute('id');
		
		placeholder.setAttribute('src',this.getAttribute('href'));
		this.setAttribute('id','selectat');
		for(x=0; x<thumb_wrapper_lks.length; x++)
		{
		  if(thumb_wrapper_lks[x].getAttribute('id')=='selectat')
		  {
			  current_foto = x;
			  nav_pag.innerHTML = current_foto+1+'/'+thumb_wrapper_lks.length;
			  if(current_foto<9) {nav_pag.innerHTML = '0'+(current_foto+1)+'/'+total_poze;}
			  if(current_foto>0) {thumb_up.style.visibility = 'visible'; bk.style.visibility = 'visible';  }
			  else {thumb_up.style.visibility = 'hidden'; bk.style.visibility = 'hidden';}
			  if(current_foto==thumb_wrapper_lks.length-1) {thumb_down.style.visibility = 'hidden'; fw.style.visibility = 'hidden';}
			  else {thumb_down.style.visibility = 'visible'; fw.style.visibility = 'visible';}
			 
			  
		  }
		}
		 main_nav.clearTimer().toElement($('selectat'));
		return false;
		
	   }
	 }
	 
	 thumb_down.onclick = function ()
	 {   
	   
	    if(current_foto==thumb_wrapper_lks.length-2) {
		  this.style.visibility = 'hidden';
		  fw.style.visibility = 'hidden';
		 }
		 thumb_up.style.visibility = 'visible';
		 bk.style.visibility = 'visible';
		 current_foto++;
		 
		 selectat =  document.getElementById('selectat');
	     selectat.removeAttribute('id');
		thumb_wrapper_lks[current_foto].setAttribute('id','selectat');
		 
		 placeholder.setAttribute('src',thumb_wrapper_lks[current_foto].getAttribute('href'));
		 nav_pag.innerHTML = current_foto+1+'/'+thumb_wrapper_lks.length;
		 if(current_foto<9) {nav_pag.innerHTML = '0'+(current_foto+1)+'/'+total_poze;}
		  main_nav.clearTimer().toElement($('selectat')); 
		 return false;
	  }
	
	fw.onclick = function ()
	 {   if(current_foto==thumb_wrapper_lks.length-2) {
		  this.style.visibility = 'hidden';
		  thumb_down.style.visibility = 'hidden';
		 }
		 thumb_up.style.visibility = 'visible';
		 bk.style.visibility = 'visible';
		 current_foto++;
		 
		 selectat =  document.getElementById('selectat');
	     selectat.removeAttribute('id');
		thumb_wrapper_lks[current_foto].setAttribute('id','selectat');
		
		 placeholder.setAttribute('src',thumb_wrapper_lks[current_foto].getAttribute('href'));
		 nav_pag.innerHTML = current_foto+1+'/'+thumb_wrapper_lks.length;
		 if(current_foto<9) {nav_pag.innerHTML = '0'+(current_foto+1)+'/'+total_poze;}
		  main_nav.clearTimer().toElement($('selectat'));
		 return false;
	  }
	  
	  
	 thumb_up.onclick = function ()
	 {  if(current_foto==1) {
		 this.style.visibility = 'hidden';
		 bk.style.visibility = 'hidden';
		 }
		 thumb_down.style.visibility = 'visible';
		 fw.style.visibility = 'visible';
		current_foto--;
		 selectat =  document.getElementById('selectat');
	     selectat.removeAttribute('id');
		thumb_wrapper_lks[current_foto].setAttribute('id','selectat');
		 
		 placeholder.setAttribute('src',thumb_wrapper_lks[current_foto].getAttribute('href'));
		 nav_pag.innerHTML = current_foto+1+'/'+thumb_wrapper_lks.length;
		 if(current_foto<9) {nav_pag.innerHTML = '0'+(current_foto+1)+'/'+total_poze;}
		  main_nav.clearTimer().toElement($('selectat'));
		 return false;
		
	  }
	  
	bk.onclick = function ()
	 {  if(current_foto==1) {
		 this.style.visibility = 'hidden';
		 thumb_up.style.visibility = 'hidden';
		 }
		 thumb_down.style.visibility = 'visible';
		 fw.style.visibility = 'visible';
		current_foto--;
		 selectat =  document.getElementById('selectat');
	     selectat.removeAttribute('id');
		thumb_wrapper_lks[current_foto].setAttribute('id','selectat');
		 
		 placeholder.setAttribute('src',thumb_wrapper_lks[current_foto].getAttribute('href'));
		 nav_pag.innerHTML = current_foto+1+'/'+thumb_wrapper_lks.length;
		 if(current_foto<9) {nav_pag.innerHTML = '0'+(current_foto+1)+'/'+total_poze;}
		  main_nav.clearTimer().toElement($('selectat'));
		 return false;
		
	  }
	  
	 poze.onclick = function ()
	 {  $('fotos').style.display = 'block';
	    $('nav_wrapper').effect('left', {duration: 1000, transition:Fx.Transitions.quadInOut}).start(559,610);
	  $('thumb_nav').effect('left', {duration: 1000, transition:Fx.Transitions.quadInOut}).start(70,0);
	   $('content').style.zIndex = 201;
		
		return false; 
	  } 
	  
	 inchide_nav.onclick = function ()
	 {  $('fotos').style.display = 'none';
	    nav_wrapper.style.left = 559 + 'px';
		thumb_nav.style.left = 70 + 'px';
	    $('content').style.zIndex = 100;
		
		return false; 
	  }
	 
	}

addDOMLoadEvent(disable_text_select);
addDOMLoadEvent(highlight_poze);
addDOMLoadEvent(scroll_it);
addDOMLoadEvent(galerie);
