
jQuery(document).ready(function(){
			
																				jQuery('.countrysearch').autocomplete('/poputchik/showtravelform/getcountry/', {
																								
																								minChars: 3,cacheLength:300,
																								matchContains: true,
																								formatItem: function(data, i, n, value) {
																										
																									return "<img src='/assets/flags/" + value.split(':')[0] + "' /> " + value.split(':')[1];
																								},
																								formatResult: function(data, value) {
																									return value.split(':')[1];
																								}

		

																				});	
																				
																				function scity(){
																					
																					jQuery('#citystartcountrysearch').autocomplete('/poputchik/showtravelform/getcity/', {
																								matchContains: true,extraParams:{country:jQuery('#idstartcountrysearch').val()},
																								minChars: 0,cacheLength:100
																					});	
																				}
																				
																				function ecity(){
																					
																					jQuery('#cityendcountrysearch').autocomplete('/poputchik/showtravelform/getcity/', {
																								matchContains: true,extraParams:{country:jQuery('#idendcountrysearch').val()},
																								minChars: 0,cacheLength:100
																					});	
																				}
																				
																				function hcity(){
																					
																					jQuery('#cityhomecountrysearch').autocomplete('/poputchik/showtravelform/getcity/', {
																								matchContains: true,extraParams:{country:jQuery('#idhomecountrysearch').val()},
																								minChars: 0,cacheLength:100
																					});	
																				}
																				scity();ecity();hcity();
																				jQuery('#startcountrysearch').result(function(event, data, formatted) {
																					var t = data + ''
																					country = t.split(':')[2]		
																					jQuery('#idstartcountrysearch').val(country)
																					jQuery('#citystartcountrysearch').val('')	
																						
																					scity()																					
																				});
																				jQuery('#endcountrysearch').result(function(event, data, formatted) {
																					var t = data + ''
																					country = t.split(':')[2]		
																					jQuery('#idendcountrysearch').val(country)
																					jQuery('#cityendcountrysearch').val('')	
																						
																					ecity()																					
																				});
																				
																				jQuery('#homecountrysearch').result(function(event, data, formatted) {
																					var t = data + ''
																					country = t.split(':')[2]		
																					jQuery('#idhomecountrysearch').val(country)
																					jQuery('#cityhomecountrysearch').val('')	
																						
																					hcity()																					
																				});
			
        	
        	
        	panelsel = ''
	         jQuery('#search span a').click(function(){
	
	        	panel = jQuery(this).attr('href')  + 'l'
	            id = jQuery(this).attr('id')
	
	            jQuery(panelsel).parent().find('span').removeClass('active')
	
	        	if (panelsel != '' && panelsel != panel)
	                 jQuery(panelsel).hide()
	
	        	if (jQuery(panel).css('display') != 'none')
	        	{
	        		jQuery(panel).fadeOut(500)
	        		jQuery(this).parent().removeClass('active')
	        	}
	        	else
	        	{
	        		jQuery(panel).fadeIn(500)
	                jQuery(this).parent().addClass('active')
	        	}
	
	        	panelsel = panel
	        })
        	
        	jQuery('#travelpanell a').click(function(){        	
             		
	             jQuery('#formats').animate({opacity: "hide"},function(){
	             		  
	             	      jQuery('#form').fadeIn(1000)
	
	             })
					if (jQuery(this).attr('rel') == 'ct')
					{
	             		  	jQuery('#fwhere').hide();
	             		  	jQuery('#fwhere input').attr('disabled',true);
	             		  	jQuery('.minihead  a[@rel*=ct]').addClass('act')	
	             	}
	             	else 
	             	{
	             		jQuery('#fwhere').show();
	             		jQuery('#fwhere input').attr('disabled',false)
	             		jQuery('.minihead a[@rel*=it]').addClass('act')
	             	}
	             	
	        })
	        
	        jQuery('.minihead a').click(function(){
	        	jQuery('.minihead a').removeClass('act');
	        	jQuery(this).addClass('act')
	        })
        	
        	
        	
        	
        	jQuery.dpText = {
				TEXT_PREV_YEAR		:	'Предыдущий год',
				TEXT_PREV_MONTH		:	'Предыдущий месяц',
				TEXT_NEXT_YEAR		:	'Следующий год',
				TEXT_NEXT_MONTH		:	'Следующий месяц',
				TEXT_CLOSE			:	'Закрыть',
				TEXT_CHOOSE_DATE	:	''
			};
            Date.format = 'dd-mm-yyyy';
            jQuery('.datesearch').datePicker({startDate:'01/01/1996',clickInput:true});
		
			
	           		
		            	
			            jQuery('a.ajax').click(function(){
									   id = jQuery('#' + $(this).attr('name'));	
									   hide = jQuery(this).parent()	
									   			
									   jQuery.ajax({
									   		
									   		url: jQuery(this).attr('href'),		   							
									   		beforeSend: function(){
    														id.html('<img src=\"/assets/new/load.gif\">Загрузка')
   														}, 
   											success: function(msg){
													    			id.html(msg)
													    			//.animate( {backgroundColor:'red'}, 1000)
													    			hide.fadeOut(500)				
													   }
									   		})
									   		
									   return false;
									})
						
	
    
					function activate(){
							 		jQuery('a.fotoedit').click(function(){
							 		id = jQuery(this).attr('name')
							 	    delet = jQuery(this).parent().parent()
							 	    		
							 		desc = jQuery('#editdesc' + id).attr('value')	
							 		flag = true
							 		if (jQuery(this).attr('title') == 'Удалить фото')
							 			if (confirm('Вы действительно хотите удалить фотографию?'))		
							 				flag = true			
							 			else
							 				flag = false
							 						
							 		if (flag == true && desc != '' )
										 jQuery.ajax({
									   		type: 'POST',
									   		url: jQuery(this).attr('href'),
									   		data: 'text='+desc,	
									   		dataType: 'html',					   							
									   		beforeSend: function(){
    														jQuery('#actionsfor' + id).show()
															jQuery('#controlsfor' + id).hide()
															jQuery('#desc' + id).show()
    														jQuery('#desc' + id).html('<img src=\"/assets/new/load.gif\">')
   														}, 
   											success: function(msg){
													    			if (msg=='deletefoto')
													    				delet.fadeOut(500)
													    			else jQuery('#desc' + id).html(msg)
													    							
													   }
									   		})	
									   						
										return false;								
									})
											
									jQuery('a.editshow').click(function(){
										id = jQuery(this).attr('name')
										jQuery('#actions' + id).hide()
										
										jQuery('#controls' + id).show()				
									})		
											
									jQuery('a.editcancel').click(function(){
										id = $(this).attr('name')
										jQuery('#actionsf' + id).show()
										
										jQuery('#controlsf' + id).hide()				
									})			
											
											
											
												
							 	}	
						
						
						jQuery("#fade").click(function(){jQuery("#fade, .dialog").fadeOut(300)})
						jQuery('a.show2').click(function(){
							    if ($(this).html() == 'Показать фото')
							    	flag = true; 		
							    else flag = false
							    		
							    				
							    id = jQuery('#fotoalbum' + jQuery(this).attr('name'))							    	
							    lightbox = jQuery(this).attr('name')
							    if (jQuery('#fotos' +jQuery(this).attr('name')).attr('class') == undefined && flag == true)
							    {		
									id.html('<img src=\"/assets/new/load.gif\">Загрузка')
										jQuery.get($(this).attr('href'),function(data){
															
														id.replaceWith(data);jQuery('a[@rel*=lightbox'+lightbox+']').lightBox();
														activate()		
													})
									
							    }	
								else if (flag == true) 
										jQuery('#fotos' +jQuery(this).attr('name')).fadeIn(300);
								else if (flag == false )
										jQuery('#fotos' +jQuery(this).attr('name')).fadeOut(300);							
								
								if (flag == true) 		
										jQuery(this).html('Скрыть фото')
								else 	jQuery(this).html('Показать фото')
										
								return false;		
								
							})		
							 		
							 	
		 				
		});
      

		function pmFirst(id)
		{
			if (jQuery('#child' + id).css('display') != 'block')
			{
				jQuery('#child' + id).animate({ opacity: "show" }, "slow");
                jQuery('#messageShort' + id + ' span').hide();
                jQuery('#pm' + id).addClass('pmactive');
                jQuery('#pm' + id).removeClass('pmnew');
                jQuery('#headerMes'+ id + ' div').css('font-weight','normal');
			}
			else
			{
				jQuery('#child' + id).animate({ opacity: "hide" }, "slow");
				jQuery('#messageShort' + id + ' span').show();
				jQuery('#pm' + id).removeClass('pmactive');
			}
		}

		function pm(id)
		{
			if (jQuery('#message' + id).css('display') != 'block')
			{
				jQuery('#message' + id).animate({opacity: "show" }, "slow");
                jQuery('#messageShort' + id + ' span').hide();
			}
			else
			{
				jQuery('#message' + id).animate({ opacity: "hide" }, "slow");
				jQuery('#messageShort' + id + ' span').show();
			}
			jQuery('#headerMes' + id + ' div').css('font-weight','normal');
			jQuery('#pm' + id).removeClass('pmnew');

		}    