var index = 0;
var timeOut = 0;
var aProd = new Array();
$(function(){
	$.get('/public/file/banner/top.xml', {}, function(xml) {
		i = 0;
		$('image', xml).each(function(){
			aProd[i] = new Array( );
			aProd[i]['top'] = $(this).find('top').text();
			aProd[i]['thumb'] = $(this).find('thumb').text();
			aProd[i]['thumbgrey'] = $(this).find('thumbgrey').text();
			aProd[i]['title'] = $(this).find('title').text();
			i++;
		});
		$('#thumb_'+index).addClass('active');
		$('#toptitle').html(aProd[index]['title']);
		setTimeout(function(){ rotator();},3000)
	//	rotator();
	},"xml");
});


function rotator(){
	clearTimeout(timeOut);
	$('#thumb_'+index).attr({'src':aProd[index]['thumbgrey'],'alt':''});
	$('#thumb_'+index).removeClass('active');
	if(aProd.length-1 >= index+1){
		index++;
	} else {
		index = 0;
	}
	$('#thumb_'+index).attr({'src':aProd[index]['thumb'],'alt':''});
	$('#thumb_'+index).addClass('active');
	$('#banner img').attr({'src':aProd[index]['top'],'alt':''});
	$('#toptitle').html(aProd[index]['title']);
	timeOut = setTimeout(function(){ rotator();},3000);
}



function show(id,type,ac){
	ds = type == '' ? 'block' : type;
	ob = document.getElementById(id);
	if(ac!=''){
		if(ac == 'hide'){
			ob.style.display = 'none';
		} else {
			ob.style.display = ds;
		}
	} else {
		if (ob.style.display == 'none') {
			ob.style.display = ds;
		}else{
			ob.style.display = 'none';
		}
	}
	return false;
}

function delete_action(){

	if (!confirm('Czy jestes pewien/na ze chcesz wykonac wybrana operacje')){return false;}

}

function showResult(thumbUrl){
	$("#MainPhotoImg").fadeOut('fast');
	$('#MainPhotoImg').attr({ src: thumbUrl }).fadeIn('slow');

	return false;
}
