var _ppk_in_progress = false;

function komentari_controller( p_content_id, p_content_type )
{

    this._get_list_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_content_komentari';
    this._submit_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_content_komentari&action=komentiraj';
    this._pohvali_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_content_komentari&action=pohvali';
    this._pokudi_url = APP_REWRITE_BASE + 'index.php?cmd=ajax_content_komentari&action=pokudi';

    this._current_page = 1;
    this._current_sort = 'kronoloski';
    this._content_id = p_content_id;
    this._content_type = p_content_type;

    this.set_cookie = function( name, value, expires, path, domain, secure )
    {
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime( today.getTime() );

        /*
        if the expires variable is set, make the correct
        expires time, the current script below will set
        it for x number of days, to make it for hours,
        delete * 24, for minutes, delete * 60 * 24
        */
        if ( expires )
        {
            expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );

        document.cookie = name + "=" +escape( value ) +
            ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
            ( ( path ) ? ";path=" + path : "" ) +
            ( ( domain ) ? ";domain=" + domain : "" ) +
            ( ( secure ) ? ";secure" : "" );
    }
    
    this.get_cookie = function( name ) {

        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )  { return null; }
        if ( start == -1 ) return null;
        
        var end = document.cookie.indexOf( ";", len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }
    
    this._set_initial_cookie = function (p_komentar_id) {
	var _cookie_name = 'VECERNJIkomentar'+p_komentar_id;
	var _cookie = this.get_cookie(_cookie_name);
	if (_cookie == null) {
	    this.set_cookie(_cookie_name, '0', false, '/');
	}
    }
    
    this.get_list = function()
    {
        var _url = this._get_list_url + '&content_id=' + this._content_id + '&content_type=' + this._content_type + '&page=' + this._current_page + '&sort=' + this._current_sort;

        var _current_sort = this._current_sort;
        
        $( '#div_komentari_list').hide();
        $( '#div_komentari_spinner').show();

        $( '#div_komentari_list').load( _url, function()
        {
            $( '#div_komentari_spinner').hide();
            $( '#div_komentari_list').show();

            if( _current_sort == 'kronoloski' ){
                $( '#link_komentar_sort_kronoloski' ).css( 'font-weight', 'bold' );
				$( '#link_komentar_sort_kronoloski' ).css( 'color', '#000000' );
                $( '#link_komentar_sort_popularnost' ).css( 'font-weight', 'bold' );
            }
            if( _current_sort == 'popularnost' ){
                $( '#link_komentar_sort_kronoloski' ).css( 'font-weight', 'bold' );
                $( '#link_komentar_sort_popularnost' ).css( 'font-weight', 'bold' );
		$( '#link_komentar_sort_popularnost' ).css( 'color', '#000000' );
            }
            
        }
        )
    };

    this.submit = function()
    {
        var _tekst = $( '#id_komentar_tekst' ).val();
        var _url = this._submit_url + '&content_id=' + this._content_id + '&content_type=' + this._content_type + '&komentar_tekst=' + encodeURIComponent( _tekst );

        if( _tekst != '' ){
            $.get( _url );

            $( '#id_komentar_tekst' ).val( '' );
            
            this._current_page = 1;
            this.get_list();
        }
    };

    this.slijedeca_stranica = function()
    {
        this._current_page ++;
        this.get_list();
    }

    this.prethodna_stranica = function()
    {
        this._current_page --;
        this.get_list();
    }

    this.pohvali = function( p_komentar_id )
    {
	$( '#span_komentar_ocjena_toolbar_' + p_komentar_id).fadeOut( 50 );

	if (!_ppk_in_progress) {

	    _ppk_in_progress = true;
	    this._set_initial_cookie(p_komentar_id);

	    var _url = this._pohvali_url + '&komentar_id=' + p_komentar_id;

	    $.get( _url, function( data ){
	        
	        if( data.substring(0,3) == 'OK:' ){

	            var _ocjena = parseInt( data.substring( 3, data.length ) );

	            $( '#span_komentar_ukupna_ocjena_' + p_komentar_id).text( _ocjena );
    
	        } else {
	            $( '#span_komentar_ocjena_toolbar_' + p_komentar_id).fadeIn( 50 );
		}
	        window.setTimeout('_ppk_in_progress = false;',50);
	    });
	}
    }

    this.pokudi = function( p_komentar_id )
    {
	$( '#span_komentar_ocjena_toolbar_' + p_komentar_id).fadeOut( 50 );

	if (!_ppk_in_progress) {

	    _ppk_in_progress = true;
	    this._set_initial_cookie(p_komentar_id);

	    var _url = this._pokudi_url + '&komentar_id=' + p_komentar_id;

	    $.get( _url, function( data ){
	        if( data.substring(0,3) == 'OK:' ){

	            var _ocjena = parseInt( data.substring( 3, data.length ) );

	            $( '#span_komentar_ukupna_ocjena_' + p_komentar_id).text( _ocjena );
	            //$( '#span_komentar_ocjena_toolbar_' + p_komentar_id).html('OCJENA:<br /><span class="komentar_ocjena">'+_ocjena+'</span>');
		} else {
	            $( '#span_komentar_ocjena_toolbar_' + p_komentar_id).fadeIn( 50 );
		}
	        window.setTimeout('_ppk_in_progress = false;',50);
	    });
	}
    }


    this.sort = function( p_sort )
    {
        this._current_sort = p_sort;
        this._current_page = 1;

        this.get_list();
    }

}


