$(document).ready(function() {

    /*Ballloto*/
    if($('#balloto_ajax_id').length){
        var b_ajax_funkc = setInterval(ballloto_refresh_bids, 25000);
      
    }
        
    /*POPUPU pozicijos fixas*/
    call_error_report_pop = function(){
        obj = $('div.popup_layer');
        gor_position = -((obj.width())/2);
        vert_position = -((obj.height())/2);
        margin_value = ''+ vert_position +'px 0 0 '+ gor_position +'px';
        //$(this).append('<div onclick="remove_popups()" class="TB_overlayBG" id="TB_overlay"></div>');
        $(obj).css({
            margin: margin_value
        }, $(obj).show().css('visibility','visible'));
    };
    call_error_report_pop();
	
    /*Kvieciam nauja popupa*/
    call_new_popup = function(popup_title, popup_content){
        $('body').append('<div onclick="remove_popups()" class="TB_overlayBG" id="TB_overlay"></div>');
        $('<div class="popup_layer dinamic_popup_layer"><table cellspacing="0" cellpadding="0" border="0"><tr><td><div class="pop_top_dec"><div></div><span></span></div></td></tr><tr><td width="356"><div class="pop_cont"><div class="pop_cont_content"><h2 class="titlus"><span onclick="remove_popups()" class="close"></span>' + popup_title + '</h2>' + popup_content + '</div></div></td></tr><tr><td><div class="pop_bottom_dec"><div></div><span></span></div></td></tr></table></div>').appendTo('body'), call_error_report_pop()
        };
	
    /*Kvieciam nauja error popupa*/
    call_new_error_popup = function(popup_title, popup_content){
        $('body').append('<div onclick="remove_popups()" class="TB_overlayBG" id="TB_overlay"></div>');
        $('<div class="popup_layer popup_error_layer dinamic_popup_layer"><table cellspacing="0" cellpadding="0" border="0"><tr><td><div class="pop_top_dec"><div></div><span></span></div></td></tr><tr><td width="356"><div class="pop_cont"><div class="pop_cont_content"><h2 class="titlus"><span onclick="remove_popups()" class="close"></span>' + popup_title + '</h2>' + popup_content + '</div></div></td></tr><tr><td><div class="pop_bottom_dec"><div></div><span></span></div></td></tr></table></div>').appendTo('body'), call_error_report_pop()
        };
	
    /*Kvieciam nauja sessijos pabaigimo popupa*/
    call_session_popup = function(){
        var options = {
            type: 'POST',
            url: '/session.php',
            dataType: 'json',
            data: {},
            success: function(data) {
                if (data == 0) {
                    if ($('#session_timeout_popup').html() == null) {
                        $('body').append('<div onclick="location.reload();" class="TB_overlayBG" id="TB_overlay"></div>');
                        $('<div id="session_timeout_popup" class="popup_layer popup_error_layer dinamic_popup_layer"><table cellspacing="0" cellpadding="0" border="0"><tr><td><div class="pop_top_dec"><div></div><span></span></div></td></tr><tr><td width="356"><div class="pop_cont"><div class="pop_cont_content"><h2 class="titlus"><span onclick="location.reload()" class="close"></span>' + translation_popup_message + '</h2>' + translation_popup_session_expired + '<div class="border_decor_1"></div><a href="javascript:location.reload();" class="button_4 button_4_momrg" style="padding-right:10px;"><span>' + translation_popup_ok + '</span></a></div></div></td></tr><tr><td><div class="pop_bottom_dec"><div></div><span></span></div></td></tr></table></div>').appendTo('body'), call_error_report_pop();
                    }
                }
            }
        }
        $.ajax(options);
    };
		        
    $('div.content_filter_1 .caller').bind('click', function(){
        $(this).toggleClass('content_filter_1_opened').parent('div.content_filter_1').children('div.content_filter_cont').toggle();
    });
	
    $('div.slider_orders a.button_5').live('click', function(){
        $(this).toggleClass('button_5_opened').parent('div.slider_orders').children('table.grid_1').toggle();
    });
	
    $('div.maps_blockus').height($('ul.cities_list').height());
		
    /*LOGINAI*/
    $('a.call_login').live('click', function(){
        $('div.user_zone_layout').hide();
        $('div.login_form_block').show();
        $('a.register_opened').removeClass('button_1_opened').removeClass('register_opened').addClass('call_registration');
        $(this).toggleClass('button_1_opened').addClass('login_opened').removeClass('call_login')

        //initialize login step
        user_login_step = 1;

        if(readCookie('punbb_cookie'))
        {
            $('#user_login_username').val('');
            $('#user_login_remember_me').attr('checked', true);
            user_login();
        }
    });
	
    $('a.login_opened').live('click', function(){
        $(this).removeClass('button_1_opened').removeClass('login_opened').addClass('call_login');
        $('div.user_zone_layout').hide();
    });
	
    $('a.call_registration').live('click', function(){
        $('div.user_zone_layout').hide();
        $('div.register_form_block').show();
        $('a.login_opened').removeClass('button_1_opened').removeClass('login_opened').addClass('call_login');
        $(this).toggleClass('button_1_opened').addClass('register_opened').removeClass('call_registration')
    });
	
    $('a.register_opened').live('click', function(){
        $(this).removeClass('button_1_opened').removeClass('register_opened').addClass('call_registration');
        $('div.user_zone_layout').hide();
    });
	
    //$('#login_form').validate();
    //$('#registration_form').validate();
	
	
    /*POPUPAI*/
	
    remove_popups = function(){
        $('#TB_overlay').remove();
        $('.dinamic_popup_layer').remove();
        $('.popup_layer').hide();
    }
	
    $('.tumtutmtj').live('click', function(){
        $('div.laytout_h_fix').animate({
            height: 169
        }, 500);
		
        $(this).removeClass('tumtutmtj').addClass('tumtutmtj_2');
        $('body').animate(
        {
            backgroundPosition:"0 169px"
        }, 

        {
            duration:500
        });
        $('body').css( {
            backgroundPosition: "0 69px"
        } );
    });
	
    $('.tumtutmtj_2').live('click', function(){
        $('div.laytout_h_fix').animate({
            height: 69
        }, 500);
		
        $(this).removeClass('tumtutmtj_2').addClass('tumtutmtj');
        $('body').animate(
        {
            backgroundPosition:"0 69px"
        }, 

        {
            duration:500
        });
        $('body').css( {
            backgroundPosition: "0 169px"
        } );
    });
	
    $('div.link_kontainer_2').live('click', function(){
        $(this).toggleClass('link_kontainer_2_opened')
        .parent('.result_view_block')
        .toggleClass('nomarg')
        .children('.result_content_lay')
        .toggle()
    });
	
    $('div.link_kontainer').live('click', function(){
        //console.log($(this).parent().parent().parent().parent().parent('.result_view_block').children('.slider_orders'));
        $(this).toggleClass('link_kontainer_opened')
        .parent().parent().parent().parent().parent().parent('.result_view_block')
        .toggleClass('nomarg')
        .children('.tab_content_layout')
        .children('.slider_orders')
        .toggle();

        link = $(this);

        $(this).parent().parent().parent().parent().nextAll('.slider_orders').each(function() {
            if ( ! $(this).is(":visible") && link.hasClass('link_kontainer_opened') ) {
                $(this).toggle();
            } 
        });

    });
	
    /*BETTING TOOLTIPS*/
	
    function simple_tooltip(target_items, name){
        $(target_items).each(function(i){
            if($.browser.msie){
                var tooltp_caller_height = ($(this).parent('div').height() - 9);
            }else{
                var tooltp_caller_height = ($(this).parent('div').height() - 9);
            }
            $(this).children('span.betting_groups').height(tooltp_caller_height).append("<span class='tool_tip_content ' id='"+name+i+"'><p>"+$(this).attr('rel')+"</p></span>");
            var my_tooltip = $("#"+name+i);
        });
    };
	
    simple_tooltip("span.addus","betting_tooltip");
	
    var Timer = [];
    $('.betting_tooltip').hover(
        function () {  
            var id = jQuery.data( this );  
            var $this = $( this );  
            Timer[id] = setTimeout( function() {  
                $this.children('.betting_groups').children('.tool_tip_content').show();
                Timer[id] = "";  
            }, 1000 );  
        }, function () {  
            var id = jQuery.data( this );  
            var $this = $( this );
            if ( Timer[id] != "" ) {  
                clearTimeout( Timer[id] );  
            } else {  
                $this.children('.betting_groups').children('.tool_tip_content').hide();	
            }  
        }  
        )
	
    $('.img_tooltip').hover(
        function () {  
            var id = jQuery.data( this );  
            var $this = $( this );  
            $this.next().children('.tool_tip_content').show();
        }, function () {  
            var id = jQuery.data( this );  
            var $this = $( this ); 
            $this.next().children('.tool_tip_content').hide();	
        }  
        )

    $('.sidebar_offer_categories_checkbox_other').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked == 0){
            $(this).parent('li').parent('ul').parent('li').find('.sidebar_offer_main_categories_checkbox_other').attr('checked', false);
        }
    });
	
    $('.sidebar_offer_main_categories_checkbox_other').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked){
            $(this).parent('li').find('.sidebar_offer_categories_checkbox_other').attr('checked', true);
        } else {
            $(this).parent('li').find('.sidebar_offer_categories_checkbox_other').attr('checked', false);
        }
    });
	
    $('.sidebar_offer_categories_checkbox').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked == 0){
            $(this).parent('li').parent('ul').parent('li').find('.sidebar_offer_main_categories_checkbox').attr('checked', false);
        }
    });
	
    $('.sidebar_offer_main_categories_checkbox').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked){
            $(this).parent('li').find('.sidebar_offer_categories_checkbox').attr('checked', true);
        } else {
            $(this).parent('li').find('.sidebar_offer_categories_checkbox').attr('checked', false);
        }
    });

    $('.sidebar_offer_spec_categories_checkbox').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked == 0){
            $(this).parent('li').parent('ul').parent('li').find('.sidebar_offer_spec_main_categories_checkbox').attr('checked', false);
        }
    });
	
    $('.sidebar_offer_spec_main_categories_checkbox').bind('click', function(){
        var checked = $(this).attr('checked');
        if(checked){
            $(this).parent('li').find('.sidebar_offer_spec_categories_checkbox').attr('checked', true);
        } else {
            $(this).parent('li').find('.sidebar_offer_spec_categories_checkbox').attr('checked', false);
        }
    });

    $('.registration_agreement_type').bind('click', function(){
        var sel = $(this).val();
        if (sel == 0) $('select[name="place"]').removeAttr("disabled");
        else $('select[name="place"]').attr("disabled","disabled");
    });
	
    $('.sidebar_period_radio').bind('click', function(){
        var times = $(this).val().split(';');
        if (times[0] != undefined)
            $('#formFrom').val(times[0]);
        if (times[1] != undefined)
            $('#formTill').val(times[1]);
		
        var isCommingManualSelected = false;
		
        $('.sidebar_offer_categories_checkbox').each(function()
        {
            if ($(this).attr('checked')) isCommingManualSelected = true;
        });
		
        if (isCommingManualSelected == false)
        {
            $('.sidebar_offer_main_categories_checkbox').each(function()
            {
                if ($(this).attr('checked', true));
            });
			
            $('.sidebar_offer_categories_checkbox').each(function()
            {
                if ($(this).attr('checked', true));
            });
        }
		
    });
	
	
	
