//<!--
var $j = jQuery.noConflict();

var headline_count;
var headline_interval;
var current_headline = 0;
var old_headline = 0;

$j(document).ready(function(){
	headline_count = $j("div.text-forecast").size();
	$j("div.text-forecast:eq(" + current_headline + ")").css('top', '0px');
	headline_interval = setInterval(headline_rotate, 5000);
	try { $j(".content .aktiv:last").css("background-image","none"); } catch (e) {}
	try { $j(".aktiv:last",$j(".content .sm_it_lst")).css("background-image","none"); } catch (e) {}
	try { $j(".news TD.x:last").css("background-image","none"); } catch (e) {}
	try { $j(".news TD.x.firstrow:last").css("background-image","none"); } catch (e) {}

	var pr_div = $j('#div_send_request');
	$j('#prod_send_request').click(function() {
		pr_div.toggle();
		if (pr_div.is(':visible')) {
			pr_div.find('input[name="name"]').val('');
			pr_div.find('input[name="email"]').val('');
			pr_div.find('input[name="phone"]').val('');
			pr_div.find('textarea').val('');
		}
		return false;
	});
	pr_div.find('input[type="image"]').click(function() {
		$j.post(
			app_path + 'pub/product/' + lang_name + '/product/' + pr_div.find('input[name="product"]').val() + '/',
			{
				"avo__ajax_request": 1,
				"send_product_request": 1,
				"name": pr_div.find('input[name="name"]').val(),
				"email": pr_div.find('input[name="email"]').val(),
				"phone": pr_div.find('input[name="phone"]').val(),
				"body": pr_div.find('textarea').val()
			},
			function(data)
			{
				if (data.result == 0) {
					pr_div.find('div.error').show().text(data.message);
				} else {
					pr_div.find('div.error').hide();
					pr_div.hide();
				}
			},
			"json"
		);
	});
});

if (map_name != '') {
	$j(document).ready(function(){
		$j('.content .map DIV a>IMG').hover(function () {
			this.src = this.src.replace(map_name, map_name + "_over");
		}, function () {
			this.src = this.src.replace(map_name + "_over", map_name);
		});
	});
}
function headline_rotate() {
	current_headline = (old_headline + 1) % headline_count;
	$j("div.text-forecast:eq(" + old_headline + ")").animate({top: -205},"slow", function() {
		$j(this).css('top','210px');
	});
	$j("div.text-forecast:eq(" + current_headline + ")").show().animate({top: 0},"slow");
	old_headline = current_headline;
}

function clear_search_value(ctrl) {
	if (ctrl.value == search_str) ctrl.value = '';
}

function show_booking_popup() {
	window.open(app_path + 'booking.html', booking_title, "height=400,width=400,status=no,toolbar=no,menubar=no,location=no");
	return false;
}

function news_manage() {
	var action_value = ($('nl_mng_subscr_ph').visible() ? '' : 'un') + 'subscribe';

	new Ajax.Request(app_path + 'pub/news_manage/' + lang_name + '/', {
		parameters: {
			action: action_value,
			first_name: $F('nl_mng_first_name'),
			surname: $F('nl_mng_surname'),
			country: $F('nl_mng_country'),
			email: $F('nl_mng_email')
		},
		onSuccess: function(transport) {
			var ok = (transport.responseText.match(/<status>(\d+)<\/status>/)[1] == '0');
			var msg = transport.responseText.match(/<message>(.*)<\/message>/)[1];
			var msg_ph = $('nl_mng_message');
			msg_ph.style.color = (ok) ? 'green' : 'red';
			msg_ph.style.display = '';
			msg_ph.innerHTML = msg;
			if (ok) $('nl_mng_first_name').value = $('nl_mng_surname').value = $('nl_mng_email').value = '';
		}
	});
	return false;
}

function update_weather_box(id) {
	new Ajax.Updater('area_weather_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			update_weather: id
		}
	});
	return false;
}

