var current_banner = 1;
var int_id;

$(document).ready(function(){
	int_id = setInterval(change_banner, 10000);
});

function banner(i) {
	clearInterval(int_id);
	select_banner(i);
}

function select_banner(i) {
	switch (current_language) {
		case "rus":
			suffix = "RU/";
		break;
		case "tur":
			suffix = "TR/";
		break;
		case "fre":
			suffix = "FR/";
		break;
		default:
			suffix = "";
		break;
	}
	
	for(var k=1;k<5;k++) $('#cb_'+k).html('<img src="http://cdn.zingaya.com/img/cb.png" border="0" width="12" height="12">');
	$('#cb_'+i).html('<img src="http://cdn.zingaya.com/img/cb_selected.png" border="0" width="12" height="12">');
	if (!$.browser.msie) {
		$('#banner_content, #buttons').fadeOut("slow", function() { 
			$('#banner_content').css({ 'backgroundImage' : 'url(http://cdn.zingaya.com/img/'+suffix+'banner'+i+'.png)' });  
			if (i != 1) $('#banner_video').hide();
			else $('#banner_video').show();
		});
		$('#banner_content, #buttons').fadeIn("slow");
	} else {
		if (i != 1) $('#banner_video').hide();
		else $('#banner_video').show();
		$('#banner_content').css('backgroundImage', 'url(http://cdn.zingaya.com/img/'+suffix+'banner'+i+'.png)');	
	}
}

function change_banner() {
	if (current_banner < 3) current_banner++;
	else current_banner = 1;
	select_banner(current_banner);
}

function showVideo() {
	$("#overlay").overlay({ 
	    // custom top position 
	    top: "center", 

	    // some expose tweaks suitable for facebox-looking dialogs 
	    expose: { 

	        // you might also consider a "transparent" color for the mask 
	        color: "#fff", 

	        // load mask a little faster 
	        loadSpeed: 200, 

	        // highly transparent 
	        opacity: 0.5 
	    }, 

		speed: 'fast',

	    // disable this for modal dialog-type of overlays 
	    closeOnClick: true, 

		onBeforeClose: function() {
			if ($.browser.msie) {
				$("#content").html("");
				parent.window.location.reload();
			}
		},
		
	    // we want to use the programming API 
	    api: true 

	// load it immediately after the construction 
	}).load();
}