//$(function(o){	
//		o = $(".orders_list").height($(window).height() - 250).overscroll({
//			onDriftEnd: function() {
//				//console.log("done!");
//			},
//			cancelOn: '.no-drag',
//			showThumbs: true
//		});
//	});
	
});

widget_legue_comming_list_event_expand = function(value)
{
    $(".slider_orders").find('a').each(function()
    {
        $(this).removeClass('button_5_opened').parent('div.slider_orders').children('table.grid_1').hide();
    });

    $(".event_checkbox_kontainer").find('input:checkbox').each(function()
    {
        var checked = $(this).attr('checked');
        if(checked){
            var obj = $('div[id^="slider_orders_'+$(this).val()+'"]');
            obj.children('a.button_5').addClass('button_5_opened');
            obj.children('table.grid_1').show();
        }
    });
}

change_text_focus = function(obj, text)
{
    if($(obj).val() == text)
    {
        $(obj).val('');
    }
} 

change_text_blur = function(obj, text)
{
    if($(obj).val() == '')
    {
        $(obj).val(text);
    }
}

invert_big_page = function(){
    var browser_window_width_resize = (window.innerWidth ? window.innerWidth : (document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body.offsetWidth));
    if ((browser_window_width_resize>=1279))
    {
        $(document).ready(function() { 
            $('body').addClass('big');
        });
    }
    else
    {
        $('body').removeClass('big');
    }
}

