// JavaScript Document

jQuery.preloadImages = function() {
	for(var i = 0; i<arguments.length; i++) {
		jQuery("<img>").attr("src", arguments[i]);
	}
}




$(document).ready( function() {

	
	$.preloadImages(
		url_base + 'images/btn0-over.png',
		url_base + 'images/btn1-over.png',
		url_base + 'images/btn2-over.png',
		url_base + 'images/btn3-over.png',
		url_base + 'images/btn4-over.png',
		url_base + 'images/btn5-over.png',
		url_base + 'images/menu_cloud_arrow.png',
		url_base + 'images/mini-th-over.gif',
		url_base + 'images/search_btn-over.png',
		url_base + 'images/menu_cloud_arrow.png',
		url_base + 'images/menu_cloud1_top.png',
		url_base + 'images/menu_cloud1_bottom.png',
		url_base + 'images/ui-btn01-over.png',
		url_base + 'images/ui-btn01-down.png',
		url_base + 'images/ui-btn02-over.png',
		url_base + 'images/ui-btn02-down.png'
	);
	
	$("#top_menu a img").mouseover( function() {
		$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+11))+'-over.png');
	}).mouseout( function() {
		if ($(this).attr('rel') == 'on')
			$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+11))+'-on.png');
		else
			$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+11))+'.png');
	});
	
	$("#search_btn").mouseover( function() {
		$(this).attr('src', url_base+'images/search_btn-over.png');
	}).mouseout( function() {
		$(this).attr('src', url_base+'images/search_btn.png');
	});

	$(".ui-button").mouseover( function() {
		$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+15))+'-over.png');
	}).mouseout( function() {
		$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+15))+'.png');
	}).mousedown( function() {
		$(this).attr('src', $(this).attr('src').substr(0, (url_base.length+15))+'-down.png');
	});

	$("#mini_search").RSV({
		onCompleteHandler: function() {
			document.location = url_base + 'Szukaj/' + $('#search_field').val() + '/';
			return false;
		},
		displayTyoe: 'alert-one',
		errorTextIntro: 'Błąd:',
		rules: [
			"length>1,search,Szukana fraza jest zbyt krótka!"
		]
	});

	$("#main_search").RSV({
		onCompleteHandler: function() {
			document.location = url_base + 'Szukaj/' + $('#main_search_field').val() + '/';
			return false;
		},
		displayTyoe: 'alert-one',
		errorTextIntro: 'Błąd:',
		rules: [
			"length>1,search,Szukana fraza jest zbyt krótka!"
		]
	});

	$("ul.sf-menu li ul").prepend('<li class="cl1_top"><img src="'+url_base+'images/menu_cloud_arrow.png" class="sf-arrow" alt="" /></li>');
	$("ul.sf-menu li ul").append('<li class="cl1_bottom"></li>');

	var title = $('#flash_header h1').text();
	var model = $('#flash_header h3').text();

	swfobject.embedSWF(
		url_base + 'flash/title.swf',
		'flash_header',
		500, 40,
		'9.0.0',
		false,
		{
			nazwa: title,
			model: model
		},
		{
			menu: 'false',
			wmode: 'transparent',
			bgcolor: '#000000',
			flashvars: 'nazwa='+title+'&model='+model
		}
	);

	swfobject.embedSWF(
		url_base + 'flash/hotele.swf',
		'flash_hotele',
		250, 210,
		'9.0.0',
		false,
		false,
		{
			menu: 'false',
			wmode: 'transparent',
		}
	);


});
