$(document).ready(function() {
	
	
	$("#head .center .col01").append('<div id="flag"><a href="http://www.versium.sk/" target="_blank"><img src="/layout/aar/flag-sk36.png" width="36" height="36" alt="" border="0"></a></div>');
	
	$("#fancybox-outer").css({'background' : '#fff', '-moz-border-radius' : '20px', '-webkit-border-radius' : '20px', 'border-radius' : '20px'});
	
	$("a.pecet").fancybox({
		'titleShow'			: false,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade',
		'overlayColor'		: '#000',
		'overlayOpacity'	: '0.8'
	});
	
	var n = Math.floor((Math.random()*16) + 1);
	if (n < 10) n = '0' + n.toString();
	$("body").css({'background' : '#000 url(/layout/aar/bg-body-' + n + '.jpg) top center no-repeat'});
	
	var url = window.location.pathname;
	if (url == '/')
	{
		
	}
	else
	{
		urlRegExp = new RegExp(url.replace(/\/$/,''));
	
		$('#text .center .col01 ul li a').each(function()
		{
			if(urlRegExp.test(this.href))
			{
				$(this).addClass('hover');
			}
		});
		
		$('#head .center .col02 ul li a').each(function()
		{
			if(urlRegExp.test(this.href))
			{
				$(this).addClass('hover');
			}
		});
	}
	
	
	function switchText()
	{
		if ($(this).val() == $(this).attr('title'))
			$(this).val('');
		else if ($.trim($(this).val()) == '')
			$(this).val($(this).attr('title'));
	}
	
	$('input[type=text][title!=""]').each(function() {
		if ($.trim($(this).val()) == '') $(this).val($(this).attr('title'));
		if ($(this).val() == $(this).attr('title')) $(this).addClass('inputemail');
	}).focus(switchText).blur(switchText);
	
	
	$(".videopaticka").click(function() {
		$.fancybox({
			'autoScale'		: false,
			'transitionIn'	: 'none',
			'transitionOut'	: 'none',
			'overlayColor'	: '#000',
			'overlayOpacity': '0.8',
			'width'			: 680,
			'height'		: 495,
			'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/') + '&autoplay=1',
			'type'			: 'swf',
			'swf'				: {
				'wmode'			: 'transparent',
				'allowfullscreen'	: 'true'
			}
		});
		return false;
	});
	
	
	$('#text .center .col02 .grow01 .gcol01:odd').addClass('srow');
	$('#text .center .col02 .grow01 .gcol02:odd').addClass('srow');
	$('#text .center .col02 .grow01 .gcol02b:odd').addClass('srow');
	$('#text .center .col02 .grow01 .gcol03:odd').addClass('srow');
	$('#text .center .col02 .grow01 .gcol04:odd').addClass('srow');
	
	
	function copyValue() {
		var item_1 = $("#select_1").val();
		var item_1n = $("#select_1 option:selected").attr("title");
		var item_1p = $("#select_1 option:selected").attr("label");
		$("#itemnumber_1").attr("value", item_1);
		$("#itemname_1").attr("value", item_1n);
		$("#itemprice_1").attr("value", item_1p);
		
		var item_2 = $("#select_2").val();
		var item_2n = $("#select_2 option:selected").attr("title");
		var item_2p = $("#select_2 option:selected").attr("label");
		$("#itemnumber_2").attr("value", item_2);
		$("#itemname_2").attr("value", item_2n);
		$("#itemprice_2").attr("value", item_2p);
		
		var item_3 = $("#select_3").val();
		var item_3n = $("#select_3 option:selected").attr("title");
		var item_3p = $("#select_3 option:selected").attr("label");
		$("#itemnumber_3").attr("value", item_3);
		$("#itemname_3").attr("value", item_3n);
		$("#itemprice_3").attr("value", item_3p);
		
		var item_4 = $("#select_4").val();
		var item_4n = $("#select_4 option:selected").attr("title");
		var item_4p = $("#select_4 option:selected").attr("label");
		$("#itemnumber_4").attr("value", item_4);
		$("#itemname_4").attr("value", item_4n);
		$("#itemprice_4").attr("value", item_4p);
		
		var item_5 = $("#select_5").val();
		var item_5n = $("#select_5 option:selected").attr("title");
		var item_5p = $("#select_5 option:selected").attr("label");
		$("#itemnumber_5").attr("value", item_5);
		$("#itemname_5").attr("value", item_5n);
		$("#itemprice_5").attr("value", item_5p);
		
		var item_6 = $("#select_6").val();
		var item_6n = $("#select_6 option:selected").attr("title");
		var item_6p = $("#select_6 option:selected").attr("label");
		$("#itemnumber_6").attr("value", item_6);
		$("#itemname_6").attr("value", item_6n);
		$("#itemprice_6").attr("value", item_6p);
		
		var item_7 = $("#select_7").val();
		var item_7n = $("#select_7 option:selected").attr("title");
		var item_7p = $("#select_7 option:selected").attr("label");
		$("#itemnumber_7").attr("value", item_7);
		$("#itemname_7").attr("value", item_7n);
		$("#itemprice_7").attr("value", item_7p);
    }
    $("select").change(copyValue);
	
});
