function init()
{
	checksize();
}

function checksize()
{
	viewportheight = 500;
	if(typeof(window.innerHeight) != "undefined") viewportheight = window.innerHeight;
	else viewportheight = document.documentElement.clientHeight;
	rows = Math.floor((viewportheight - 120) / 202);
	if(rows < 1) rows = 1;
	dojo.byId('carousel').style.height = (rows * 202) + 'px';
	dojo.byId('carouselwrapper').style.marginTop = ((viewportheight - (rows * 202)) / 2) + 'px'
	xajax_modelle(xajax.getFormValues('modellfilter'),rows);
}

function modell(object_id,url)
{
	detail[object_id] = window.open("http://" + window.location.hostname + basepath + url, "Detail" + object_id, "statusbar=no,menubar=yes,width=805,height=600,dependent=yes,location=yes,scrollbars=no,resizable=yes");
	detail[object_id].moveTo((screen.width/2) - (805/2),(screen.height/2) - (600/2));
	detail[object_id].focus();
}

function picture(object_id,object_count)
{
	if(document.getElementById("picturelarge")) document.getElementById("picturelarge").src = filesbasepath + 'bild.php?name=' + object_id + '-' + object_count + '.jpg&size=600';
}

function preload(object_id)
{
	if(document.getElementById("preload")) document.getElementById("preload").innerHTML = '<img src="' + filesbasepath + 'bild.php?name=' + object_id + '-2.jpg&size=600" />\
	<img src="' + filesbasepath + 'bild.php?name=' + object_id + '-3.jpg&size=600" />';
}

function showpopup(object_id)
{
	if(document.getElementById(object_id))
	{
		elem1 = document.getElementById(object_id);
		elem2 = document.getElementById(object_id + 'container');
		elem3 = document.getElementById('overlay');
		
		elem1.style.left = '50%';
		elem1.style.top = '50%';
		elem1.style.marginLeft = (Math.round(elem2.offsetWidth / 2) * -1) + 'px';
		elem1.style.marginTop = ((Math.round(elem2.offsetHeight / 2) * -1) -20) + 'px';
		elem1.style.visibility = 'visible';
		elem1.style.zIndex = 4;

		elem3.style.left = 0;
		elem3.style.top = 0;
		elem3.style.width = '100%';
		elem3.style.height = '100%';
		elem3.style.visibility = 'visible';
		elem3.style.zIndex = 3;
		
		img = null;
	}
}
function closepopup(object_id)
{
	if(document.getElementById(object_id))
	{
		elem1 = document.getElementById(object_id);
		elem3 = document.getElementById('overlay');

		elem1.style.visibility = 'hidden';
		elem1.style.zIndex = -1;
		elem1.style.left = '-10000px';
		elem3.style.visibility = 'hidden';
		elem3.style.zIndex = -1;
		elem3.style.left = '-10000px';
	}
}


//sliding to the right  
function slideRight() 
{  
	var carousel = dojo.byId('carousel');  
	newLeft = carousel.scrollLeft;  
	newLeft = newLeft + 270;  
	var animation = dojox.fx.smoothScroll({
		win: carousel,
		target: {x: newLeft, y: 0},
		duration: 500
	}).play();
	
}  
  
//sliding to the left  
function slideLeft() 
{  
	var carousel = dojo.byId('carousel');  
	newLeft = carousel.scrollLeft;  
	newLeft = newLeft - 270;  
	var animation = dojox.fx.smoothScroll({
		win: carousel,
		target: {x: newLeft, y: 0},
		duration: 500
	}).play();
}  

var rows = 2;
var detail = new Object();
var newLeft = 0;  

window.onbeforeunload = function(){
	for(var attribut in detail) detail[attribut].close();
}

window.onresize = function() {
	checksize();
}

window.onload = function() {
	if(detailansicht == 0) init();
	else 
	{
		self.focus();
		preload(detailansicht);
	}
}

if(typeof(dojo) != "undefined")
{
	dojo.require('dojox.fx.scroll');
	  
	//attach events on load  
	dojo.addOnLoad(function() {  
		   var prev = dojo.byId('carouselprev');  
		   var next = dojo.byId('carouselnext');  
		   dojo.connect(prev,"onclick",null,"slideLeft");  
		   dojo.connect(next,"onclick",null,"slideRight");
	});  
}

