$(document).ready(function() {
	$("#footerOut").corner("7px");
	$(".drop").selectbox();
	//$(".corner7").corner("7px");
	//$(".corner10").corner("10px");

	$("#filterRadio li > a").live('click', function (event) {
		event.preventDefault();

		// wyzeruj stan listy
		$('#filterRadio .radioactive').removeClass("radioactive");
			
		// zamień id linka na int opcji
		var id = this.id;
		var newselect = id.replace('filterLink', '');

		// zaznacz radio!
		var radiosy = $('.filterRadio > input:eq('+newselect+')');
		radiosy.attr('checked', true);

		// dodaj klasę do linka
		$(this).addClass("radioactive").parent().addClass("radioactive");

		return false;
	});
	
	if ( $('.filterRadio > input:eq(0)').attr('checked')) {
		$('#filterLink0').addClass("radioactive").parent().addClass("radioactive");
	}
	else if ($('.filterRadio > input:eq(1)').attr('checked')) {
		$('#filterLink1').addClass("radioactive").parent().addClass("radioactive");
	}
	
	// faq section
	$('div#faq div.faqQuestion').click(function() {
		$(this).next().toggle('fast');
		$(this).toggleClass('faqQuestionActive');
		return false;
	}).next().hide();

	// fix Eolas' patent ('Click to activate and use this control' problem in Opera/IE)
	function fixClickMeObjProblem() {
		var htmlObjects = document.getElementsByTagName("object");
		for (i = 0; i < htmlObjects.length; i++) { 
			htmlObjects[i].outerHTML += ""; 
		}
	}
	if ($.browser.opera) { fixClickMeObjProblem(); }

	// hover effect on images
	$('img.imgFrame').hover(function() {
		$(this).stop().animate({opacity: 1}, "fast");
	},function() {
		$(this).stop().animate({opacity: 0.8}, "fast");
	});

	// read on links - insert arrow
	$('.readOn').append('&nbsp;<img src="/images/arrowROrange.png" />');

	// tabify!
	$('#tabBar a').click(function() {
		$('#productTabs > .tabContent').hide().filter(this.hash).show();
		$('#tabBar a').removeClass('selected');
		$(this).addClass('selected').blur();
		return false;
	}).filter(':first').click();
	
	// product gallery in the right column
	$('#galleryOut').innerfade({ 
		animationtype: 'fade',
		speed: 900,
		timeout: 6000,
		containerheight: '111px'
	});
});

var currentRegion = "";

function selectRegion(str) {
	// check if form sent by, if so exit
	if (typeof formSent !== "undefined"){
		return;
	}

	// update the page
	if (currentRegion != "") {
		$("#"+currentRegion).hide();
	} else {
		$("#regions").show();
		$("#regionPrompt").hide();
		$("#regionForm").show();
		$(".drop").selectbox();
	}
	currentRegion = str;
	$("#"+currentRegion).show();

	// update form email
	var regionEmail = $("#"+currentRegion+" > div > #regionEmail").html();
	setEmailRegion(regionEmail);

	// update header image
	var newSrc = "/umbraco/imagegen.aspx?text=" + 
		$("#"+currentRegion+" > div > #regionNazwa").html() + 
		"&Font=/images/MyriadPro-Regular.ttf&FontColor=002D85&FontSize=26&Format=PNG";
	$("#placeholder").attr('src', newSrc);
}