function fw3k_thumb_gallery( p_arr_entiteti, p_thumb_variation, p_thumbs_per_page, p_url_target, p_id_suff, p_app_rewrite_base, p_use_additional_overlay, p_use_hover_thumb )
{
    if(p_arr_entiteti.length == 0) return false;

    var SLIKA_ID = 0;
    var ENTITET_OPIS = 1;
    var URL = 2;

    this._arr_entiteti = p_arr_entiteti;

    this._current_page = 1;
    this._current_index = 0;

    this._total_pages = 1;
    this._thumbs_per_page = p_thumbs_per_page;

    this._id_suff = p_id_suff;

    this._url_target = p_url_target;
    this._thumb_variation = p_thumb_variation;

    this._fade_inout = true;

    this._app_rewrite_base = p_app_rewrite_base;

    this._use_additional_overlay = p_use_additional_overlay;

    this._use_hover_thumb = p_use_hover_thumb;
    
    this._init = function()
    {
        this._total_pages = Math.ceil( this._arr_entiteti.length / this._thumbs_per_page);
        this.show_thumbs();

        this.show( 0 );
    }

    this.show_thumbs = function()
    {
        var _obj_instance = this;
        var _thumb_variation = this._thumb_variation;
        var _id_suff = this._id_suff;

        var _app_rewrite_base = this._app_rewrite_base;

        for ( index = 0; index < this._thumbs_per_page; index++ ){

            var _current_abs_index = this._get_absolute_index( index, this );

            if( _current_abs_index <= this._arr_entiteti.length -1 ){

                var thumb_el = document.getElementById( 'galerija_thumb_' + (index + 1) + '_' + _id_suff );

                $('#galerija_thumb_' + (index + 1) + '_' + _id_suff).hide();

                var _index = parseInt( thumb_el.id.substr( 'galerija_thumb_'.length, thumb_el.id.length - 'galerija_thumb_'.length - _id_suff.length - 1 ) );
                var _abs_index = parseInt( _obj_instance._get_absolute_index( ( _index - 1 ), _obj_instance ) );
                var arr_entitet = _obj_instance._arr_entiteti[ _abs_index ];

                $('#galerija_spinner_' + (_index ) + '_' + _id_suff).show();                

                if( typeof( arr_entitet ) != 'undefined' ){
                    
                    var _url = arr_entitet[ URL ];

                    var _slika_id = arr_entitet[ SLIKA_ID ];
                    var _opis = arr_entitet[ ENTITET_OPIS ];

                    var _galerija_thumb_id = '#galerija_thumb_' + _index + '_' + _id_suff;
                    var _galerija_caption_id = '#galerija_caption_' + _index + '_' + _id_suff;

                    
                    _html_slika = '<a href="' + _url +'"><img src="' + _app_rewrite_base + 'fw3k/util_scripts/get_slika_varijacija.php?slika_id=' + _slika_id + '&amp;var_suff=' + _thumb_variation + '" onload="javascript:obj_gallery_' + _id_suff + '.hide_spinner(' + _index + ')" border="0" />';

                    if (this._use_additional_overlay) {
                        _html_slika += '<span class="photogallery_name_container"><div class="photogallery_overlay"></div><h4>' + _opis + '</h4></span>';
                    }
                    _html_slika += '</a>';
                    _html_caption = '<a href="' + _url +'">' + _opis + '</a>';

                    $( _galerija_thumb_id ).html( _html_slika );
                    $( _galerija_caption_id ).html( _html_caption );

                    
                    if (this._use_hover_thumb /*&& !($.browser.msie && $.browser.version=='6.0')*/) {
                    	this.set_img_hover(_galerija_thumb_id, _slika_id);
                    }

                    if( $.browser.opera ){
                        _obj_instance.hide_spinner(_index);
                    }
                }
            } else {
                // prikazi prazan thumb
                $( '#galerija_thumb_' + (index + 1) + '_' + this._id_suff ).html( '&nbsp;' );
                $( '#galerija_caption_' + (index + 1) + '_' + this._id_suff ).html( '&nbsp' );
            }
        }

    }

    this.set_img_hover = function (parent, slika_id)
    {
    	var _app_rewrite_base = this._app_rewrite_base;
    	
    	var parent_cont = $(parent);

    	var img_src = _app_rewrite_base + 'fw3k/util_scripts/get_slika_varijacija.php?slika_id=' + slika_id + '&var_suff=';
    	
    	var preload_img = new Image();
    	preload_img.src = img_src + '190x125';
    	
    	var a    = parent_cont.find('a');
    	var img  = a.find('img');
    	var span = a.find('span.photogallery_name_container');

    	var _img;
    	a.hover(function() {
    		img.css({
    			width: '190px',
    			height: '125px'
			}).attr('src', img_src +  '190x125');
    		parent_cont.css({'z-index': '1000'});
    		a.css({
    			position: 'absolute',
    			'z-index': '1000',
    			top: '-40px',
    			left: '-55px',
    			width: '190px',
    			height: '125px',
    			display: 'block'
    		});
    		a.addClass('frame');
    		span.css('display', 'block');
    	}, function() {
    		a.removeClass('frame');
    		img.css({
				width: '83px',
				height: '54px'
			});
    		img.attr('src', img_src  + '83x54');
    		span.css('display', 'none');
    		parent_cont.css({'z-index': '50'});
    		a.css({
    			position: 'relative',
    			'z-index': '50',
				top: '0',
    			left: '0',
    			width: '83px',
    			height: '54px'
    		});
		});
    }

    this.show = function( p_index )
    {
        // evenutalno promijeni klasu trenutno aktivnog thumba
    }

    this.next = function()
    {
        if( this._get_absolute_index( this._current_index ) < (this._arr_entiteti.length - 1) ){
            this._current_index ++;

            // ako prelazimo na slijedecu stranicu
            if( this._current_index > this._thumbs_per_page - 1 ){
                this._current_index = 0;
                this._current_page++;

                this.show_thumbs();
            }

            this.show( this._current_index );
        }
    }

    this.hide_spinner = function( p_index )
    {
        //alert( 'pozvan' );
        var _galerija_thumb_id = '#galerija_thumb_' + p_index + '_' + this._id_suff;
        $( _galerija_thumb_id ).show();
        $( '#galerija_spinner_' + (p_index ) + '_' + this._id_suff ).hide();
    }

    this.prev = function()
    {
        if( this._get_absolute_index( this._current_index ) > 0 ){
            this._current_index --;

            // ako prelazimo na prethodnu stranicu
            if( this._current_index < 0){
                this._current_index = this._thumbs_per_page - 1;
                this._current_page--;

                this.show_thumbs();
            }

            this.show( this._current_index );
        }
    }

    this.next_page = function()
    {
        if( this._current_page < this._total_pages ){
            this._current_page ++;
            this._current_index = 0;

            this.show_thumbs();
            //this.show( this._current_index );
        }
    }

    this.prev_page = function()
    {
        if( this._current_page > 1 ){
            this._current_page --;
            this._current_index = this._thumbs_per_page - 1;

            this.show_thumbs();
            //this.show( this._current_index );
        }
    }

    // index je zero based
    this._get_absolute_index = function( p_index, p_obj_instance )
    {
        return (p_obj_instance._current_page - 1) * p_obj_instance._thumbs_per_page + p_index;
    }

    if( typeof( this._app_rewrite_base ) == 'undefined' ){
        this._app_rewrite_base = '';
    }

    if( typeof( this._use_additional_overlay ) == 'undefined' ){
        this._use_additional_overlay = true;
    }

    if( typeof( this._use_hover_thumb ) == 'undefined' ){
        this._use_hover_thumb = false;
    }

    this._init();
}


