function addDates(date){
	/*if (date.getDay() == 0 || date.getDay() == 6) {
		return [false, ""];
	}*/
	for (x = 0; x < dates.length; x++) {
		/*if (date.getMonth() == months[x] - 1 &&
			date.getDate() == days[x]) {
			return [true, "preBooked_class"];
		}
		var a=dates[x].split(',');
		var b=a[0].split('-');
		var c=b[0]+','+(b[1])+','+b[2];
		var bas=new Date(c);
		var b=a[1].split('-');
		var c=b[0]+','+(b[1])+','+b[2];
		var bit=new Date(c);
		*/
		var a=dates[x].split(',');
		var b=a[0].split('-');
		var c=a[1].split('-');
		if (date.getDate() >= b[2] && date.getDate() <= c[2] && date.getMonth() >= b[1]-1 && date.getMonth() <= c[1]-1 && date.getFullYear() >= b[0] && date.getFullYear() <= c[0]){
			
			return [true, "preBooked_class"];
		}
	}
	return [true, ""];
}
$(function(){
	$('#datepicker').datepicker({
		beforeShowDay: addDates,
		showOtherMonths: true,
		onSelect:function(a){
			$.post(local+'/etkinlik/detay',{tarih:a},function(data){
				if (data.htm!=''){
					//alert(data.htm);
					$('#dialog').html(data.htm);
					$('#dialog').dialog({
						width:550,
						height:350,
						modal: true,
						title:data.title
					});
				}
			},'json');
		}
	});
	//$('#datepicker .datepicker table.datepickerViewDays tr').each(function(i){
	$('#datepicker tr').each(function(i){
		$(this).children('td:first').css('border-left','none');
		$(this).children('td:last').css('border-right','none');
		$(this).children('th:first').css('border-left','none');
		$(this).children('th:last').css('border-right','none');
	});

	//$('.icerik').jScrollPane({showArrows: true});
	$('#list').jScrollPane({showArrows: true});
	$(this).find("[class*=corners]").each(function(i){
		rulesP = $(this).attr('class');
		rulesR = /\[(.*)\]/;
		getR = rulesR.exec(rulesP);
		str = getR[1];	
		$(this).corner(str);
	});
	var options = {
		newsList: "#news",
		startDelay: 10,
		placeHolder1: " |",
		tickerRate: 80,
 		controls: false,
 		ownControls: false,
 		stopOnHover: false,
 		resumeOffHover: true
	}
	if ($('#news').length>0){
		$().newsTicker(options);
	}
	$('#email').live('click',function(){
		if ($(this).val()=='E-Posta Adresiniz'){
			$(this).val('');
			$(this).removeClass('default');
		}
	}).blur(function(){
		if ($(this).val()==''){
			$(this).val('E-Posta Adresiniz').addClass('default');
		}
	});
	$('form').validationEngine();
	
});
