/* LAYOVERS */

function showLoading(s, t)
{
	return t;
}
function hideLoading()
{
	// $('LocationTitle').style.background = "url(img/input_background.gif)";
}
function showLocation(t, e)
{
	/*
	var url = 'location/'+e.id;
	self.location.href = url;
	*/
}

/* NEW */

var popupConntent = null;

function popUpOverlay(type)
{
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	var boxTop = arrayPageScroll[1] + (arrayPageSize[3] / 15);

	popupConntent = type;
	
	showOverlay();

	Element.setTop('overlaycontent', boxTop);
	Element.show('overlaycontent');
}

function showOverlay()
{
	var arrayPageSize = getPageSize();
	Element.setHeight('overlay', arrayPageSize[1]);
	new Effect.Appear('overlay', { duration: 0.2, from: 0.0, to: 0.8, afterFinish:showContent});
}

function showContent()
{
	switch(popupConntent) {
		case "imprint":
			showImprint();
			break;
		case "products":
			showProducts();
			break;
	}
}

function hideContent()
{
	var lmnt = document.getElementById('overlaycontent');
	lmnt.style.display = "none";
	lmnt.innerHTML = "";
	new Effect.Fade('overlay', { duration: 0.2, from: 0.8, to: 0 });
}


function getPageScroll()
{
	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}

	arrayPageScroll = new Array('',yScroll) 
	return arrayPageScroll;
}

function getPageSize()
{
	var xScroll, yScroll;

	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}

	var windowWidth, windowHeight;
	if (self.innerHeight) {	// all except Explorer
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	

	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}

Object.extend(Element, {
	getWidth: function(element) {
	   	element = $(element);
	   	return element.offsetWidth; 
	},

	setWidth: function(element,w) {
	   	element = $(element);
    	element.style.width = w +"px";
	},

	setHeight: function(element,h) {
   		element = $(element);
    	element.style.height = h +"px";
	},

	setTop: function(element,t) {
	   	element = $(element);
    	element.style.top = t +"px";
	},

	setSrc: function(element,src) {
    	element = $(element);
    	element.src = src; 
	},

	setHref: function(element,href) {
    	element = $(element);
    	element.href = href; 
	},

	setInnerHTML: function(element,content) {
		element = $(element);
		element.innerHTML = content;
	}
});

function showImprint()
{
	var lmnt = document.getElementById('overlaycontent');
	lmnt.style.display = "block";
	var content = '<div id="imprint">';
	
	content += '<h1><img src="img/logo_white_s.gif" /></h1>';
	content += '<div id="close" onclick="hideContent()"><img src="img/arrow_neu.png" />&nbsp;close</div>';
	content += '<br class="reset" />';
	content += '<div class="spacer"></div>';
	content += '<p>Veröffentlicht und herausgegeben durch:</p>';

	content += '<p>Pictonia GmbH<br />';
	content += 'Borsigstraße 33<br />';
	content += '10115 Berlin<br />';
	content += 'Germany</p>';

	content += '<p>Geschäftsführung:</p>';

	content += '<p>Michael Hecken</p>';

	content += '<p>Kontakt:<br />';
	content += '<a href="mailto:mail@pictonia.com" target="_blank">mail@pictonia.com</a><br />';
	content += 'T: 0180 555 8866<br />';
	content += 'F: 0180 599 7775</p>';

	content += '<p>Design und Umsetzung:';

	content += '<p>Hope & Glory<br />';
	content += 'Borsigstraße 33<br />';
	content += '10115 Berlin<br />';
	content += 'Germany<br />';
	content += '<a href="http://www.hopeglory.com/" target="_blank">www.hopeglory.com</a></p>';

	content += '</div>';

	lmnt.innerHTML = content;
}
function showProducts()
{
	new Ajax.Updater('overlaycontent', 'pages/products', {asynchronous:true});
	$('overlaycontent').style.display = 'block';
}
     

/* Slideshow functions */

var key = 1;    
var numImages = 13;
function preloadImages()
{
	for(var i=1; i<=numImages; i++) {
		var im = new Image();
		im.src = 'img/front_'+ i +'.jpg';
	}
}
function startSlideShow()
{
	preloadImages();
	setInterval('changePicture()', 6000);
}     

function changePicture()
{
	if(key<=numImages-1)
		key++;  
    else
		key = 1;   
	if(key%2 == 0) { 
		$('slideshow2').src = 'img/front_'+ key +'.jpg';   	
		new Effect.Fade('slideshow1',{duration:1,afterFinish:function() {                                    
																	  $('slideshow2').style.zIndex = "3";
																	  $('slideshow1').style.zIndex = "2";
																   		new Effect.Appear('slideshow1');
																   }});
	}    else {      
		 $('slideshow1').src = 'img/front_'+ key +'.jpg';
		 new Effect.Fade('slideshow2',{duration:1,afterFinish:function() {                                    
																		  $('slideshow1').style.zIndex = "3";
																		  $('slideshow2').style.zIndex = "2";
																	   		new Effect.Appear('slideshow2');
																	   }});
	}
}