function fw3k_anketa_controller( p_anketa_id, p_app_rewrite_base, p_answer_count )
{

    this._anketa_id = p_anketa_id;
    this._app_rewrite_base = p_app_rewrite_base;
    this._url = p_app_rewrite_base + (window.location.href.indexOf('/sport/')>-1 ? 'sport/' : '') +'index.php?cmd=show_anketa&anketa_id=' + p_anketa_id;
    this._window_parameters = 'width=640, height=480, scrollbars=yes';
    this.additional_parameters = '';
	this._answer_count = parseInt( p_answer_count );

    this.set_cookie = function( name, value, expires, path, domain, secure )
    {
        // set time, it's in milliseconds
        var today = new Date();
        today.setTime( today.getTime() );

        /*
        if the expires variable is set, make the correct
        expires time, the current script below will set
        it for x number of days, to make it for hours,
        delete * 24, for minutes, delete * 60 * 24
        */
        if ( expires )
        {
            expires = expires * 1000 * 60 * 60 * 24;
        }
        var expires_date = new Date( today.getTime() + (expires) );

        document.cookie = name + "=" +escape( value ) +
            ( ( expires ) ? ";expires=" + expires_date.toGMTString() : "" ) +
            ( ( path ) ? ";path=" + path : "" ) +
            ( ( domain ) ? ";domain=" + domain : "" ) +
            ( ( secure ) ? ";secure" : "" );
    }

    this.get_cookie = function( name ) {

        var start = document.cookie.indexOf( name + "=" );
        var len = start + name.length + 1;
        if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) )  { return null; }
        if ( start == -1 ) return null;

        var end = document.cookie.indexOf( ";", len );
        if ( end == -1 ) end = document.cookie.length;
        return unescape( document.cookie.substring( len, end ) );
    }



    this.glasaj = function()
    {
        var _input_name = 'anketa_' + this._anketa_id;

        var _cookie = 'VECERNJI_aodg_'+this._anketa_id;
        var _cookie_val = this.get_cookie(_cookie);
        if (_cookie_val == null) {
            this.set_cookie(_cookie, 0, false, '/');
        }

        var _odgovor_id = $( "input[@name='" + _input_name + "']:checked" ).val();

        if( typeof( _odgovor_id ) != 'undefined' ){
            if( typeof( document.getElementById( 'float_anketa' ) ) != 'undefined' ){
                $( '#float_overlay' ).show();
                $( '#float_spinner' ).show();
                $( '#float_anketa' ).hide();

                $( '#float_anketa' ).load( this._url + '&action=odgovori&odgovor_id=' + _odgovor_id + this.additional_parameters, '', function()
                {
                    $( '#float_overlay' ).show();
					$( '#float_spinner' ).hide();
                    $( '#float_anketa' ).show();
                }
                );

            } else {
                var obj_win = window.open( this._url + '&action=odgovori&odgovor_id=' + _odgovor_id + this.additional_parameters, 'obj_win', this._window_parameters );
            }
        }
    };

	this.ocjeni = function()
	{
        var _form_name = 'forma_anketa_' + this._anketa_id;

        var _cookie = 'VECERNJI_aodg_'+this._anketa_id;
        var _cookie_val = this.get_cookie(_cookie);
        if (_cookie_val == null) {
            this.set_cookie(_cookie, 0, false, '/');
        }

		var $form = $('#'+_form_name);
		var inputs = $( '#'+_form_name+' input:radio:checked' )
		var select_count =  inputs.length;

		// imamo sve odgovore
		if ( ( select_count > 0 ) && ( select_count == this._answer_count ) )
		{
			// kreiranje querystringa sa odgovorima
			var arr = [];
			$.each(inputs, function(idx,value)
				{
					odgovor_id = $(value).attr('rel');
					var odg = 'o['+odgovor_id+']='+$(value).val();
					arr.push( odg );

				}
			);

			var odg_qstr = arr.join('&');

			var _url = this._url + '&action=ocjeni&'+odg_qstr;

			if( typeof( document.getElementById( 'float_anketa' ) ) != 'undefined' )
			{
                $( '#float_overlay' ).show();
                $( '#float_spinner' ).show();
                $( '#float_anketa' ).hide();

                $( '#float_anketa' ).load(_url, null, function()
					{
					    $( '#float_overlay' ).show();
						$( '#float_spinner' ).hide();
					    $( '#float_anketa' ).show();
					}
                );

			} else {
                var obj_win = window.open( _url, 'obj_win', this._window_parameters );
			}
		}


	}

	this.captcha_glasaj = function() {
		var _input_name= 'anketa_' + this._anketa_id;

        var _cookie = 'VECERNJI_aodg_'+this._anketa_id;
        var _cookie_val = this.get_cookie(_cookie);
        if (_cookie_val == null) {
            this.set_cookie(_cookie, 0, false, '/');
        }

        var _odgovor_id   = $( "form#captcha input[@name='" + _input_name + "']:checked" ).val();
		var _captcha_hash = $( "form#captcha #captcha_hash").val();
		var _captcha_str  = escape($( "form#captcha #captcha").val());

        if( typeof( _odgovor_id ) != 'undefined' ){
            if( typeof( document.getElementById( 'float_anketa' ) ) != 'undefined' ){
                $( '#float_overlay' ).show();
                $( '#float_spinner' ).show();
                $( '#float_anketa' ).hide();

                $( '#float_anketa' ).load( this._url + '&action=odgovori&captcha=true&captcha_str=' + _captcha_str + '&captcha_hash=' + _captcha_hash + '&odgovor_id=' + _odgovor_id + this.additional_parameters, '', function()
                {
					$( '#float_overlay' ).show();
					$( '#float_spinner' ).hide();
                    $( '#float_anketa' ).show();
                }
                );

            } else {
                var obj_win = window.open( this._url + '&action=odgovori&odgovor_id=' + _odgovor_id + this.additional_parameters, 'obj_win', this._window_parameters );
            }
        }
	}

    this.rezultati = function()
    {
        if( typeof( document.getElementById( 'float_anketa' ) ) != 'undefined' ){
            $( '#float_overlay' ).show();
            $( '#float_spinner' ).show();
            $( '#float_anketa' ).hide();
            $( '#float_anketa' ).load( this._url + this.additional_parameters, '', function()
            {
                $( '#float_spinner' ).hide();
                $( '#float_anketa' ).show();
            }
            );

        } else {
            var obj_win = window.open( this._url + this.additional_parameters, 'obj_win', this._window_parameters );
        }
    };

    fw3k_anketa_controller.close = function()
    {
        $( '#float_overlay' ).hide();
        $( '#float_anketa' ).hide();
    }

}