sidebar_offer_categories_select = function(value)
{
    $('.sidebar_offer_categories_checkbox').attr('checked', value);
	
}



widget_user_past_bids_expand = function(card_id, event_count)
{
    var status = $('.row_hidden_' + card_id).css('display');
    if (status == 'none')
    {
        $('.img_span_' + card_id).attr('src', "/public/images/icons/ico_18.png");
        $('.row_hidden_' + card_id).show();
        $('.row_span_' + card_id).attr('rowspan', event_count);
        $('.row_expand_button_' + card_id).hide();
    }
    else
    {
        $('.img_span_' + card_id).attr('src', "/public/images/icons/ico_17.png");
        $('.row_hidden_' + card_id).hide();
        $('.row_span_' + card_id).attr('rowspan', 1);
        $('.row_expand_button_' + card_id).show();
    }
}

show_add_info_basic = function(name, status, link_name)
{
	$('tr').nextAll(link_name).each(function() {
		if ( $(this).hasClass(name) ) {
		//if ( $(this).is("#ev_tr_"+name) ) {
			if (status == 'none')
				$(this).show();
			else
				$(this).hide();
		} 
	});
}

show_add_info = function(name, status)
{
	if (status == null) status = $("#ev_tr_"+name).css('display');
    var my_buttom = $("#button_"+name);
	if (status == 'none')
		my_buttom.attr('src', "/public/images/icons/ico_18.png");
	else
		my_buttom.attr('src', "/public/images/icons/ico_17.png");
	show_add_info_basic (name, status, '.link_kontainer_2');
	show_add_info_basic (name, status, '.link_kontainer_3');
}

