var div_das = 'div#dasmanov_gif';
var div_das_width = 194;
var div_das_height = 258;
var class_1 = 'block_1';
var class_2 = 'block_2';
var img_path_begin = '/media/forgif/gallery-';
var img_path_end = '.jpg';
var i_begin = 1;
var i_end = 25;

var i_img = i_begin;
var tumbler = 1;
var div_block_1 = div_das+' .'+class_1;
var div_block_2 = div_das+' .'+class_2;
var img_a = div_das+' a';

function show_gif(){
	img_num_test();
	//$(div_block_1).css('background-image','url('+img_path_begin+i_img+img_path_end+')');

	if(tumbler == 1){
		$(div_block_1).show();
		$(div_block_1).css('background-image','url('+img_path_begin+i_img+img_path_end+')');
		i_img++;
		img_num_test();
		$(div_block_2).hide();
		$(div_block_2).css('background-image','url('+img_path_begin+i_img+img_path_end+')');
		tumbler = 2;
	}else if(tumbler == 2){
		$(div_block_2).show();
		$(div_block_2).css('background-image','url('+img_path_begin+i_img+img_path_end+')');
		i_img++;
		img_num_test();
		$(div_block_1).hide();
		$(div_block_1).css('background-image','url('+img_path_begin+i_img+img_path_end+')');
		tumbler = 1;
	}
	//i_img++;
}

function img_num_test(){
	if(i_img > i_end){
		i_img = i_begin;
	}
	if(i_img < 10 && typeof( i_img ) == 'number'){
		i_img = '0'+i_img;
	}
}

function intval( mixed_var, base ) {	// Get the integer value of a variable
	//
	// +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)

	var tmp;

	if( typeof( mixed_var ) == 'string' ){
		tmp = parseInt(mixed_var);
		if(isNaN(tmp)){
			return 0;
		} else{
			return tmp.toString(base || 10);
		}
	} else if( typeof( mixed_var ) == 'number' ){
		return Math.floor(mixed_var);
	} else{
		return 0;
	}
}

$(document).ready(function(){
	$(div_das)
	.css('width',div_das_width+'px')
	.css('height',div_das_height+'px')
	.css('position','relative')
	.append('<div class="'+class_1+'"></div><div class="'+class_2+'"></div>');

	$(div_block_1+','+div_block_2)
	.css('width',div_das_width+'px')
	.css('height',div_das_height+'px')
	.css('position','absolute')
	.css('left',0)
	.css('top',0)
	.css('background-color','#E7DBCD')
	.css('background-position','50% 50%')
	.css('background-repeat','no-repeat');
	$(div_block_1).css('z-index',20);
	$(div_block_2).css('z-index',10);

	$(img_a)
	.css('position','absolute')
	.css('text-align','center')
	.css('text-decoration','none')
	.css('color','white')
	.css('font-weight','bold')
	.css('font-size','16px')
	.css('line-height',div_das_height+'px')
	.css('left',0)
	.css('top',0)
	.css('display','block')
	.css('margin','0')
	.css('padding','0')
	.css('width',div_das_width+'px')
	.css('height',div_das_height+'px')
	.css('z-index',30);

	/*if(i_img < 10){
	i_img = '0'+i_img;
	}
	$(div_block_1).css('background-image','url('+img_path_begin+i_img+img_path_end+')');*/

	show_gif();
	setInterval('show_gif()',2000);
});