function linked_columns_height() {
    var elm1 = document.getElementById("linked_news_column");
    var elm2 = document.getElementById("about_topic_column");

    if (elm1 != null && elm2 != null ) {

        var colHeight = new Array(2);
        colHeight[0] = elm1.offsetHeight + 35;
        colHeight[1] = elm2.offsetHeight + 35;

        if (colHeight[0] > colHeight[1]) {
            elm1.style.height = colHeight[0] + "px";
            elm2.style.height = colHeight[0] + "px";
        } else {
            elm1.style.height = colHeight[1] + "px";
            elm2.style.height = colHeight[1] + "px";
        }
    }
}

function vecernji_fm_popup()
{
    window.open ("http://media.vecernji-list.hr/vecernji.fm/player.html","mywindow","location=0,status=1,scrollbars=0,width=488,height=190");
}

function main_picture_caption_height() {
    /*var el1 = document.getElementById("main_canvas_caption_picture");
    var el2 = document.getElementById("main_canvas_caption_overlay");
    
    if(  el1 != null && el2 != null ){
        colLength = new Array(1);
        colLength[0] = el1.offsetHeight + 10;
        el2.style.height = colLength[0] + "px";
    }*/
    
    var galerije = $('div.clanak_gallery');
    galerije.each(function(i) {
        var g = galerije[i];
        var divz = g.getElementsByTagName('div');
        var h = divz[1].offsetHeight + 10;
        divz[0].style.height = h + "px";
    });
}