betting_description = function()
{
    var status = $('.row_hidden_description').css('display');
    if (status == 'none')
    {
        $('.img_span_description').attr('src', "/public/images/icons/ico_18.png");
        $('.row_hidden_description').show();
        $('.row_expand_button_description').hide();
    }
    else
    {
        $('.img_span_description').attr('src', "/public/images/icons/ico_17.png");
        $('.row_hidden_description').hide();
        $('.row_expand_button_description').show();
    }
}

user_login = function()
{
    var h = $('#login_form').height();
    $('#login_form').hide();
    $('#login_preloader').height(h);
    $('#login_preloader .valign_container').css('padding-top', (h/2 -45) + 'px' );
    $('#login_preloader').show();

    if(user_login_step == 1)
    {
        $('.user_login_field').removeClass('error');
        var username = $('#user_login_username').val();
        var password = $('#user_login_password').val();
        var options = {
            type: 'POST',
            url: '/' + cur_lang + '/user/pre_login',
            dataType: 'json',
            data: {
                username: username, 
                password: password
            },
            success: user_pre_login_response
        }

        $.ajax(options);

    }
    else
    {
        $('.user_login_field').removeClass('error');

        var username = $('#user_login_username').val();
        var password = $('#user_login_password').val();
        var remember_me = 0 + $('#user_login_remember_me').is(':checked');
        var code = $('#user_login_code').val();

        var options = {
            type: 'POST',
            url: '/' + cur_lang + '/user/login',
            dataType: 'json',
            data: {
                username: username, 
                password: password, 
                remember_me: remember_me, 
                code: code
            },
            success: user_login_response
        }

        $.ajax(options);

    }

    return false;
}

user_pre_login_response = function(response)
{
    $('#login_preloader').hide();
    $('#login_form').show();
	
    switch(response['status'])
    {
        case 'success':
            if (response['online'] != 1)
            {
                $('.user_login_step_1').hide();
                $('.user_login_step_2').show();
                $('#user_login_code').focus();

                user_login_step = 2;
                $('.user_login_field').removeClass('error');
                $('#user_login_code_number').html(response['required_code']);
            } else {
                user_login_step = 2;
                user_login();
            }
            break;
        case 'error':
            $('.user_login_field').addClass('error');
            call_new_error_popup(response['error_title'], response['error_message']);
            break;
    }
	    
    return false;
}

user_login_response = function(response)
{
    switch(response['status'])
    {
        case 'success':
            if (window.location.search.indexOf("session_expired", 0) > -1){
                window.location.href = "http://"+window.location.host+window.location.pathname;
            } else {
                location.reload();
            }
            break;
        case 'error':
            $('#login_preloader').hide();
            $('#login_form').show();
            $('.user_login_field').addClass('error');
            call_new_error_popup(response['error_title'], response['error_message']);
            break;
    }
    return false;
}


past_bids_filter_by_duration = function()
{
    document.location = '?duration=' + $("#past_bids_filter_duration").val();
    return false;
}


past_bids_filter_by_card_id = function()
{
    document.location = '?card_nr=' + $("#past_bids_filter_card_id").val();
    return false;
}

