var global_maps = new Array();

$(document).ready(function() {            
	$('#culture > ul').tabs();
    $('#news > ul').tabs();
    $('.Lightbox').lightbox();
    $('.Accordion').accordion({
    	header: 'span',
        alwaysOpen: false,
        active: false
    });
    $('#info > ul').tabs();            
    $('ul.MainMenu').superfish({delay: 100, speed: 'fast', dropShadows: true, autoArrows: true});
	$('.datepicker').datepicker();
	roundSelect();
	resize();
});
function resize()
{
	$('#tools').fontresizing({
        smallClass: 'small',
        mediumClass: 'medium',
        largeClass: 'large',
        fontresizingClass: 'font-resizing',
        cookieDuration: 365
});
}
function roundSelect()
{
	$('.RoundLink a').click(function() {
		$('.RoundConteiner').children().removeClass('Select');
		$(this).parent().addClass('Select');
	})
}

act_event=0;

function CById(href,id) 
{
	var h=$('#'+id);
	h.load(href,{});
}

function jById(href,id) {
	var h=$('#'+id);
	
	h.load(href,{},function(){
		 loadEnd(id);
		 startMaps();
	});
	
	loadStart(id);
}

function startMaps()
{
	var glen = global_maps.length;
	 for (var i = 0; i < glen; i++) {
		 var map_id = global_maps[i];
		 var func = 'DBSActivateMap_' + map_id + '();';
		 eval(func);
	 }
}
function getFormConteiner(href, id, form_id)
{
	var h = $('#'+id);	
	h.load(href,$('#'+form_id).serializeArray(), function(){startMaps();});
}
function getFormConteinerAppendData(href, id, form_id)
{
	var h = $('#'+id);	
	var dataString = $("#"+form_id).serializeArray();
	$.ajax({
		  url: href,
		  dataType: 'text',
		  type: 'POST',
		  data: dataString,
		  success: function(dataC) {
				h.append(dataC);
			}
		});
	$('.Lightbox').lightbox();
}

function loadEnd(id) {
	
	var h=$('#'+id);
	
	h.animate({
		opacity: "1"
	},1000);
	
	$('.Lightbox').lightbox({
	 	fitToScreen: true,
	 	disableNavbarLinks: true
	});
	if(typeof window.displayMap == 'function'){
		displayMap();
	}
}

function loadStart(id) {
	var h=$('#'+id);
	h.css('opacity','0.4');
	var he = h.css('height');
	
	var wi = h.css('width');
	hei = he.replace('px','');
	wid = wi.replace('px','');
	heig = (Math.round((hei)/2));
	widt = (Math.round((wid)/2));
	h.append('<div style=\'top:'+heig+'px; left: '+widt+'px;\' class=\'Loadrek\'></div>');
}

function collapseAll() {
	var m=$('.MapBox');
	m.css('border','0px');
	m.animate({
		height: "0px"
	},900);
}
function showMap() {
   var m=$('.MapBox');
   m.css('border','1px solid #C9C9C9');
   m.animate({
	   height: "300px"
   },900);
}

function showConteinerOrHide(id)
{
	var m=$('#'+id);
	if (m.css('display')=='none') {
		m.show('slow');
	} else {
		m.hide('slow');
	}
}
function choseAct(value)
{
	alert(value);
}

function mainEventsSwich(ile) {
	var ile = $('.NewsBody').length;
	
	setTimeout('mainEventsSwich2('+ile+',1);',6000);
}

function mainEventsSwich2(ile,t) {

	if (act_event==ile) act_event=0;
	change=act_event+1;
	if(change==ile)  change=0;
	changePromoEvents(act_event,change);
	
	if (t) setTimeout('mainEventsSwich2('+ile+',1);',6000);
	
	act_event++;
	
}

function mainEventsSwichRev(ile) {

	if (act_event==ile) act_event=0;
	change=act_event-1;
	
	if (change==-1)  change=ile;
	changePromoEvents(act_event,change);
	
	act_event--;
	
}


function changePromoEvents(act,change) {
	$('#promo_event_'+act).hide();
	$('#promo_event_'+change).show();
}

function fbs_click() {
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

