var act;
var act_about;

var max_akciok = 0;
var max_about = 0;

$(document).ready(function(){
   
   var maxwidth = 500;
   
   $("#center table").each(function(){
    
        $(this).width(500);
    
   })
   
   
   var maxwidth = 500;
	$('#center img').each(function() { 	
		
		if(this.width > maxwidth) {
			
			var ratio =  maxwidth / this.width;
			//alert(maxwidth+' - '+this.width+'    '+ratio);
			this.width = maxwidth;
			var a = this.height * ratio;
			this.height = a; 
			
		}
	});   
    
    $('#center object').each(function() { 	
		
		if(this.width > maxwidth) {
			
			var ratio =  maxwidth / this.width;
			//alert(maxwidth+' - '+this.width+'    '+ratio);
			this.width = maxwidth;
			var a = this.height * ratio;
			this.height = a; 
			$(this).css({'width' : maxwidth+'px', 'height' : a+'px'});
		}
	});   
   
    $('#center embed').each(function() { 	
		
		if(this.width > maxwidth) {
			
			var ratio =  maxwidth / this.width;
			//alert(maxwidth+' - '+this.width+'    '+ratio);
			this.width = maxwidth;
			var a = this.height * ratio;
			this.height = a; 
			$(this).css({'width' : maxwidth+'px', 'height' : a+'px'});
		}
	});   
    
    
    
    act = 1;
    act = parseInt(act);
    
    $(".adfader").each(function(){
        max_akciok++;
    });
    
    
    
    
    
    act_about = 1;
    act_about = parseInt(act_about);
    
    $(".aboutfader").each(function(){
        max_about++;
    });
    
    //alert(max_about);
    startImageRoll();
    
    
    
}); 

var discount_step_delay = 5000;
var discount_fade_delay = 500;

function startImageRoll() {
    
   
    
     setTimeout('stepImage()', discount_step_delay);
}

function stepImage(){
    
   
    var a = $("#adfader_"+act);
   

    $("#adfader_"+act).fadeOut(discount_fade_delay, function(){        
        act += 1;
        if(act > max_akciok) act = 1;
        
        $("#adfader_"+act).fadeIn(discount_fade_delay, function(){
            setTimeout('stepImage()', discount_step_delay);
            
        });
        
    });
    
   
    
}




function stepImage_old(){
    
    $("#adfader_"+act).fadeOut(discount_fade_delay, function(){});
    act += 1;
    if(act > max_akciok) act = 1;
    $("#adfader_"+act).fadeIn(discount_fade_delay, function(){});
    //$("#randimg").attr({'src' : '/images/randimg_'+act+'.png'});
    
    /*
    $("#aboutfader_"+act_about).fadeOut('slow', function(){});
    act_about += 1;
    //alert(act_about);
    if(act_about > max_about) act_about = 1;
    $("#aboutfader_"+act_about).fadeIn('slow', function(){});
    */
    
    setTimeout('stepImage()', discount_step_delay);
}


 function removeStyleAttribute(element, name) {
        if(jQuery.browser.msie)
        element.style.removeAttribute(name);
        return true;
    } 
