function show_info(id) {
	document.getElementById(id+'_info').style.display='block';
}
function hidden_info(id) {
	document.getElementById(id+'_info').style.display='none';
}

function menu_show(id) {
	document.getElementById('menu_'+id).style.display='block';
	document.getElementById('fomenu_'+id).style.background='url(images/menu/xps_menu_'+id+'.png) no-repeat';
	document.getElementById('fomenu_'+id).style.backgroundPosition='18px 16px';
	document.getElementById('fomenu_'+id).style.borderTop='1px solid #454246';
	document.getElementById('fomenu_'+id).style.borderLeft='1px solid #454246';
	document.getElementById('fomenu_'+id).style.borderRight='1px solid #454246';
	document.getElementById('menu_'+id).style.borderTop='0';		
}
function menu_hidden(id) {
	document.getElementById('menu_'+id).style.display='none';
	document.getElementById('fomenu_'+id).style.background='#5E4D89 url(images/menu/xps_menu_'+id+'.png) no-repeat';
	document.getElementById('fomenu_'+id).style.backgroundPosition='18px 16px';		
	document.getElementById('fomenu_'+id).style.border='0px solid #454246';
	document.getElementById('menu_'+id).style.borderTop='1px solid #454246';		
}

function numberCheck(val,ring) {

	if (!ring) ring = 1;

	if ((val - 0) != val && val.length > 0) { if (ring==1) alert('Ebbe a mezőbe kérjük csak számokat írni!'); return numberCheck(val.slice(0,-1), (ring+1)); }
	else { return val; }
}

$(document).ready(function() {
	
	$('.only_number').live('keyup', function() {
		var value = $(this).val();
		
		if (value!='') {
			value = value.replace(',', '').replace('.','').replace(' ', '');
			$(this).val(numberCheck(value));
		}
	});
	
	$('.kviz .kerdes').corner();
	
	$('.kviz form').submit(function() {
		var error = new Array(); var error_i = 0;
		
		$(this).find('div.kerdes').each(function() {
		
			var ez = $(this);
			var checked = false;
			
			ez.find('input').each(function() {
				if ($(this).attr('type')=='radio' && $(this).attr('checked')=='checked') checked = true;
				else if ($(this).attr('type')=='text' && $(this).val()>0) checked = true;
			});
			
			if (checked==false) {
				error[error_i] = ez.find('h2').text();
				error_i++;
			}
		});
		
		if (error.length>0) {
			var text = "Az alábbi kérdésekre nem adott választ:\n";
			
			for (var i=0;i<error.length;i++) {
				error[i] = error[i];
				if (error[i]!=null && text.indexOf(error[i])==-1) text += "- "+error[i]+"\n";
			}
			
			alert(text);
		
			return false;
		} else {
			return true;
		}
		
	});
	
	
	$('#csomagcsv_all').click(function() {
		
		if ($(this).is(':checked')) {
			$(this).attr('checked', true);
			$(this).parents('.webrendeles').find('input[type=checkbox]').attr('checked', true);
		} else {
			$(this).removeAttr('checked');
			$(this).parents('.webrendeles').find('input[type=checkbox]').removeAttr('checked');
		}
		
	});
	
	$('#csomagcsv_form').submit(function() {
		
		var check = false;
		$(this).find('input[type=checkbox]').each(function() {
			if ($(this).is(':checked')) check = true;
		});
		
		if (check==false) {
			alert('Nem jelölt ki egy csomagot sem!');
			return false;
		} else {
			var c = confirm('Biztosan megrendeli a kijelölteket?');
			if (c==true) {
				document.getElementById('loading_div').style.display='block';
				return true;
			} else return false;
		}
		
	});
	
});
