$(document).ready(
	function()
	{
		try
		{
			GLOBALS.isIE == true;
		}
		catch (exc)
		{
			GLOBALS.isIE = GLOBALS.isIE6 = GLOBALS.isIE7 = false;
		}

		// fix transparent png's for best pal IE6
		if (GLOBALS.isIE6)
		{
			$.ifixpng(GLOBALS.webBasepath+ '/resources/gfx/dot/alpha.gif');
			$('img.alpha').ifixpng();
		}

		try
		{
			$("#d").datepicker({
				dateFormat: 'dd.mm.yy',
				buttonImage: GLOBALS.webBasepath+ '/resources/gfx/icon/datepicker.gif'
			});
		} catch (exc) {}
		
		// linklist onchange event
		$('.keyvisual select').change(function() {
			window.location.href = $(this).val();
		});
		
		// linklist onchange event
		$('div.dates select').change(function() {
			$(this).parents('form').get(0).submit();
		});

		$(".linkList form[@method='post'] select").change(function() {
			window.location.href = $(this).val();
		});

		$(".linkList form[@method='get'] select").change(function() {
			$(this).parents('form').get(0).submit();
		});

		$("#field-quickSearch-s").bind("focus", function() {
			if ($(this).attr('rel') == undefined || $(this).attr('rel') == '')
			{
				$(this).attr("rel", $(this).val());
				$(this).val('');
			}
			else if ($(this).attr('rel') != '')
			{
				$(this).select();
			}
		});

		$("#field-quickSearch-s").bind("blur", function() {
			if ($(this).val() == '')
			{
				$(this).val($(this).attr("rel"));
				$(this).attr('rel', '');
			}
		});

		// jquery selectboxes
		try
		{
			$('select').selectbox();
		}
		catch (e) {}

		// jquery lightboxes
		try
		{
			$('div.image a.fatbox').fatbox();
		}
		catch (e) {}

		try
		{
			$('div.photogallery a.fatbox').fatbox(
				{
					media: {
						loader: {
							image: FatboxGallery.doNothing
						}
					}
				},
				{
					load: new Array(FatboxGallery.buildInterface),
					animated: new Array(FatboxGallery.fadeIn),
					closed: new Array(FatboxGallery.moveInterface)
				}
			);
		}
		catch (exc) {}

		// galleries
		try
		{
			$('#gallery').gallery();
		}
		catch (e) {}

		// external links
		$('a.ext').click(function() {
			try
			{
				if ($(this).attr('href') != '')
				{
					var ext = window.open($(this).attr('href'));
					ext.focus();
				}
			}
			catch (e) {}

			return false;
		});

		// gallery links
		$('a.galleryPopUp').click(function() {
			try
			{
				if ($(this).attr('href') != '')
				{
					var settings = "top=50,left=50,width=734,height=594,scrollbars=no,resizable=no,location=no,status=no";
					var ext = window.open($(this).attr('href'), "gallery", settings);
					ext.focus();
				}
			}
			catch (e) {}

			return false;
		});
	}
);
