
(function(){
	var $ = document.id;
/**Toggler**/
this.Collapsable = new Class({
    Extends: Fx.Reveal,
    initialize: function(clicker, section, options) {
        this.clicker = $(clicker).addEvent('click', this.toggle.bind(this));
        this.parent($(section), options);
    }
});
/**end Toggler**/
/**Menu**/
this.myMenu = new UvumiDropdown("dropdown-menu",{
	duration:250, //duration in millisecond of opening/closing effect default 250
	openDelay:50,  //if hover mode, duration the mouse must stay on target before submenu is opened. if exits before delay expires, timer is cleared 
    closeDelay:200, //delay before the submenu close when mouse exits. If mouse enter the submenu again before timer expires, it's cleared
	transition:Fx.Transitions.Linear, //default was Fx.Transitions.linear
	delay:500, //default was 500ms
	clickToOpen:false, //default was false
	mode:'horizontal'
	}); 
/**end Menu**/
/**addThis**/
var addthis_config = {
     ui_language: "sl",
     data_use_flash: false
};
/**end addThis**/
/**Newsletter**/
function nlCallback(obj) {
	if(obj != undefined && obj.length > 0) {
		if($$('.mod_subscribe') && $$('.mod_subscribe').length>0 && $$('.mod_subscribe')[0].getElements('p.error').length<=0) {
			$$('.mod_subscribe h4')[0].setStyle('display','none');
            $$('.mod_subscribe input').each(function(el){el.setStyle('display','none');});
            $('nllinkButton').setStyle('display','none');
		}
	}
}
/**end Newsletter**/

window.addEvent('domready', function(){
	/**Login over text**/
	if($$('input.formtxtfield') && $$('input.formtxtfield').length>0){
		$$('input.formtxtfield').each( function(el) {
	        new OverText(el,{
	            poll: true
	        });
	    });
	}
	/**end Login over text**/
	/**Open new window**/
    $$('a[rel^=_blank]').each(function(el) {
        el.setProperty('target', '_blank');
    });
	/**end Open new window**/
    /**Menu**/
    if($$('ul#dropdown-menu li.active a') && $$('ul#dropdown-menu li.active a').length > 0) {
        var size = $$('ul#dropdown-menu li.active a')[0].measure(function(){
            if($('activestripe') != undefined && $('activestripe') != null) {
                $('activestripe').setStyle('width',this.getSize().x+'px');
            }
        });
    }
    /**end Menu**/
    /**CFE-nice form Anketa**/
    if(($$('.anketaform') && $$('.anketaform').length > 0) || ($$('.mod_registration') && $$('.mod_registration').length > 0) || ($$('.mod_lostPassword') && $$('.mod_lostPassword').length > 0) || ($$('.mod_personalData') && $$('.mod_personalData').length > 0)) {
	    /* path to a 1x1 pixel transparent gif */ 
	    cfe.spacer = "plugins/cfe/gfx/spacer.gif"; 
	    /* create a cfe replacement instance */ 
	    var myCfe = new cfe.replace(); 
	    myCfe.unregisterModule('submit');
        myCfe.unregisterModule('select');
	    /* now you may set options [see cfe.autostart.sample for details] */ 
	    /* initialize cfe */ 
	    myCfe.init({
	        //theme: "basic", currently not supported
	        scope: $('container')
	    });
	    if($$('.anketaform') && $$('.anketaform').length > 0) {
		    if($$('.anketaform .radio_container') && $$('.anketaform .radio_container')[0].getChildren('span').length > 0) {
		        for(j=0;j<$$('.anketaform .radio_container').length;j++) {
				    var anketaoptions = $$('.anketaform .radio_container')[j].getChildren('span');
				    anketaoptions[anketaoptions.length-1].setStyle('border','none');
		        }
		    }
	    }
    }
    /**end CFE-nice form Anketa**/
    /**Vstopna zadnje štiri novice**/
    if($$('#news_last_four .layout_latest h2 a') && $$('#news_last_four .layout_latest h2 a').length > 0) {
        if($$('.layout_latest .image_container') && $$('.layout_latest .image_container').length > 0){
	        var lastonepic = $$('.layout_latest .image_container')[0];
            var lastonepicOrigStyle = lastonepic.get('style');
            lastonepicOrigStyle = lastonepicOrigStyle.split(":",2)[1].replace(';','');
	        //var arrLastfournewslinks = $$('#news_last_four .layout_latest h2 a');
            var arrLastfournewsbox = $$('#news_last_four .layout_latest');
            for(var i=0;i<arrLastfournewsbox.length && arrLastfournewsbox.length>=1;i++) {
            	arrLastfournewsbox[i].addEvent('mouseover', function(e){
                	if(this.getChildren('.image_container').getChildren('img')[0]) {
					    var mypic = this.getChildren('.image_container').getChildren('img')[0][0].src;
	                    lastonepic.setStyle('background','url("'+mypic+'") no-repeat');
	                    this.setStyle('border-color','#ffea00');
                	}
			    });
            	arrLastfournewsbox[i].addEvent('mouseout', function(){//alert(lastonepicOrigStyle);
                    lastonepic.setStyle('background',lastonepicOrigStyle);
                    this.setStyle('border-color','#ffffff');
                });
            }
        }
    }
    /**end Vstopna zadnje štiri novice**/
    /**Pagina size**/
    if($$('.pagination ul') && $$('.pagination ul').length) {
	    var paginaSize = $$('.pagination ul')[0].getSize();
	    var pagesSize = $$('.pagination p')[0].getSize();
		var widthToSetCell = paginaSize.x+pagesSize.x+'px';
		$$('.cell2')[0].setStyle('width',widthToSetCell);
	}

    /**end Pagina size**/
    /**Newsletter**/
    if($$('div.mod_subscribe') && $$('div.mod_subscribe').length>0){ 
    	$$('div.mod_subscribe').position({ relativeTo: $('nlClicker'),position: 'bottomLeft',offset:{x:-190}});
		$$('div.mod_subscribe form')[0].onsubmit = function(){return false;};
		$('nllinkButton').addEvent('click', function(){
			var channelsArr = Array();
			$each($$('div.mod_subscribe input.nl_channels'),function(el){channelsArr.push(el.value);});
			if(channelsArr.length > 0) {channels = '&channels='+channelsArr.toString();}
			var mail = $$('div.mod_subscribe input.text')[0].value;
			$$('div.mod_subscribe input.text')[0].value = '';
			var myRequest = new Request.HTML({method: 'post', url: 'ajax.php', update: 'responseBox', onSuccess: function(obj){nlCallback(obj);}});
			myRequest.send('action=fmd&id=46&FORM_SUBMIT=tl_subscribe&email='+mail+channels+'&lang='+$('langsetter').value);
			return false;
		});
		new Collapsable($('nlClicker'), $$('.mod_subscribe')[0]);
	    new Collapsable($('closenewsletter'), $$('.mod_subscribe')[0]);
    }
    /**Columns same size**/
    if($('right') != null && $('main') != null) {
	    /*var mainboxy = $('main').getComputedSize().height;
	    var rightboxy = $('right').getComputedSize().height;
	    if(mainboxy > rightboxy) {
	    	$('right').setStyle('height',mainboxy);
	    }*/
    }
    /**end Columns same size**/
    /**end Newsletter**/
    if($$('div.forumbox') && $$('div.forumbox').length>0){ 
    	$$('div#content_container div.full').setStyles({'position':'relative','z-index':'9','width':'961px'});
    	if (Browser.ie6){
    		$$('div#main').setStyles({'margin-top':'-67px'});
    	}
    }
});


/**end AJAX functons calendar**/
})();

