
function checkPopup(params, redi)
{
	if(window.opener == null)
	{
		$('#popup').hide();
		
	    $("#dialog").dialog({
	    	bgiframe: true,
	    	autoOpen: false,
	    	height: 300,
	    	modal: true,
	    	buttons: {
	    		OK: function()
	    		{
					reArrangeWindows(params, redi);
	    		  	$(this).dialog('close');
	    		},
	    		Abbrechen: function()
	    		{
	    			location.href = redi;
	    			//$(this).dialog('close');
	    		}
	    	}
	    });
		$('#dialog').dialog('open');		
		
	}
}

function reArrangeWindows(params, redi)
{
	var uri = location.href;
	var s = /[A-Za-z]+\:\/\/[A-Za-z\.]+\/[wW]+\//;
	var r = '';
	uri = uri.replace(s, r);
	
	if(params != '')
	{
		if(window.open(location.href, 'popup', params))
		{
			location.href = redi;
		}
	}	
}

// wird ab swfobject 2 nicht mehr verwendet, 09/05/07 jviebrock
function writeFlash(flashName, target, version, filePath, wmode, vars)
{
	var so = new SWFObject(filePath, flashName, "100%", "100%", version);
	if(wmode != "") so.addParam("wmode", wmode);
	
	if(vars != "")
	{
		arr = vars.split(";");
	
		for(i=0; i<arr.length;i++)
		{
			str = arr[i].split("=");
			if(str[0] != "")
				so.addVariable(str[0],str[1]);
		}
	}
	
	so.write(target);
}



//wird ab swfobject 2 nicht mehr verwendet, 09/05/07 jviebrock
function writeFlashMediaPlayer(flashName, target, version, wmode, vars, fullscreen, previewPicture, autoplay)
{
	var so = new SWFObject('/default/swf/player.swf', flashName, "100%", "100%", version);
	if(wmode != "") so.addParam("wmode", wmode);
	if(fullscreen == "y") so.addParam("allowfullscreen", true);
	else so.addParam("allowfullscreen", false);
	
	if(autoplay == "y") so.addVariable("autoplay", "true");
	
	if(previewPicture != "") so.addVariable("image", previewPicture);
	
	if(vars != "")
	{
		arr = vars.split(";");
	
		for(i=0; i<arr.length;i++)
		{
			str = arr[i].split("=");
			if(str[0] != "")
				so.addVariable(str[0],str[1]);
		}
	}
	
	so.write(target);
}


function gallery()
{
	$('ul.gallery').galleria({
		history   : true, // activates the history object for bookmarking, back-button etc.
		clickNext : true, // helper for making the image clickable
		insert    : '#main_image', // the containing selector for our main image
		onImage   : function(image,caption,thumb) { // let's add some image effects for demonstration purposes
			
			// fade in the image & caption
			image.css('display','none').fadeIn(1000);
			caption.css('display','none').fadeIn(1000);
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// fade out inactive thumbnail
			_li.siblings().children('img.selected').fadeTo(500,0.3);
			
			// fade in active thumbnail
			thumb.fadeTo('fast',1).addClass('selected');
			
			// add a title for the clickable image
			image.attr('title','Weiter >>');
		},
		onThumb : function(thumb) { // thumbnail effects goes here
			
			// fetch the thumbnail container
			var _li = thumb.parents('li');
			
			// if thumbnail is active, fade all the way.
			var _fadeTo = _li.is('.active') ? '1' : '0.3';
			
			// fade in the thumbnail when finnished loading
			thumb.css({display:'none',opacity:_fadeTo}).fadeIn(1500);
			
			// hover effects
			thumb.hover(
				function() { thumb.fadeTo('fast',1); },
				function() { _li.not('.active').children('img').fadeTo('fast',0.3); } // don't fade out if the parent is active
			)
		}
	});	
}


$(document).ready(function ()
{
	if($('#gallery').length > 0)
		gallery();
	
//	if($('#popeye2').length > 0)
//	{
//		 var options = {  
//			 direction:  'right',  
//		     duration:   230,  
//		     stageW:     '180px',  
//		     stageH:     '150px',
//		     clabel: 'Schließen',
//		     nlabel: 'Weiter',
//		     plabel: 'Zurück',
//		     oflabel: 'von',
//		     blabel: 'Vergrößern',
//		     countpos:   'caption'
//		 };
//		 $('.popeye2').popeye(options);
//	}
});

