$(document).ready(function(){
	//$(".calendar_div").pngFix();

	$(".du_image").mouseenter(function()
	{
		$(".du_additional").fadeIn('slow');
		$(this).css("cursor","pointer");
	}).mouseleave(function()
	{
	    $(".du_additional").fadeOut('slow');
	});

	$("a").click(function()
	{
		if($(this).attr("name") == "blesk_foto")
		{
			$("#blank2").toggle("slow");
			return false;
		}
		if($(this).attr("name") == "blesk_price")
		{
			$("#blesk_price").toggle("slow");
			return false;
		}
		if($(this).attr("name") == "kurs_more")
		{
			$("#kurs_hide").toggle();
			if($("#kurs_hide").css("display") == "none")
			{
				$(this).text("Показать еще");
			}else $(this).text("Скрыть")
			return false;
		}
		if ($(this).attr("name") == "show_photo")
		{
		 	$("#stroy_thumbnails").toggle('slow');
			return false;
		}
	});


	$(".write_stats").click(function()
	{
	 	//alert("sdf");
	 	writeStats($(this).attr("name"));
	});


	$(".radio_items").mouseenter(function()
	{
		i_id = $(this).attr("myattr");
		$(this).addClass("radio_item_on");
		$("#radio_item_bg_"+i_id).css("background", "url(images/radio/channels/radio_item_bg_on.gif) no-repeat left");
	}).mouseleave(function()
	{
		i_id = $(this).attr("myattr");
		$(this).removeClass("radio_item_on");
		$("#radio_item_bg_"+i_id).css("background", "url(images/radio/channels/radio_item_bg.gif) no-repeat left");
	}).click(function()
	{
		i_id = $(this).attr("myattr");
		RadioWin(i_id);
	});

	$("#radio_play").mouseenter(function()
	{
		$(this).addClass("radio_play_in");
	}).mouseleave(function()
	{
		$(this).removeClass("radio_play_in");
	}).click(function()
	{
		i_id = $("#radio_list").val();
		RadioWin(i_id);
	});
});


function writeStats(param)
{
	$.ajax
	({
	 	type: "POST",
	 	url: "index.php?option=com_counter&tmpl=component&format=raw&name="+param,
	 	cache: false,
	    success: function(msg)
	    {

		}
 	});
}

function animLeftDiv()
{

	item_left_str = $("#radio_content_table").css("left");
	item_left_int = parseInt(item_left_str.substring(0, item_left_str.length-2));
	if (item_left_int >= 0)
	{
		$("#radio_content_table").stop();
	}
	else
	{
	    animate_length = 0 - item_left_int;
		animate_duration = animate_length * 4;

	    {
			$("#radio_content_table").animate
		    (
		    	{"left": "+="+animate_length+"px"},
		    	{duration: animate_duration, complete: function(){animLeftDiv();}, easing: 'easeInOutSine'}
		    );
		}
    }
}

function animRigthDiv()
{

	item_left_str = $("#radio_content_table").css("left");

	item_left_int = parseInt(item_left_str.substring(0, item_left_str.length-2));

	total_width = 710;
	if (item_left_int <= -total_width)
	{
		$("#radio_content_table").stop();
	}
	else
	{

	    animate_length = total_width + item_left_int;
		animate_duration = animate_length * 6;
			$("#radio_content_table").animate
		    (
		    	{"left": "-="+animate_length+"px"},
		    	{duration: animate_duration, complete: function(){animRigthDiv();}, easing: 'easeInOutSine'}
		    );
    }
}



function hotels_photos(param){
  myWind= open("hotels/photo.php?hotel="+param, "HotelPhotosWindow",
    "width=600,height=430,status=yes,toolbar=yes,menubar=no");
}

function winop()
{
	myWind = open("/index2.php?option=com_facileforms&Itemid=69&ff_form=1&ff_frame=1",
					"displayWindow",
					"width=630,height=850,status=no,toolbar=no,menubar=no");
}

function RadioWin(i_id)
{
	myWind = open("modules/mod_radio/modal_window.php?radio_param="+i_id,
					"radioWindow",
					"width=230,height=120,status=no,toolbar=no,menubar=no");
}
