$(function(){ 
	$('input[title!=""]').hint();
	$('textarea[title!=""]').hint();
});

$(document).ready(function() {

//proba=$("#list-month li:first").attr("class");
//alert(proba);
	
	$('input.button').hover(function() {
	$(this).addClass('hover');
	}, function() {
	$(this).removeClass('hover');
	});	
	
	$("#destinations li.main a").click(function () {
	  if($(this).attr("class")=="open")
	  	{
	  		$(this).removeClass("open");
	  		$("#destinations ." + this.rel).hide("fast");
	  	}
	  else{
	  $("#destinations li[class!=\"main\"]").hide();
	  $("#destinations a").removeClass("open");
	  $(this).addClass("open");
	  $("#destinations ." + this.rel).show("fast");
  	  }
	  
	});
	onread();
	calendar_onread();


$("#ddlProducttypes").change(function(){ 


	var prod_id=$(this).val();
	if(prod_id) id=prod_id;
	else id=0;
	var country=$("#country_type").val();
  var offset=$("#country_offset").val();
  var country_name=$("#country_name").val();
	//alert(country_name);
	document.location.href="/Destination/"+country+"/"+0+"/"+id+"/"+country_name+".html";
	//$("#content_offer").hide();
	//$("#content_offer").load("/en/_script_country_type.php",{"id":id,"country":country},
     //     function() {	
      //        $("#content_offer").show();onread();});
});

$("#ddlCountry").change(function()
{ 
	var country_id=$(this).val();
	if(country_id) id=country_id;
	else id=0;
	var type=$("#t_type").val();    
    var type_name=$("#t_name").val();    
    document.location.href="/ProductType/"+type+"/"+0+"/"+type_name+".html?cid="+id+"";
	
});

function onread() 
{
$("dl.offerlist dd a").css({ background: "#fff", opacity: "0", filter: "alpha(opacity=0)" });
	$('dl.offerlist dd').hover(function() {
	$(this).addClass('hover');
	}, function() {
	$(this).removeClass('hover');
	});		
}

function calendar_onread()
{
	$(".calendar-event .calendar-cover").css({ background: "#fff", opacity: "0", filter: "alpha(opacity=0)" });
	$('.calendar-event').hover(function() {
	$(this).addClass('calendar-hover');
	}, function() {
	$(this).removeClass('calendar-hover');
	});		
}

/* RCOL JAVACrIPT */
	$('#boxshow-flight a').click(function() {
			if($(this).hasClass('down')) $(this).removeClass('down');
			else $(this).addClass('down');
			$('#flightinfo').slideToggle('normal');
		});
	
	$('.box a').click(function() {
		if($(this).hasClass('down')) $(this).removeClass('down');
		else $(this).addClass('down');
		$(this).parent().parent().parent().parent().parent().parent().find('.hidden').slideToggle('normal');
	});
	
	$('.dep-info li .topinfo').click( function() {
		if( $(this).parent().hasClass('selected') ) {
		$(this).parent().find('ul').slideUp('normal');
		$(this).parent().removeClass('selected'); 
		return;
		} // END IF
		
		if( $(this).parent().hasClass('noinfo') ) return;
		else	{
			$(this).parent().find('ul').slideDown('normal');
			$(this).parent().addClass('selected');
		}
	});
	
	
	
/* RCOL JAVACrIPT */


/*$("#newsletter_form").validate({
        rules: {
        newsletter_email: {
				required: true,
				email:true
			}}
			});*/
			
/*$("#ordercatalogue").validate({
        rules: {
        name: {
				required: true,
				email:false,
				messages:{required:""}
			},
			phone: {
				required: true,
				email:false,
				messages:{required:""}
			},
			mail: {
				required: true,
				email:true,
				messages:{required:""}
			},
			street: {
				required: true,
				email:false,
				messages:{required:""}
			},
			street_number: {
				required: true,
				email:false,
				messages:{required:""}
			},
			city: {
				required: true,
				email:false,
				messages:{required:""}
			},
			postal_code: {
				required: true,
				email:false,
				messages:{required:""}
			},
			country: {
				required: true,
				email:false,
				messages:{required:""}
			},
			hereAboutPenguin: {
				required: true,
				email:false,
				messages:{required:""}
			}
			
			}
			});*/
});

function order(id)
{
    var ch=$("input[name='catalog_"+id+"']:checked");
    var str = ch.val();
       
    $.post("/en/_script_order_catalogue.php", {"id":id, "inp":str});
         
}

