$(function() {
	var newsletter_input = $('#footer form.f_prom input[name="email"]');
	var newsletter_placeholder = newsletter_input.val();

	newsletter_input.bind('focus', function() {
		if($(this).val() == newsletter_placeholder)
			$(this).val('');
	});

	newsletter_input.bind('blur', function() {
		if($(this).val() == '')
			$(this).val(newsletter_placeholder);
	});

	$('#show-coupon').live('click', function() {
		if($('#btn-coupon').width() < 600) {
			$('#btn-coupon').show().animate({
				width : 600
			}, 1000);
			$('#coupon').animate({
				right : 600
			}, 1000);
		} else {
			$('#btn-coupon').animate({
				width : 0
			}, 500, function() {
				$(this).hide()
			});
			$('#coupon').animate({
				right : 0
			}, 500);
		}
	});

	$('#menu img').mouseover(function() {
		this.src = this.src.replace(/\.gif/, '1.gif');
	}).mouseout(function() {
		this.src = this.src.replace(/1\.gif/, '.gif');
	})
});
function add_attachment() {
	el = document.createElement('input');
	el.type = 'file';
	el.name = 'pliki[]';
	el.className = 'form';
	document.getElementById('attachments').appendChild(el);
	return false;
}

function offer_select(id) {
	var el = $('#offer input[value="' + id + '"]');
	var parent_div = el.parent().parent();
	var child_div = el.parent().next();

	if(parent_div.hasClass('item')) {
		var parent_el = parent_div.prev().find('input');
		parent_div.show();
		parent_el.attr('checked', 'checked');
		offer_select(parent_el.val());
	}
	if(child_div.hasClass('item')) {
		if(el.attr('checked')) {
			child_div.show();
		} else {
			child_div.hide();
			child_div.find('input').each(function() {
				$(this).removeAttr('checked');
			});
			child_div.find('.item').each(function() {
				$(this).hide();
			});
		}
	}
}

function toggle_slides() {
	if(is_home) {
		var visible_slide = $('#main_slide > #slides > .slide:visible');
		var visible_text = $('#main_slide > #text > .text_slide:visible');
		var next_slide = visible_slide.next();
		var next_text = visible_text.next();
		$('#main_slide > #slides').append(visible_slide);
		$('#main_slide > #text').append(visible_text);
		next_slide.show();
		next_text.fadeIn(1000);
		visible_slide.fadeOut(1000);
		visible_text.fadeOut(1000);
	} else {
		var visible = $('#flash-page > div:visible');
		var next = visible.next();
		$('#flash-page').append(visible);
		next.show();
		visible.fadeOut(1000);
	}
}