widget_box_checkbid_check = function()
{
    var card_id = $("#widget_box_checkbid_id").val();
    var options = {
        type: 'POST',
        url: '/card/check',
        dataType: 'json',
        data: {
            card_id: card_id
        },
        success: widget_box_checkbid_response
    }
    $.ajax(options);

    return false;
}

widget_box_checkbid_response = function (response)
{
    if(response['message'] && response['title'])
    {
        call_new_popup(response['title'], response['message']);
    }
}



// LEAGUE PAST LIST
widget_legue_past_list_update_filter_date = function()
{
    var values = {};
    $.each($('#date_filter').serializeArray(), function(i, field) {
        values[field.name] = field.value;
    });

    $('#filter_from_from').val(values['from_y'] + '-' + values['from_m'] + '-' + values['from_d']);
    $('#filter_from_till').val(values['till_y'] + '-' + values['till_m'] + '-' + values['till_d']);

}

widget_legue_past_list_update_filter_date_from = function()
{
    var from_y = $('#widget_legue_past_list_update_filter_date_from_y').val();
    var from_m = $('#widget_legue_past_list_update_filter_date_from_m').val();
    var from_d = $('#widget_legue_past_list_update_filter_date_from_d').val();

    var till_y = $('#widget_legue_past_list_update_filter_date_till_y').val();
    var till_m = $('#widget_legue_past_list_update_filter_date_till_m').val();
    var till_d = $('#widget_legue_past_list_update_filter_date_till_d').val();

    var from = new Date(from_y, from_m-1, from_d);
    var till = new Date(till_y, till_m-1, till_d);

    if(Math.abs((from.getTime()/1000 - till.getTime()/1000)/60/60/24) > 7)
    {
        till = new Date(from.getTime() + 1000*60*60*24*7);

        $('#widget_legue_past_list_update_filter_date_till_y').val(till.getFullYear());
        $('#widget_legue_past_list_update_filter_date_till_m').val(till.getMonth()+1);
        $('#widget_legue_past_list_update_filter_date_till_d').val(till.getDate());

        $('#filter_limit_warning').show();
    }

    if(from > till)
    {
        till = from;

        $('#widget_legue_past_list_update_filter_date_till_y').val(till.getFullYear());
        $('#widget_legue_past_list_update_filter_date_till_m').val(till.getMonth()+1);
        $('#widget_legue_past_list_update_filter_date_till_d').val(till.getDate());
    }

    widget_legue_past_list_update_filter_date();

}

widget_legue_past_list_update_filter_date_till = function()
{
    var from_y = $('#widget_legue_past_list_update_filter_date_from_y').val();
    var from_m = $('#widget_legue_past_list_update_filter_date_from_m').val();
    var from_d = $('#widget_legue_past_list_update_filter_date_from_d').val();

    var till_y = $('#widget_legue_past_list_update_filter_date_till_y').val();
    var till_m = $('#widget_legue_past_list_update_filter_date_till_m').val();
    var till_d = $('#widget_legue_past_list_update_filter_date_till_d').val();

    var from = new Date(from_y, from_m-1, from_d);
    var till = new Date(till_y, till_m-1, till_d);

    if(Math.abs((from.getTime()/1000 - till.getTime()/1000)/60/60/24) > 7)
    {
        from = new Date(till.getTime() - 1000*60*60*24*7);

        $('#widget_legue_past_list_update_filter_date_from_y').val(from.getFullYear());
        $('#widget_legue_past_list_update_filter_date_from_m').val(from.getMonth()+1);
        $('#widget_legue_past_list_update_filter_date_from_d').val(from.getDate());
        $('#filter_limit_warning').show();

    }

    if(from > till)
    {
        from = till;

        $('#widget_legue_past_list_update_filter_date_from_y').val(from.getFullYear());
        $('#widget_legue_past_list_update_filter_date_from_m').val(from.getMonth()+1);
        $('#widget_legue_past_list_update_filter_date_from_d').val(from.getDate());
    }

    widget_legue_past_list_update_filter_date();

}


//Box_Tips

$(document).ready(function() { 
    box_tip_count = $('.box_tip').length;
    box_tip_current = Math.floor(Math.random()*box_tip_count+1) - 1;
    $('.box_tip:eq(' + box_tip_current +')').show();
});

function box_tips_next()
{
    box_tip_current++;
    if(box_tip_current >= box_tip_count)
    {
        box_tip_current = 0;
    }

    $('.box_tip').hide();

    $('.box_tip:eq(' + box_tip_current +')').show();
}

