var search;
var newsletter;

$(document).ready(function(){
	
	// custom file input - additional code
	if ($('.form_field').children("input[type=file]").length) {
		$('.form_field').children("input[type=file]").customFileInput();
		$(".customfile-input").css('opacity', 0);
	}
	
	// custom fonts
	Cufon.replace('#offer > a > span > span', {textShadow: '2px 2px 2px #3F3F3F'});
	Cufon.replace('#main_menu > li > a', {hover: {
        color: '#FEFEFE'
    }});
	Cufon.replace('#news > .title > span');
	Cufon.replace('#contact > .title');
	Cufon.replace('.column_title');
	
	// search text replace
	$('#search').focus(function(){
		if (!search) {
			search = $(this).val();
			$(this).val('');
		} else {
			if (search == $(this).val()) {
				search = $(this).val();
				$(this).val('');
			} 
		}
	}).blur(function(){
		if ($(this).val()=='') {
			$(this).val(search);
		}
	});
	
	// newsletter text replace
	$('#newsletter').focus(function(){
		if (!newsletter) {
			newsletter = $(this).val();
			$(this).val('');
		} else {
			if (newsletter == $(this).val()) {
				newsletter = $(this).val();
				$(this).val('');
			} 
		}
	}).blur(function(){
		if ($(this).val()=='') {
			$(this).val(newsletter);
		}
	});
	
	// galleries
	if ($(".gallery > li > a").length) {
		$(".gallery > li > a").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Zdjęcie ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	}
	/*
	if ($(".big_gallery > li > a").length) {
		$(".big_gallery > li > a").fancybox({
				'transitionIn'		: 'none',
				'transitionOut'		: 'none',
				'titlePosition' 	: 'over',
				'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
					return '<span id="fancybox-title-over">Zdjęcie ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
				}
			});
	}
	*/

	// walidacja
	$("#contactValidate, #login_form, #newsletter_form").validate();
	
	$("#dane_techniczne table").addClass("data"); 
	$("#dane_techniczne tr:odd").addClass("odd"); 
	$("#dane_techniczne table tr").find("td").each(function(e) { 
			if (e%2 -1) $(this).addClass("left"); 
	});



	
});


function setFiles(){
	if (document.getElementById('group').value != ''){
		document.files.submit();
	}
}

