﻿
jQuery(function ($) {
	$.datepicker.regional['he'] = {
		closeText: 'סגור',
		prevText: '&#x3c;הקודם',
		nextText: 'הבא&#x3e;',
		currentText: 'היום',
		monthNames: ['ינואר', 'פברואר', 'מרץ', 'אפריל', 'מאי', 'יוני',
		'יולי', 'אוגוסט', 'ספטמבר', 'אוקטובר', 'נובמבר', 'דצמבר'],
		monthNamesShort: ['1', '2', '3', '4', '5', '6',
		'7', '8', '9', '10', '11', '12'],
		dayNames: ['ראשון', 'שני', 'שלישי', 'רביעי', 'חמישי', 'שישי', 'שבת'],
		dayNamesShort: ['א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'],
		dayNamesMin: ['א\'', 'ב\'', 'ג\'', 'ד\'', 'ה\'', 'ו\'', 'שבת'],
		weekHeader: 'Wk',
		dateFormat: 'dd/mm/yy',
		firstDay: 0,
		isRTL: true,
		showMonthAfterYear: false,
		yearSuffix: ''
	};
	$.datepicker.setDefaults($.datepicker.regional['he']);
});

$().ready(function () {
	//	$("#sub_menu_wrap ul li a").each(function (i, el) {
	//		var s = $(el).html();
	//		$(el).html("<span>" + s + "</span>");
	//	}); 


	$.datepicker.setDefaults($.extend({}, $.datepicker.regional["he"]));

	$('.customSelect').selectmenu();

	//var events = '[{ Date: "07/06/2011", URL: "/" },{ Date: "05/06/2011", URL: "/" },{ Date: "06/06/2011", URL: "/" }]';

	//createCal(events);
	//$(".calendar").datepicker();
});

var _disable_cal_chng = false;
function createCal(events) {
	$().ready(function () {
		events = eval(events);
		$(".calendar").datepicker({
			beforeShowDay: function (date) {
				var result = [true, '', null];
				var matching = $.grep(events, function (event) {
					//return event.Date.valueOf() === date.valueOf();
					return event.Date === $.datepicker.formatDate('dd/mm/yy', date);
				});

				if (matching.length) {
					result = [true, 'highlight', null];
				}
				return result;
			},
			onSelect: function (dateText) {
				var i = 0;
				var event = null;

				while (i < events.length && !event) {
					if (events[i].Date == dateText) {
						event = events[i];
					}
					i++;
				}
				if (event) {
					lochref(_ev_url + "?d=" + dateText.replace('/', '.').replace('/', '.'));
				}
			},
			onChangeMonthYear: function (year, month, inst) {
				if (!_disable_cal_chng) {
					ws_GetEvents(month, year);
				} 
			}
		}).trigger('change');
	});
}