function fbs_click()
{
	u=location.href;
	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;
}

function GetThis(T, C, U, L)
{
	var targetUrl = 'http://www.myspace.com/Modules/PostTo/Pages/?' + 't=' + encodeURIComponent(T) + '&c=' + encodeURIComponent(C) + '&u=' + encodeURIComponent(U) + '&l=' + L;
	window.open(targetUrl);
}

function CroportalAdd(URL, TITLE, ABSTRACT, CATEGORY)
{
	var targetUrl = 'http://www.croportal.net/submit?url=' + encodeURIComponent(URL) + '&title=' + encodeURIComponent(TITLE) + '&abstract=' + encodeURIComponent(ABSTRACT) + '&category=' + encodeURIComponent(CATEGORY);
	window.open(targetUrl);
}

function TwitterAdd(URL)
{
	var targetUrl = 'http://twitter.com/home?status=Trenutno citam ' + encodeURIComponent(URL);
	window.open(targetUrl);
}

function DiggAdd(URL)
{
	var targetUrl = 'http://digg.com/submit?phase=2&url=http://' + encodeURIComponent(URL);
	window.open(targetUrl);
}

jQuery(document).ready(function()
{
    if( typeof( jQuery("#breadCrumb").jBreadCrumb ) != 'undefined' ){
        jQuery("#breadCrumb").jBreadCrumb();
    }
    
    var foto_sub = jQuery("#main_content div.fotogaleries_sub1");
    var video_sub = jQuery("#main_content div.videos_sub1");

    // fix z-indexa za fotogalerije kada se nađu jedna do druge
    if (jQuery.browser.msie && (jQuery.browser.version == '6.0' || jQuery.browser.version == '7.0')) {
	    if (typeof(foto_sub) != 'undefined' && typeof(video_sub) != 'undefined') {
	    	foto_sub.mouseover(function(){
	    		foto_sub.css({'z-index': 60});
	    		video_sub.css({'z-index': 50});
	    	});
	    	video_sub.mouseover(function(){
	    		video_sub.css({'z-index': 60});
	    		foto_sub.css({'z-index': 50});
	    	});
	    }
    }
})

