var urlAkcija = "action.php";//lokalno	


function rand ( n ) {
  return ( Math.floor ( Math.random ( ) * n + 1 ) );
}



function refreshIt(ime_slike, name) {
   if (!document.images) return;
   document.images[name].src = 'temp/'+ ime_slike +'?' + Math.random();
}


//ucitavanje thumbica u meni
function MeniLoad (id, tip) {

	$('#'+id+' ul').slideToggle("slow");
	
	if (tip == 2) {
		
		$('.thumbiciInput').html('');
		$('#loading_thumbici').show();
		
		$.post(urlAkcija, {ID_kat: id, strana: 'thumbiciMeni'},
			function(data) {
				
				if (data) {
					$('.thumbiciInput').html(data);
				} 
				
			}
		);
	
	}
	
}


//promena tipa
function promenaTip (tip) {

	$('input[@name=TrenutniTip]').attr('value', tip).focus();
	$('#extra_meni li').removeClass("selected");
	$('.'+tip).addClass("selected");
	
}



//flip
function flip () {
	
	$('#loading').show();
	
	var tip = document.getElementById('TrenutniTip').value;
	var imageFlip = document.getElementById(tip+'Flip').value;
	
	if (imageFlip == 0) {
		imageFlip = 1;
	} else {
		imageFlip = 0;
	}
	
	$('input[@name='+tip+'Flip]').attr('value', imageFlip).focus();
	
	$.post(urlAkcija, {strana: 'flip', tip: tip},
		function(data) {
			if (data) {
				refreshIt(data, tip+'Temp');
			} 
		}
	);
	
}


//brise iz extra menija
function ExtraMeniRemove (id, title) {
	
	$('.'+title+' a').fadeOut('slow');
	$('#'+title+'ID').fadeOut('slow');
	$('.'+title).removeClass("selected");
	$("#"+title+"_sort").html('<img src="thumbs/'+title+'.jpg" alt="'+title+'" width="50" height="50" />');
	
	$.post(urlAkcija, {strana: 'NizChange', tip: title});

}




//$('#heder').html(x_poz +', '+ y_poz);
//window.alert(slikaW);