function toggle_subscr_newsletter_box(state) {
	var ph = $('nl_mng_subscr_ph');
	if (state) {
		ph.show();
	} else {
		ph.hide();
	}
	$('nl_mng_message').innerHTML = '';
	return false;
}

function show_taf_box() {
	$('taf_mng_ph').show();
	return false;
}

function do_taf() {
	new Ajax.Request(app_path + 'pub/taf/' + lang_name + '/', {
		parameters: {
			action: 'tip',
			your_name: $F('taf_mng_your_name'),
			fr_name: $F('taf_mng_fr_name'),
			fr_email: $F('taf_mng_fr_email'),
			text: $F('taf_mng_text')
		},
		onSuccess: function(transport) {
			var ok = (transport.responseText.match(/<status>(\d+)<\/status>/)[1] == '0');
			var msg = transport.responseText.match(/<message>(.*)<\/message>/)[1];
			var msg_ph = $('taf_mng_message');
			msg_ph.style.color = (ok) ? 'green' : 'red';
			msg_ph.style.display = '';
			msg_ph.innerHTML = msg;
			if (ok) $('taf_mng_your_name').value = $('taf_mng_fr_name').value = $('taf_mng_fr_email').value = $('taf_mng_text').value = '';
		}
	});
	return false;
}

function window_print() {
	window.print();
	return false;
}

function tip_about_product() {
	show_taf_box();
	$('taf_mng_your_name').scrollTo();
	$('taf_form').focusFirstElement();
	return false;
}

function prod_add_comment()
{
	var d = $('div_add_comment');
	if (d.visible()) {
		d.hide();
	} else {
		d.show();
		var t = $('ta_prod_comment');
		if (t) t.focus();
	}
	return false;
}

function prod_send_comment(p_id)
{
	new Ajax.Updater('div_add_comment', document.URL, {
		parameters: {
			'avo__ajax_request': 1,
			'ta_prod_comment': $('ta_prod_comment').value,
			'ta_prod_id': p_id
		}
	});
	return false;
}

function show_map(lat, lon, title){
	window.open(app_path + 'pub/map_popup/' + lang_name + "/?lat=" + lat + "&lon=" + lon + "&title=" + title, 'Map', "height=600,width=762,status=no,toolbar=no,menubar=no,location=no");
	return false;
}

function tp_add_to_palnner(p_id, name) {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_add_product: p_id,
			tp_product_name: name
		}
	});
	return false;
}

function tp_add_product_comment(p_id) {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_add_product_comment: p_id,
			tp_product_comment: $('rp_comment').value
		}
	});
	return false;
}

function tp_delete_product(p_id) {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_del_product: p_id
		}
	});
	return false;
}

function tp_delete_product_comment(p_id, c_id) {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_del_product_comment: p_id,
			tp_product_c_id: c_id
		}
	});
	return false;
}

function tp_calcel_planner() {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_cancel_planner: 1
		}
	});
	return false;
}

function tp_send_to_friend() {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_send_to_friend: 1,
			my_name: $F('tp_my_name'),
			subject: $F('tp_subject'),
			message: $F('tp_message'),
			email: $F('tp_email')
		}
	});
	return false;
}

function tp_publish_to_site() {
	new Ajax.Updater('travel_planner_box', document.URL, {
		parameters: {
			avo__ajax_request: 1,
			tp_publish_to_site: 1,
			my_name: $F('tp_my_name'),
			subject: $F('tp_subject'),
			message: $F('tp_message')
		}
	});
	return false;
}

function change_area(sender, url) {
	sender.form.action = sender.form.action.replace('/_AVO_AREA_REPL_/', '/' + sender.value + '/');
	sender.form.submit();
}

function tp_show_full_description() {
	document.getElementById("short").style.display="none";
	document.getElementById("full").style.display="block";
	return false;
}

function tp_clear_text(ctl, def_text) {
	if (ctl.value == def_text) ctl.value = '';
}

function show_user_comments(product_id)
{
	new Ajax.Updater('div_prod_comments', document.URL, {
		parameters: {
			'avo__ajax_request': 1,
			'get_user_comments': product_id
		}
	});
	return false;
}
// -->