var action = 0;
var t;
var c = 10;

$(document).ready(function(){
    if(typeof($('#flash')) != 'undefined' && $('#reklama').text() != ''){
        reklama();
    }
    else if(typeof($('#flash')) != 'undefined' && $('#reklama').text() == ''){
        $('#reklama').hide();
        $('#flash').show();
    }
});

function reklama(){
    $('#reklama').prepend('<div id="reklama_counter" style="width: 100%; position: relative; color:#000; top: 0px; left: 0px;">Игра начнется через '+c+' секунд</div>');
    t = setInterval(function(){
        --c;
        if(c > 0) $('#reklama_counter').text('Игра начнется через '+c+' секунд');
        else{
            $('#reklama').hide();
            $('#flash').show();
        }
    }, 1000);
}


function slider_right(id){
    if(action == 0){
        action = 1;
        var slider = $('#'+id);
        if($.browser['msie'] == true && $.browser.version == 6) var incr = 114;
        else var incr = 115;

        if(parseInt($(slider).css('right'))-incr > 0){
            $(slider).animate({'right': '-='+incr+'px'}, function(){action = 0;});
        }
        else $(slider).animate({'right': 0}, function(){action = 0;});
    }
}

function slider_left(id){
    if(action == 0){
        action = 1;
        var slider = $('#'+id);
        var length_child = $('.slider_item', slider).length;

        if($.browser['msie'] == true && $.browser.version == 6) var incr = 114;
        else var incr = 115;

        if(parseInt($(slider).css('right'))+incr < (length_child*114-incr*3)){
            $(slider).animate({'right': '+='+incr+'px'}, function(){action = 0;});
        }
        else action = 0;
    }
}


function getFlashObj(movie){
       if (window.document[movie]) {
          return window.document[movie];
       }
       if (navigator.appName.indexOf("Microsoft Internet") == -1) {
          if (document.embeds && document.embeds[movie]) {
             return document.embeds[movie];
          }
       } else {
          return document.getElementById(movie);
       }
    }
    

function setFlashSize() {

    
    var movieObj = getFlashObj('flash');
    var width = parseInt(movieObj.TGetProperty("/", 8));
    var height= parseInt(movieObj.TGetProperty("/", 9));

    if(width > 738){
        var nw = 738;
        var nh = 738*(height/width);
    }
    else{
        var nw = width;
        var nh = height;
    }
   
    $('#flash').width(nw);
    $('#flash').height(nh);
    $('[name=flash]').attr('width', nw);
    $('[name=flash]').attr('height', nh);

}



