﻿// SKRYPTY RODZINA

//zakładki
function changeZak(n, hm, bxName){
	for(var i=1; i<=hm; i++) {
		if(i==n) {
			$('d'+bxName+i).show(); //kontent
			$('z'+bxName+i).addClass("on");
		} else {
			$('d'+bxName+i).hide(); //kontent
			$('z'+bxName+i).deleteClass("on");
		}
	}
}

var calendarForm;

WP.event.set(window, 'ondomload', function() {
	if (typeof $('dodajWydarzenie') == 'object') {
		calendarForm = new bliscy.lib.window.Window('dodajWydarzenie');
		calendarForm.setPosition(calendarForm.POS_CENTER, calendarForm.POS_CENTER);
	}
})

function showForm(n) {
	calendarForm.show();
	Shadow.show();
}

function hideForm(n) {
	clearCalendarEvent();
	calendarForm.hide();
	Shadow.hide();
}

function showAddCalendarEvent(n) {
	showForm(n);
	$('ceHeaderCreate').style.display = 'block';
	$('ceHeaderUpdate').style.display = 'none';
	$('calendarEvent')['do'].value = 'create';
}

function showEditCalendarEvent(n, eventId) {
	showForm(n);
	$('ceHeaderCreate').style.display = 'none';
	$('ceHeaderUpdate').style.display = 'block';
	var c = $('calendarEvent');
	var e = calendarEvents[eventId];

	for (var i = 0; i < c['type'].options.length; i++) {
		if (c['type'].options[i].value == e.type) {
			break;
		}
	}

	for (var j = 0; j < c['person1'].options.length; j++) {
		if (c['person1'].options[j].value == e.person1) {
			break;
		}
	}

	c['do'].value = 'update';
	c['eid'].value = eventId;
	c['type'].options.selectedIndex = i;
	c['day'].options.selectedIndex = parseInt(e.day) - 1;
	c['month'].options.selectedIndex = parseInt(e.month) - 1;
	c['year'].value = e.year;
	c['person1'].options.selectedIndex = j;
	c['description'].value = e.description;
}

function clearCalendarEvent() {
	var c = $('calendarEvent');
	var d = new Date();

	c['do'].value = '';
	c['eid'].value = '';
	c['type'].options.selectedIndex = 0;
	c['day'].options.selectedIndex = d.getDay() - 1;
	c['month'].options.selectedIndex = d.getMonth();
	c['year'].value = d.getFullYear();
	c['person1'].options.selectedIndex = 0;
	c['description'].value = '';
}

function noFirefoxFocusBorder() {
	if (!document.getElementsByTagName) return;
	var anchors = document.getElementsByTagName("a");
	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];
		if (anchor.getAttribute("href")) anchor.setAttribute("onfocus", "blur()");
	}
}


window.onload = noFirefoxFocusBorder;
