function checkAllStateChange(la, state) {
	if (la.hasClassName('checkuncheck')) {
		$$('.filter .kvl').each(function(el) {
			if (!el.hasClassName('checkuncheck')) {
				if (!state) {
					el.down('.real').checked = false;
					el.down('.input').removeClassName('checked');
				}
				else {
					el.down('.real').checked = true;
					el.down('.input').addClassName('checked');
				}
			}
		});
	}
}

function checkStates() {
	$$('.kvl').each(function(la) {
		if (la.down('input').readAttribute('type') == 'checkbox') {

			la.insert({ top : new Element('span', { 'class' : 'input' }) });
			la.down('.real').setStyle({ 'display' : 'none' });

			if (la.down('input').checked == true) la.down('.input').addClassName('checked');

			la.down('.input').observe('mouseup', function(ev) {
				el = ev.element();
				if(la.down('input').disabled) {
					ev.stop();
					return;
				}
				
				if (la.down('input').checked == true) {
					la.down('.real').click();
					la.down('.input').removeClassName('checked');
					checkAllStateChange(la, false);
				}
				else if (la.down('input').checked == false) {
					la.down('.real').click();
					la.down('.input').addClassName('checked');
					checkAllStateChange(la, true);
				}
			});
		}
	});
	
}

document.observe('dom:loaded', checkStates);

function ShowCountry(country)
{
	$('map').hide();
	$('country').writeAttribute('style', 'background: url(img/country/'+country+'.jpg) no-repeat 0 0; display: block;');
}
function BackGlobal()
{
	$('map').show();
	$('country').hide();
}

document.observe('dom:loaded', function(){
	if ($$(".model_3d").size()) {
		$$('.model_3d .menu li a').each(function(el, index){
			el.observe('click', function(ev){
				var sel = index + 1;
				$$('.model_3d .pop').each(function(el){
					el.hide();
				});
				$$('.model_3d .menu li a').each(function(el){
					el.removeClassName('sel');
				});
				$('pop0'+ sel).show();
				el.addClassName('sel');
			});
		});
	}	
});