//Functions for twist-f.de
//  contact nick@twist-f.de

var previewSlices = new Array();
var imageShown = false;
function show_preview_slice(series)
{ 
	var helparray = new Array();
	for (var i=0; i = previewSlices.length;i++) 
	    {
	    helpebene=previewSlices.pop();
	    if (helpebene !='test'+series && document.getElementById(helpebene) != null) Effect.Fade(helpebene);
	    helparray.push(helpebene);
	    } 
	previewSlices=helparray;
	if(document.getElementById('test'+series) == null) 
	{
			create_content('test'+series,450,50,'relative','');
			new Ajax.Updater('test'+series,'photo.php?do=8&id='+series, {asynchronous:true});
			previewSlices.push('test'+series);
	}else
	{
			new Effect.Appear('test'+series);
	}
}

//--------------------------------------------------------------------

function show_image(series,bildname,bildnummer,bildid,callLocation)
{
window.scrollTo(0,0);	
if (document.getElementById('pic_detail') == null) 
{
	create_content('pic_detail',dimension[0],0,'absolute','');
  
  document.getElementById('pic_detail').style.backgroundColor='#000000';
	document.getElementById('pic_detail').style.width=dimension[0];
	document.getElementById('pic_detail').style.height=dimension[1];
	create_content('picture',dimension[0],(dimension[1]/2)-220,'absolute','');
  create_content('prev',Math.ceil((dimension[0]*0.125)-75),dimension[1]+75,'absolute','');
  create_content('next',Math.ceil((dimension[0]*0.875)-75),dimension[1]+75,'absolute','');
  
  //create_content('description',(dimension[0]/2)-256,dimension[1]/2+38,'absolute','');
  
 /* element = Builder.node('div',{id: 'description' ,style:'position:absolute;top:'+(dimension[1]/2+38)+'px;left:'+((dimension[0]/2)-256)+'px;font-size:8pt;font-weight:bold;width:492px;vertical-align:top;padding:4px;height:100px;z-index:5;'});
	Ebenen.push(element);
	document.getElementById('yeahbaby').appendChild(element);
  element = Builder.node('div',{id: 'descBackground' ,style:'position:absolute;top:'+(dimension[1]/2+38)+'px;left:'+((dimension[0]/2)-256)+'px;font-size:8pt;font-weight:bold;background-image:url(\'bilder/bk.gif\');background-repeat:repeat-x;background-position:bottom;width:492px;vertical-align:top;padding:4px;height:100px;z-index:4;'});
 	Ebenen.push(element);
	document.getElementById('yeahbaby').appendChild(element);
  Element.setOpacity('descBackground',0.5);
 */ 
  
}
  dimension=getDimension();
  
  
  if(!imageShown)
    {
    	new Effect.Move('pic_detail',{x:(0),y:(0),duration: 0.7,mode:'absolute'});
  //Element.hide('descBackground');
  //Element.hide('description');
document.getElementsByTagName('body')[0].style.overflow='hidden';
  Element.hide('pic_detail');
  Element.setOpacity('pic_detail',0.0);
  Element.show('pic_detail');
  Element.show('prev');
   Element.show('next');
  Element.show('picture');
  new Effect.Appear("prev");
  new Effect.Appear("next");
 
    new Effect.Opacity('pic_detail',
    { duration: 0.3, 
      transition: Effect.Transitions.linear, 
      from: 0.0, to: 0.75 });
 
  new Effect.Move('prev',{x:(0),y:(-200),mode:'relative',queue:'parallel'});
  new Effect.Move('next',{x:(0),y:(-200),mode:'relative',queue:'parallel'});           
   }
  
  new Ajax.Updater('prev','photo.php?do=9&id='+bildid, {asynchronous:true,onComplete:function(){Element.setOpacity('prevImage',0.65);}});
  new Ajax.Updater('next','photo.php?do=10&id='+bildid, {asynchronous:true,onComplete:function(){Element.setOpacity('nextImage',0.65);}});    
	new Ajax.Updater('picture','photo.php?do=4&callLocation='+callLocation+'&id='+bildid, {asynchronous:true,onComplete:function(){
		Element.hide('descBackground')
		Element.hide('description')
		
		//hideDescription();
		new Effect.Move('picture',{x:((dimension[0]/2)-(getValueFromStyle(document.getElementById('shownpicture').style.width)/2)),y:((dimension[1]/2)-(getValueFromStyle(document.getElementById('shownpicture').style.height)/2)-20),mode:'absolute',queue:'parallel'});
	
		}});


	

	//new Effect.Move('picture',{x:((dimension[0]/2)-),y:(dimension[1]/2-270),mode:'absolute',queue:'parallel'});
	
	imageShown=true;
}


//--------------------------------------------------------------------
function getValueFromStyle(value)
{
	help=value.substring(0,(value.length-2));
	return parseInt(help);
}
function hideDescription()
{
 new Effect.Fade('descBackground');	
 new Effect.Fade('description');	
}
function showDescription()
{
 Element.hide('descBackground');
 Element.hide('description');
 Element.setOpacity('descBackground',0.0);
 Element.setOpacity('description',0.0);
 Element.show('descBackground');
 Element.show('description');
 new Effect.Opacity('descBackground',
    { duration: 0.3, 
      transition: Effect.Transitions.linear, 
      from: 0.0, to: 0.75 });
 new Effect.Opacity('description',
    { duration: 0.3, 
      transition: Effect.Transitions.linear, 
      from: 0.0, to: 0.75 });
}

function hideDetail(callLocation) 
{
 new Effect.Move('prev',{x:(0),y:(200),mode:'relative',queue:'parallel'});
 new Effect.Move('next',{x:(0),y:(200),mode:'relative',queue:'parallel'});           

new Effect.Move('picture',{x:(dimension[0]),y:(dimension[1]/2-270),queue:'parallel',mode:'absolute'});
new Effect.Move('pic_detail',{x:(dimension[0]),y:(0),mode:'absolute'});
 new Effect.Opacity('pic_detail',
    { duration: 0.9, 
      transition: Effect.Transitions.linear, 
      from: 0.75, to: 0.0, afterFinishInternal:function(){Element.hide('pic_detail');
Element.hide('prev');
Element.hide('next');
Element.hide('picture');
hideDescription();
} });
if (callLocation=='news') window.setTimeout("document.getElementsByTagName('body')[0].style.overflow='auto'",1000);
imageShown=false;


}

//--------------------------------------------------------------------

function show_images()
{
element = Builder.node('div',{id: 'photos' ,style:'position:absolute;top:50px;left:230px;'});
//create_content('photos',230,50,'absolute','');
document.getElementById('yeahbaby').appendChild(element);
Ebenen.push(element);
Element.hide('photos');
new Ajax.Updater('photos', 'photo.php?do=', {asynchronous:true,onComplete: function()
	{
	document.getElementById("scrolldown").addEventListener("mousemove", scrollGalleryDown, false);
	  document.getElementById("scrollup").addEventListener("mousemove", scrollGalleryUp, false);
 
   
	}});
  new Effect.Appear('photos',{queue:'end'});
//document.getElementById('photos').
}

//--------------------------------------------------------------------


function show_gallery(no,page)
{
flush_layers();	
create_content('gallery',250,50,'absolute','');
new Ajax.Updater('gallery', 'photo.php?do=3&id='+no+'&seite='+page, {asynchronous:true});
Element.hide('gallery');
new Effect.Appear('gallery',{queue:'end'});
}