function box_tips_back()
{
    box_tip_current--;
    if(box_tip_current < 0)
    {
        box_tip_current = box_tip_count - 1;
    }

    $('.box_tip').hide();

    $('.box_tip:eq(' + box_tip_current +')').show();
}

//Comming_Group_Checkboxs

$(document).ready(function() { 
    is_first_time = 1;
});

function comming_categories_select(group_id)
{
    if ($("#gp_"+group_id).is(':checked'))
    {
        $("#gp_"+group_id).parent('li').find('input[id^="gp_'+group_id+'_"]').each(function(){
            $(this).attr('checked', true);
        });
    }
    else
    {
        $("#gp_"+group_id).parent('li').find('input[id^="gp_'+group_id+'_"]').each(function(){
            $(this).attr('checked', false);
        });
    }
}
function comming_categories_select_split(group_id)
{
    if ($("#gp_"+group_id).is(':checked'))
    {
        $('input[id^="gp_'+group_id+'_"]').each(function(){
            $(this).attr('checked', true);
        });
    }
    else
    {
    	
        $('input[id^="gp_'+group_id+'_"]').each(function(){
            $(this).attr('checked', false);
        });
    }
}
function comming_subcategories_select(group_id, sub_group_id)
{
    if ($("#gp_"+group_id+"_"+sub_group_id).is(':checked'))
    {
        $("#gp_"+group_id).attr('checked', false);
    }
    else
    {
        $("#gp_"+group_id).attr('checked', false);
    }
}

/*
function comming_subcategories_select(group_id, sub_group_id)
{
	if ($("#gp_"+group_id+"_"+sub_group_id).is(':checked'))
	{
		if (is_first_time == 1)
		{
			is_first_time = 0;
			$('input[id^="gp_'+group_id+'"]').each(function(){
				$(this).attr('checked', false);
			});
			$("#gp_"+group_id+"_"+sub_group_id).attr('checked', true);
		}
		else
		{
			$("#gp_"+group_id).attr('checked', false);
		}
	}
}
*/
function comming_super_categories_select()
{
    if ($("#spGp").is(':checked'))
    {
        $("#spGp").parent('li').find('input[id^="lgAlt_"]').each(function(){
            $(this).attr('checked', true);
        });
    }
    else
    {
        $("#spGp").parent('li').find('input[id^="lgAlt_"]').each(function(){
            $(this).attr('checked', false);
        });
    }
}
function comming_super_subcategories_select(group_id)
{
    if ($("#lgAlt_"+group_id).is(':checked'))
    {
        $("#spGp").attr('checked', false);
    }
    else
    {
        $("#spGp").attr('checked', false);
    }
}
/*
function comming_super_subcategories_select(group_id)
{
	if ($("#lgAlt_"+group_id).is(':checked'))
	{
		$("#spGp").attr('checked', false);
		if (is_first_time == 1)
		{
			is_first_time = 0;
			$('input[id="spGp"]').each(function(){
				$(this).attr('checked', false);
			});
			$("#lgAlt_"+group_id).attr('checked', true);
		}
	}
}
*/
// cookies


function createCookie(name,value,days) {
    if (days) {
        var date = new Date();
        date.setTime(date.getTime()+(days*24*60*60*1000));
        var expires = "; expires="+date.toGMTString();
    } else {
        var expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for(var i=0;i < ca.length;i++) {
        var c = ca[i];
        while (c.charAt(0)==' ') c = c.substring(1,c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name,"",-1);
}




function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  }
  return null;
} 



/*BALL LOTTO*/

function ballloto_refresh_bids() {
    var from = getQueryVariable('from');
    var till = getQueryVariable('till');
    var data = new Object();
    data['from'] = from;
    data['till'] = till;
    var options = {
        type: 'POST',
        url: '/' + cur_lang + '/ajax/ballloto-events',
        dataType: 'json',
        data: data,
        success: function (data){
            $('#balloto_ajax_id').html(data['html'])
            }
    }
    $.ajax(options);
}


function popup(url, w, h) {
    var winl = (screen.width-w)/2;
    var wint = (screen.height-h)/2;
    var settings  ='height='+h+',';
    settings +='width='+w+',';
    settings +='top='+wint+',';
    settings +='left='+winl+',';
    settings +='scrollbars=yes,directories=no,location=no,menubar=no,status=no,toolbar=no,resizable=yes';
    window.open(url,'',settings);
}
//justino
function uzklausa() {
	window.open("http://ofisas.orakulas.lt/uzklausa","UŽKLAUSA","status=1,height=720,width=670,resizable=0");
}


