var globalCurrArtSlideshowId=new Array();
var globalActArtSlideshowNum=0;
var globalArtSlideshowInterval=5000;
var interval=null;
function post(data,mode){if(mode==null || mode!=true) var mode=false; if (window.XMLHttpRequest) xmlhttp = new XMLHttpRequest; else if (window.ActiveXObject)xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); xmlhttp.open('POST','/ajax.php',mode); xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xmlhttp.onreadystatechange = function(){if (xmlhttp.readyState == 4){if (xmlhttp.status == 200){ajax_data = null;ajax_data = xmlhttp.responseText;}}}; xmlhttp.send(data); ajax_data = null; ajax_data = xmlhttp.responseText; return ajax_data;}


function isMagicBrowser(Is7thMagic){if(Is7thMagic==null) var Is7thMagic=false;if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){var v=new Number(RegExp.$1);if((v>=6||v>=5)&&v<7){return true;}else if(Is7thMagic){return (v>=7)?true:false;}else return false;}else{return false;}}
function switchArticle(id,auto){
	if(!auto||(auto!=true&&auto!=false)){var auto=false;}
	$('.thumbnails>div').removeClass('act');
	$('.image-block').hide();
	$('.text').hide();
	$('#art'+id).addClass('act');
	if(isMagicBrowser(1)){
		$('#article'+id+'>.image-block').show();
		$('#article'+id+'>.text').show();
	}else{
		$('#article'+id+'>.image-block').fadeIn(400,function(){$('#article'+id+'>.image-block').css({'display':'table'})});
		$('#article'+id+'>.text').fadeIn(400,function(){$('#article'+id+'>.text').css({'display':'table'})});	
	}
	if(!auto){
		clearInterval(interval);
		for(var u=0;globalCurrArtSlideshowId.length>u;u++){
			if(globalCurrArtSlideshowId[u]==id){
				globalActArtSlideshowNum=(u+1);
				break;
			}
		}
		interval=setInterval('articleAutoSwitcher()',globalArtSlideshowInterval);
	}
}
function articleAutoSwitcher(){
	if(globalActArtSlideshowNum>(globalCurrArtSlideshowId.length-1)){globalActArtSlideshowNum=0;}
	switchArticle(globalCurrArtSlideshowId[globalActArtSlideshowNum],true);
	globalActArtSlideshowNum=globalActArtSlideshowNum+1;
}


// ---<--- kalendâra funkcijas
var globalCurrMonth=null;
var globalCurrYear=null;
function bubmitdate(){
	m = parseFloat(globalCurrMonth);
	var datums = globalCurrYear+'-'+m;
	//alert(datums);
	window.location='/calendar/'+datums;
}
function calendarReloader(){
	globalCurrYear=document.getElementById('gads').value;
	globalCurrMonth=parseFloat(document.getElementById('meenesis').value)+1;
	bubmitdate();
}
function onemore(){
	globalCurrYear=document.getElementById('gads').value;
	var curr_month=document.getElementById('meenesis').value;
	if(curr_month<0||curr_month>=11){
		var curr_year = document.getElementById('gads').value;
		globalCurrMonth=1;
		globalCurrYear=parseFloat(curr_year)+1;
	} else {
		if(curr_month>=0){curr_month=parseFloat(curr_month);}
		else{
			curr_month = 12;
			var curr_year = document.getElementById('gads').value;
			curr_year = parseFloat(curr_year)+1;
			globalCurrYear=curr_year;
		}
		globalCurrMonth=curr_month+2;
	}
	bubmitdate()
}
function oneless(){
	globalCurrYear=document.getElementById('gads').value;
	var curr_month=document.getElementById('meenesis').value;
	if(curr_month<0||curr_month>12){curr_month=1;}
	if(curr_month>0){curr_month=parseFloat(curr_month);}
	else{
		curr_month = 12;
		var curr_year = document.getElementById('gads').value;
		curr_year = parseFloat(curr_year)-1;
		globalCurrYear=curr_year;
	}
	globalCurrMonth=curr_month;
	bubmitdate()
}
// --->--- kalendâra funkcijas

function openAnn(id){
	var url='/photo/'+id;
	var w = screen.width;
	var h = screen.height;
	var width=1000;
	var height=800;
	var l=(w-width)/2;
	var t=(h-height)/2;
	window.open( url,"_blank", "toolbar=0,scrollbars=1,resizable=1,left="+l+",top="+t+",width="+width+",height="+height );
	return false;
}