/**AJAX functons calendar**/
function initCalendar(day) {
	if(day != '') {
		day = '&day='+day;
	} else{
		day = '';
	}
	this.myRequest = new Request({method: 'get', url: 'ajax_getmethod.php', onSuccess: function(el){initCalendarOutput(el);}});
	myRequest.send('action=fmd&id=74&lang=sl'+day);
}
function initCalendarOutput(el) {
	var cal = $$('.mod_calendar')[0];
	if(cal != undefined) {
		$$('.mod_calendar')[0].innerHTML=el;
	}
}
function changeMonth(month) {
	this.myRequest = new Request({method: 'get', url: 'ajax_getmethod.php', onSuccess: function(el){changeMonthOutput(el);}});
	myRequest.send('action=fmd&id=74&lang=sl'+month);
}
function changeMonthOutput(el) {
	var cal = $$('.mod_calendar')[0];
	if(cal != undefined) {
		$$('.mod_calendar')[0].innerHTML=el;
	}
}

/**TinyMCE functions**/
/**
 * This script contains embed functions for common plugins. This scripts are complety free to use for any purpose.
 */

function writeFlash(p) {
	writeEmbed(
		'D27CDB6E-AE6D-11cf-96B8-444553540000',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'application/x-shockwave-flash',
		p
	);
}

function writeShockWave(p) {
	writeEmbed(
	'166B1BCA-3F9C-11CF-8075-444553540000',
	'http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=8,5,1,0',
	'application/x-director',
		p
	);
}

function writeQuickTime(p) {
	writeEmbed(
		'02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
		'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
		'video/quicktime',
		p
	);
}

function writeRealMedia(p) {
	writeEmbed(
		'CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA',
		'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0',
		'audio/x-pn-realaudio-plugin',
		p
	);
}

function writeWindowsMedia(p) {
	p.url = p.src;
	writeEmbed(
		'6BF52A52-394A-11D3-B153-00C04F79FAA6',
		'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701',
		'application/x-mplayer2',
		p
	);
}

function writeEmbed(cls, cb, mt, p) {
	var h = '', n;

	h += '<object classid="clsid:' + cls + '" codebase="' + cb + '"';
	h += typeof(p.id) != "undefined" ? 'id="' + p.id + '"' : '';
	h += typeof(p.name) != "undefined" ? 'name="' + p.name + '"' : '';
	h += typeof(p.width) != "undefined" ? 'width="' + p.width + '"' : '';
	h += typeof(p.height) != "undefined" ? 'height="' + p.height + '"' : '';
	h += typeof(p.align) != "undefined" ? 'align="' + p.align + '"' : '';
	h += '>';

	for (n in p)
		h += '<param name="' + n + '" value="' + p[n] + '">';

	h += '<embed type="' + mt + '"';

	for (n in p)
		h += n + '="' + p[n] + '" ';

	h += '></embed></object>';

	document.write(h);
}
/**end TinyMCE functions**/

