function setLoadEvent() {
	isNotProccessAjax=false;
    document.onmousemove = displayLoading;
}

function setCompleteEvent() {
	document.onmousemove = function(){}
	$("loading").setStyle({visibility: 'hidden'})
	isNotProccessAjax=true;
}

function displayLoading(e){
	var posx = 0;
	var posy = 0;
	if (!e) var e = window.event;
	if (e.pageX || e.pageY) {
		posx = e.pageX;
		posy = e.pageY;
	}
	else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
	}
	// posx and posy contain the mouse position relative to the document
	// Do something with this information
	$("loading").setStyle({left: posx + 10 + 'px', top: posy + 16 + 'px', visibility: 'visible'})
}

function inquiryChangeSelected(sender, radioId)
{
	var object = document.getElementById("inquiry");	
	var arr = object.getElementsByTagName('a');	
	for(i=0;i<arr.length;i++) arr[i].className = "inquiry-option bullet-normal";	
	sender.className = "inquiry-option bullet-selected";
	
	var arr = object.getElementsByTagName('input');	
	for(i=0;i<arr.length;i++) arr[i].value = 'false';
	
	object = document.getElementById(radioId);	
	object.value = 'true';
}

function changeCollapsedExpanded(object){
	var object = document.getElementById(object);

	if(object){
		if(object.className == "panel-collapse") object.className = "panel-exp";
		else if(object.className == "panel-exp") object.className = "panel-collapse";
		
	}
}

var currentMainNews = 0;
var pe;

function toggleMainNews(index,interval)
{		
	currentMainNews = index-1;	
	pe.stop();
	rotate();
	pe = new PeriodicalExecuter(rotate, interval);	
}

function rotateArticles(interval)
{				
	pe = new PeriodicalExecuter(rotate, interval);
}

function rotate()
{
	var array = $$('#MainMenuList a');
	if (array.length>0)
	{ 
		if (currentMainNews>=array.length-1) 
			currentMainNews=0;
		else 
			currentMainNews++;
		
		var html = array[currentMainNews].innerHTML;
		
		var url = $('UrlContent'+currentMainNews).innerHTML;	
		html = '<a href="'+url+'" class="white large" style="font-size: 18px;">' + html + '</a>';	
		$('MainNewPanel').update(html);	
		
		html = $('DataContent'+currentMainNews).innerHTML;	
		$('MainNewsDate').update(html);	
		
		html = $('ImgSrcContent'+currentMainNews).innerHTML;	
		$('MainNewsImgSrc').setStyle({'background':'url('+html+')'});	
	}
}


var currentMainNewsVideo = 0;
var peVideo;

function toggleMainNewsVideo(index,interval)
{		
	currentMainNewsVideo = index-1;	
	peVideo.stop();
	rotateVideos();
	peVideo = new PeriodicalExecuter(rotateVideos, interval);	
}

function rotateArticlesVideos(interval)
{				
	peVideo = new PeriodicalExecuter(rotateVideos, interval);
}

function rotateVideos()
{
	var array = $$('#MainMenuVideoList a');
	if (array.length > 0)
	{ 
		if (currentMainNewsVideo>=array.length-1) 
			currentMainNewsVideo=0;
		else 
			currentMainNewsVideo++;
		
		var html = array[currentMainNewsVideo].innerHTML;
		
		var url = $('UrlContentVideo'+currentMainNewsVideo).innerHTML;	
		html = '<a href="'+url+'" class="white large" style="font-size: 18px;">' + html + '</a>';	
		$('MainNewVideoPanel').update(html);	
		
		html = $('DataContentVideo'+currentMainNewsVideo).innerHTML;	
		$('MainNewsVideoDate').update(html);	
		
		html = $('ImgSrcContentVideo'+currentMainNewsVideo).innerHTML;	
		$('MainNewsVideoImgSrc').setStyle({'background':'url('+html+')'});	
	}
}



var currentFontSize = 11;
function incrementDecrementFont(step, object1, object2)
{		
	if ((currentFontSize+step) <= 9 || (currentFontSize+step) >= 15) 
	{	
		return false;
	}
	else
	{	
		$('decrText').className = 'txt-but decr-txt-s';
		$('incrText').className = 'txt-but incr-txt-s';
		currentFontSize += step;
		document.getElementById(object1).style.fontSize = currentFontSize + 'px';
		document.getElementById(object2).style.fontSize = currentFontSize + 'px';
	}
	
	if ((currentFontSize+step) <= 9)
	{			
		$('decrText').className = 'txt-but decr-txt-f';
	}
	
	if ((currentFontSize+step) >= 15)
	{
		$('incrText').className = 'txt-but incr-txt-f';
	}
}

function showAnswerStat(id, title, lang)
{
	var flashvars = {};
	var params = {};
	var attributes = {};
	swfobject.embedSWF("lib/flash/votes_map.swf?v=modules/votesPerCitiesXML.php?id="+id+"&currentLang="+lang, "flashcontent1", "550", "360", "8", "", flashvars, params, attributes);
	$('flashholder').show();
	document.getElementById('answertxt').innerHTML = title;
}

function changeMainArticleView(sender, interval)
{
	$('MainNewsArticlePicture').toggle();
	$('MainNewsArticleVideos').toggle();
	
	var array = $$('#MainMenuVideoList a');
	currentMainNewsVideo = array.length;
	
	array = $$('#MainMenuVideoList a');
	currentMainNews = array.length;
	
	peVideo.stop();	
	rotateVideos();
	peVideo = new PeriodicalExecuter(rotateVideos, interval);
	
	pe.stop();	
	rotate();
	pe = new PeriodicalExecuter(rotate, interval);
}

function popup(url,winWidth,winHeight,sb) 
{
	winTop = (screen.height - winHeight) / 2;
	winLeft = (screen.width - winWidth) / 2;
	window.open(url,"","width=" + winWidth + ",height=" + winHeight + ",top=" + winTop  + ",left=" + winLeft  + ",resizable=no,scrollbars=" + sb + ",toolbar=no");
}