jQuery(document).ready(function(){
	$("a.fancyselector").fancybox();

	if ($('a.imgpreviewselector').get(0)) {
		$('a.imgpreviewselector').imgPreview({
			srcAttr: 'rel',
			containerID: 'imgPreviewWithStyles',
			imgCSS: {
				// Limit preview size:
				height: 200
			},
			// When container is shown:
			onShow: function(link){
				// Animate link:
				//$(link).stop().animate({opacity:0.4});
				// Reset image:
				//$('img', this).stop().css({opacity:0});
			},
			// When image has loaded:
			onLoad: function(){
				// Animate image
				//$(this).animate({opacity:1}, 300);
			},
			// When container hides: 
			onHide: function(link){
				// Animate link:
				//$(link).stop().animate({opacity:1});
			}
		});
	}

	if ($('a.imgpreviewselectornorel').get(0)) {
		$('a.imgpreviewselectornorel').imgPreview({
			containerID: 'imgPreviewWithStyles',
			imgCSS: {
				// Limit preview size:
				height: 200
			},
			// When container is shown:
			onShow: function(link){
				// Animate link:
				//$(link).stop().animate({opacity:0.4});
				// Reset image:
				//$('img', this).stop().css({opacity:0});
			},
			// When image has loaded:
			onLoad: function(){
				// Animate image
				//$(this).animate({opacity:1}, 300);
			},
			// When container hides: 
			onHide: function(link){
				// Animate link:
				//$(link).stop().animate({opacity:1});
			}
		});
	}

	$("a.fancyselectorivideo").each(function() {
		//alert($(this).find('.hidden_data .videowidth').text());
		//alert($(this).find('.hidden_data .videoheight').text());
		$(this).fancybox({
			'hideOnContentClick': false,
			'frameWidth': parseInt($(this).find('.hidden_data .videowidth').text()),
			'frameHeight': parseInt($(this).find('.hidden_data .videoheight').text())
		});
	});

	$('.doscroll a[name]').each(function() {
		var htmlinside = $(this).html();
		$(this).replaceWith('<p id="' + $(this).attr('name') + '">' + htmlinside + '</p>');
	});

	$(function()
	{
		// this initialises the demo scollpanes and makes it reinitialise itself once it's images have loaded...
		var settings = {
			showArrows:true
		};
		$('.doscroll')
			.jScrollPane(settings)
			.onImagesLoad(
				{
					callback: function(ref) {
						$(ref).jScrollPane(settings);
					}
				}
			);
	});

	$('#frm_email_newsletter').click(function(){
		if ($(this).attr('value') == 'e-mail') $(this).attr('value', '');
	});
	$('#frm_email_newsletter').blur(function(){
		if ($(this).attr('value') == '') $(this).attr('value', 'e-mail');
	});
});
