$(document).ready(function() {
	var diastripe = $("#imageSpanner");
	var width = diastripe.width();
	var scroll = true;
	var animOverlay = true;
	var imgWidth = 450;

	$("#conRight").mouseover(function() {
		$("#picOverlay").animate( { top: "335px" } , 300);
	} );
	$("#conRight").mouseout(function() {
		$("#picOverlay").animate( { top: "370px" } , 300);
	} );

	$(".picControlLft a").click(function() {
		if(scroll) {
			scroll = false;
			var xpos = diastripe.css("left");
			xpos = xpos.replace(/px/g, "");
			xpos = parseFloat(xpos) + imgWidth;
			if(xpos == 0)
				$(".picControlLft").addClass("hidden");
			if(xpos > (width - imgWidth) * -1)
				$(".picControlRght").removeClass("hidden");
			diastripe.animate( { left: xpos+"px" } , 500, function() { scroll = true; } );
			var imgNr = xpos * (-1) / imgWidth;
			var newText = $("#imageSpanner img:eq("+imgNr+")").attr("alt");
			$("#picOverlay p").text(newText);
		}
	} );
	$(".picControlRght a").click(function() {
		if(scroll) {
			scroll = false;
			var xpos = diastripe.css("left");
			if(xpos == "auto")
				xpos = "0px";
			xpos = xpos.replace(/px/g, "") - imgWidth;
			if(xpos <= -imgWidth)
				$(".picControlLft").removeClass("hidden");
			if(xpos <= (width - imgWidth) * -1)
				$(".picControlRght").addClass("hidden");
			diastripe.animate( { left: xpos+"px" } , 500, function() { scroll = true; } );
			var imgNr = xpos * (-1) / imgWidth;
			var newText = $("#imageSpanner img:eq("+imgNr+")").attr("alt");
			$("#picOverlay p").text(newText);
		}
	});
});

function startDiashow_old(milsec)
{
	if(milsec)
		setInterval("scrollRight()",milsec*1000);
	else
		setInterval("scrollRight()",5000);
}

// modified by mediahof, requires jQuery.cycle();
function startDiashow(milsec) {
    $("#imageSpanner").cycle({timeout: milsec*1000, after: function() {$("#picOverlay p").text((($(this).children('img').length)?$(this).children('img').attr('alt'):$(this).attr('alt')));}});
}
function scrollRight()
{
	var diastripe = $("#imageSpanner");
	var width = diastripe.width();
	var scroll = true;
	var animOverlay = true;
	var imgWidth = 450;
	
	if(scroll) {
		scroll = false;
		var xpos = diastripe.css("left");
		if(xpos == "auto")
			xpos = "0px";
		xpos = xpos.replace(/px/g, "") - imgWidth;
		
		if(xpos < (width - imgWidth) * -1)
			xpos = 0;

		diastripe.animate( { left: xpos+"px" } , 500, function() { scroll = true; } );
		var imgNr = xpos * (-1) / imgWidth;
		var newText = $("#imageSpanner img:eq("+imgNr+")").attr("alt");
		$("#picOverlay p").text(newText);
	}
}

$(function() {
	if(lang == "en")
	{
		txtImg = "Image";
		txto	= "of";
	}
	else
	{
		txtImg = "Bild";
		txto	= "von";
	}
	var settings = jQuery.extend({
		overlayBgColor: 		'#000',
		overlayOpacity:		0.85,
		fixedNavigation:		false,
		imageLoading:			'/cms/templates/conelly_design/images/loader.gif',
		imageBtnPrev:			'/cms/templates/conelly_design/images/lightbox-btn-prev-'+lang+'.gif',
		imageBtnNext:			'/cms/templates/conelly_design/images/lightbox-btn-next-'+lang+'.gif',
		imageBtnClose:		'/cms/templates/conelly_design/images/lightbox-btn-close-'+lang+'.gif',
		imageBlank:			'/cms/templates/conelly_design/images/lightbox-blank.gif',
		containerBorderSize:		10,
		containerResizeSpeed:	400,
		txtImage:			txtImg,
		txtOf:				txto,
		keyToClose:			'c',
		keyToPrev:			'p',
		keyToNext:			'n',
		imageArray:			[],
		activeImage:			0
	},settings);

	$("#imageHolder a").lightBox(settings);
	$("#imageSpanner a").lightBox(settings);
});
