// JavaScript Document
function reloadPage(){
	location.reload();
}

function access(){
	document.write('<iframe src="/access?ref='+document.referrer+'" width="1" height="1" frameborder="0" scrolling="no"></iframe>');
}

/*______________________________________________________________________

Ajax
______________________________________________________________________*/

document.observe('dom:loaded',function(){
	new Control.Window($(document.body).down('[href=#language]'),{
		className    : 'normal-window',
		position     : 'relative',
		closeOnClick : 'layout',
		offsetTop    : 26
	});
	new Control.Window($(document.body).down('[href=#tool]'),{
		className    : 'normal-window',
		position     : 'relative',
		closeOnClick : 'layout',
		offsetTop    : 26
	});
	new Control.Window($(document.body).down('[href=#genre]'),{
		className    : 'normal-window',
		position     : 'relative',
		closeOnClick : 'layout',
		offsetTop    : 16
	});
	var areaSetupWindow = new Control.Window($(document.body).down('[href=#area]'),{
		className    : 'normal-window',
		closeOnClick : 'area-close',
		closeOnClick : 'layout',
		beforeOpen   : showAreaWindow
	});
});

function showAreaWindow(){
	$("area-response").hide();
	$("area-indicator").show();
	new Ajax.Updater('area-response','/ajaxs/area_setup', {
		asynchronous:true,
		evalScripts:true,
		onComplete:function(request, json) {
			$("area-response").show();
			$("area-indicator").hide()
		}, 
		method:'get',
		requestHeaders:['X-Update', 'area-response']
	})
}


/*______________________________________________________________________

Form
______________________________________________________________________*/


function showLength(str,maxLenght,showId,btnId) {
	document.getElementById(showId).innerHTML = str.length+'/'+maxLenght;
	document.getElementById(btnId).disabled = (str.length > maxLenght)? true : false ;
	if(document.getElementById(btnId).disabled){
		document.getElementById(btnId).className = 'disabled';
	}else{
		document.getElementById(btnId).className = '';
	}
}

function backForm(to){
	document.getElementById('EventNextPage').value = to;
	document.getElementById('EventSave').value = 0;
	document.getElementById('EventAddForm').submit();
}

function nextForm(to){
	document.getElementById('EventNextPage').value = to;
	document.getElementById('EventAddForm').submit();
}