$(function() {
	$('ul#gallery a').lightBox();
	$('a.fancybox').fancybox({	'width'				: 550,
		'height'			: 480,
		'autoDimensions'    : false,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
});
    
    
  
	
	
	 /* var dialogOpts = 
	  {
          modal: true,
          bgiframe: true,
          autoOpen: false,
          height: 500,
          width: 500,
          draggable: true,
          resizeable: true,
    };
    $("#example").dialog(dialogOpts);   //end dialog
   
   $('.fancybox').click(
      function() {
         $("#example").load("script_tourleader.php", [], function(){
               $(".fancybox").dialog("open");
            }
         );
         return false;
      }
   );*/



		//$("a.dialog").dialog('open');
		//$("a.dialog").dialog();

});

function calendar(event)
{
	var count=$("#list-month li:last").attr("id");
	if(count)
	{
		var all=count.split("_");
		all=all[1];
	}
	
	if(event=='right')
	{		
		if($(".first").attr("id"))
		{			
			var cnt=$(".first").attr("id");
			var id=cnt.split("_");
			var id=parseInt(id[1]);	
			var next=id+1;
			var cnt_to_end=next+4;
						
			if(cnt_to_end>=all) $("#calendar-switch-right").html("");
			$("#calendar-switch-left").html("<a class=\"control\" href=\"javascript:calendar('left');\"><span>&nbsp;</span></a>");
			
			if(	$("#cnt_"+next+"").attr("id"))
			{							
				nextYear=$("#cnt_"+next+"").attr("class");	
				nextYear=nextYear.split("_");			
				nextYear=parseInt(nextYear[1]);	
					
				curryear=$("#cnt_"+id+"").attr("class");	
				curryear=curryear.split(" ");	
				  
							
				//if(nextYear=='null'||nextYear=='')	nextYear=$("#cnt_"+id+" span.year").html();							
				$("#cnt_"+id+"").attr("style","display:none;");				
				//$(".first span.year").html("");				
				$("#cnt_"+id+"").attr("class",curryear);
				$("#cnt_"+next+"").attr("class","first year_"+nextYear+"");
				//$(".first span.year").html(nextYear);
			}			
		}
		
	}
	else if(event=='left')
	{		
		if($(".first").attr("id"))
		{
			var cnt=$(".first").attr("id");		
			var id=cnt.split("_");
			var id=parseInt(id[1]);
			var last=id+5;
			var prev=id-1;	
			if(prev<=1) $("#calendar-switch-left").attr("");			
			$("#calendar-switch-right").html('<a class="control" href="javascript:calendar(\'right\');"><span>&nbsp;</span></a>');	
			
			if(	$("#cnt_"+prev+"").attr("id"))
			{				
			
				year=$("#cnt_"+prev+"").attr("class");	
				year=year.split("_");			
				year=parseInt(year[1]);	
				
				curryear=$("#cnt_"+id+"").attr("class");				
				curryear=curryear.split(" ");				
							
				var  selYear=curryear[1].split("_");		
				
				//$(".first span.year").html("");
				$("#cnt_"+id+"").attr("class",curryear);			
				$("#cnt_"+prev+"").attr("class","first year_"+year+"");
				$("#cnt_"+prev+"").attr("style","display:block");
				
				//if(year!=selYear[1]) { $("#cnt_"+id+" span.year").html(""+selYear[1]+"");}
				//if(year=='null'||year=='')	year=$("#cnt_"+id+" span.year").html();	
				
				//$(".first span.year").html(year);
			}
		}
		
	}		
}	
/*var count=$("#list-month li:last").attr("id");
	if(count)
	{
		var all=count.split("_");
		all=all[1];
	}
	var slides = $('#list-month li');
	var total = slides.length;
	var width = 80;				
	var slide_click_speed = 500;
	var total = slides.length;	
	var last = false;	
	var current=0;
	var offset = total-1;
	
	if(event=='right')
	{		
		if($(".first").attr("id"))
		{	
			slides.wrapAll('<div class="calendar-li"></div>');
			$('.calendar-li').css('width', width*total);
			$('.calendar-li li').attr("style","");
						
			var cnt=$(".first").attr("id");
			var id=cnt.split("_");
			var id=parseInt(id[1]);	
			var next=id+1;
			var cnt_to_end=next+4;
						
			if(cnt_to_end>=all) $("#calendar-switch-right a.control").attr("href","#");
			$("#calendar-switch-left a.control").attr("href","javascript:calendar('left');");		
						
			current=id;	
					
			if(	$("#cnt_"+next+"").attr("id"))
			{							
				nextYear=$("#cnt_"+next+"").attr("class");	
				nextYear=nextYear.split("_");			
				nextYear=parseInt(nextYear[1]);	
					
				curryear=$("#cnt_"+id+"").attr("class");	
				curryear=curryear.split(" ");							
				$("#cnt_"+id+"").attr("class",curryear);
				$("#cnt_"+next+"").attr("class","first year_"+nextYear+"");
				
			}
			
			$('.calendar-li').animate
			({
					
					marginLeft: width*(-current),
				  }, slide_click_speed
			);
		
			
		}		*/
