$(function(){
	
	$('.cycle').cycle().css('display','block');
	
	if($('.datepicker').attr('name') != undefined){
		$('.datepicker').datepicker({
			nextText: '',
			prevText: '',
			dateFormat: 'd M y'
		});
		
		$('.datepicker').each(function(){
			
			var name = $(this).attr('name');
			var hiddenId = name+'_hidden';
			
			$(this).after('<input id="'+hiddenId+'" type="hidden" name="'+name+'" value="" />');
			$(this).removeAttr("name");
						
			$(this).datepicker('option', 'altField', '#'+hiddenId);
			$(this).datepicker('option', 'altFormat', 'yy-mm-dd');
			
			if($(this).val()=='' || $(this).val()==undefined){
				$(this).val('Click here');
			}else{
				$('#'+hiddenId).val($(this).val());
				
				var objDp = $(this);
				
				$.get('/p/date.php?date='+$(this).val(),function(e){
					
					objDp.val(e);
					
				});
			}
		});
	}
	
	$('#gallery a, #right_panel_gallery a').lightBox({
		fixedNavigation: true
	});
	
	$('img').each(function(){
		if(($(this).attr('title') == '' || $(this).attr('title') == undefined) && ($(this).attr('alt') != '' && $(this).attr('alt') != undefined)){
			$(this).attr('title',$(this).attr('alt'));
		}
	});
	
	if($.browser.msie){
		$('#header').height(330);
		$('#lightbox-nav-btnPrev, #lightbox-nav-btnNex').css('zoom','1');
	}
	
	$('head').append('<link href="/css/ui.theme.css" type="text/css" rel="stylesheet" />');
	$('head').append('<link href="/css/ui.datepicker.css" type="text/css" rel="stylesheet" />');
	
});