function prikazi_quick()
{
    var d_down = document.getElementById("quick_dd");
    if(d_down.style.left == -999 + "em")
    {
        d_down.style.left = "";
    } else {
        d_down.style.left = -999 + "em" ;
    }
}

function vecernji_fm_popup()
{
    window.open ("http://media.vecernji-list.hr/vecernji.fm/player.html","mywindow","location=0,status=1,scrollbars=0,width=488,height=190");
}


function show_hide_list(t)
{
    if ( !$(t).hasClass('active') ){
        $(t).parent().children("ul").slideUp(400);
        $(t).parent().children("div#fondw").slideUp(400);
        $(t).parent().children("div#burzew").slideUp(400);
        $(t).parent().children("div.tbl").slideUp(400);
        $(t).parent().children().removeClass("active");
        $(t).parent().children().addClass("inactive_h");
        
		$(t).next("ul").slideDown(400);
        $(t).next("div#fondw").slideDown(400);
        $(t).next("div#burzew").slideDown(400);
        $(t).next("div.tbl").slideDown(400);
        $(t).removeClass("inactive_h");
        $(t).addClass("active");
    }
}


$().ready(function()
{
    if( typeof( obj_glavni_sadrzaj ) != 'undefined' ){
        obj_glavni_sadrzaj.start_slideshow();
    }

    $('#ex3a').jqm({
        trigger: '#ex3aTrigger',
        overlay: 50,
        overlayClass: 'whiteOverlay'});


        $('input.jqmdX')
        .hover(
        function(){ $(this).addClass('jqmdXFocus'); },
        function(){ $(this).removeClass('jqmdXFocus'); })
        .focus(
        function(){ this.hideFocus=true; $(this).addClass('jqmdXFocus'); })
        .blur(
        function(){ $(this).removeClass('jqmdXFocus'); });

}
);

sfHover = function() {
    var sfEls = document.getElementById("nav").getElementsByTagName("LI");
    for (var i=0; i<sfEls.length; i++) {
        sfEls[i].onmouseover=function() {
            this.className+=" sfhover";
        }
        sfEls[i].onmouseout=function() {
            this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
        }
    }
}
if (window.attachEvent) window.attachEvent("onload", sfHover);


