var n=0;
jQuery.getGallery=function(sr,gal_name){
$.ajax({
	type: "POST",
	url: "/ajax_request_manager.php",
	dataType: "html",
	data: "action=getGallery&gallery="+gal_name,
	success: function(xml) {
			var app=$(xml).find('#append');
			if (app){
				$('.ajax_gallery').remove();
				$('#'+sr).append($(app).html());
			}
		}
	});
	return false;
}
jQuery.getVideosList=function(sr,cat_name){
$.ajax({
	type: "POST",
	url: "/ajax_request_manager.php",
	dataType: "html",
	data: "action=getVideosList&category="+cat_name,
	success: function(xml) {
			var app=$(xml).find('#append');
			if (app){
				$('.ajax_category').remove();
				$('#'+sr).append($(app).html());
			}
		}
	});
	return false;
}
jQuery.getVideo=function(sr,id){
$.ajax({
	type: "POST",
	url: "/ajax_request_manager.php",
	dataType: "html",
	data: "action=getVideo&id="+id,
	success: function(xml) {
			var app=$(xml).find('#append');
			if (app){
				$('.ajax_video').remove();
				$('#'+sr).append($(app).html());
			}
		}
	});
	return false;
}
jQuery.showYear=function(sr,id){
$.ajax({
	type: "POST",
	url: "/ajax_request_manager.php",
	dataType: "html",
	data: "action=showYear&id="+id,
	success: function(xml) {
			var app=$(xml).find('#append');
			if (app){
				$('#'+sr).empty().append($(app).html());
			}
		}
	});
	return false;
}
function counter(max) {
    if (max)
	counter.max=max;
    if ( typeof counter.count == 'undefined' || counter.count == counter.max) {
        counter.count = 0;
    }
    return counter.count++;
}
jQuery.getBoxNews=function(sr,num,tot,time){
for (var i=0;i<num;i++){
	$.ajax({
		type: "POST",
		url: "/ajax_request_manager.php",
		dataType: "html",
		data: "action=getNewsBox&num="+counter(tot),
		success: function(xml) {
				var app=$(xml).find('#append');
				if (app){
					$('#'+sr).prepend($(app).html());
				}
			}
		});
}
	window.setInterval(function(){
		$.ajax({
			type: "POST",
			url: "/ajax_request_manager.php",
			dataType: "html",
			data: "action=getNewsBox&num="+counter(),
			success: function(xml) {
					var app=$(xml).find('#append');
					if (app){
						$('#'+sr).children('div:last').remove();
						$('#'+sr).prepend($(app).html());
					}
				}
			});
		return false;
	},time);
}
jQuery.getCalendarNews=function(sr,num,tot,time){
for (var i=0;i<num;i++){
	$.ajax({
		type: "POST",
		url: "/ajax_request_manager.php",
		dataType: "html",
		data: "action=getCalendarBox&num="+counter(tot),
		success: function(xml) {
				var app=$(xml).find('#append');
				if (app){
					$('#'+sr).prepend($(app).html());
				}
			}
		});
}
	window.setInterval(function(){
		$.ajax({
			type: "POST",
			url: "/ajax_request_manager.php",
			dataType: "html",
			data: "action=getCalendarBox&num="+counter(),
			success: function(xml) {
					var app=$(xml).find('#append');
					if (app){
						$('#'+sr).children('div:last').fadeOut('slow',function(){
							$('#'+sr).children('div:last').remove();
							$('#'+sr).prepend($(app).html());
							});
					}
				}
			});
		return false;
	},time);
}
function myCustomFileBrowser(field_name, url, type, win) {
	var stile = "width=500, height=650";
	win.name='TinyImages';
 	window.open('/browseImages.php?win='+win.name+'&id='+win.document.forms[0].elements[field_name].id,'',stile);
}
function ShowHide(id){
	if(document.getElementById(id)){
		var el=document.getElementById(id);
		el.style.display = (el.style.display=="") ? "none" : "";
	}
}

