function enable_counties(){
	var county = document.getElementById('county');
	var country = document.getElementById('country');
	var div_county = document.getElementById('div_county');
	var div_county1 = document.getElementById('div_county1');
	if(country.value == '131'){
		county.disabled = false;
		div_county.style.display = "block";
		div_county1.style.display = "none";
	}else{
		county.disabled = true;
		div_county.style.display = "none";
		div_county1.style.display = "block";
	}
}

function enable_counties1(){
	var county = document.getElementById('county');
	var country = document.getElementById('country');
	if(country.value == '131'){
		county.disabled = false;
	}else{
		county.disabled = true;
	}
}

function change_city(){
	var county = document.getElementById('county');
	var div_varos = document.getElementById('div_varos');
	var div_kerulet = document.getElementById('div_kerulet');
	if(county.value == '0'){
		div_kerulet.style.display = "block";
		div_varos.style.display = "none";
	}else{
		div_kerulet.style.display = "none";
		div_varos.style.display = "block";
	}
}

function addOption(selectId, val, txt, sel) {
    var objOption = new Option(txt, val, sel, sel);
     document.getElementById(selectId).options.add(objOption);
}

function clearOption(selectId) {
	document.getElementById(selectId).length=0;
}

function valt(selectId){
	var div = document.getElementById(selectId);
	if(div.style.display == 'none'){
		div.style.display = 'block';
	}else{
		div.style.display = 'none';
	}

}

function csere(selectId1, selectId2){
	var s1 = document.getElementById(selectId1);
	var s2 = document.getElementById(selectId2);
	s1.style.display = 'block';
	s2.style.display = 'none';
	//alert(selectId1);
	//alert(s1);
	if (selectId1=='holland') {
		//alert(selectId1);
		//alert(document.getElementById("price_h").value);
		document.getElementById("price_h").value=document.getElementById("price").value;
	}
	else {
		document.getElementById("price").value=document.getElementById("price_h").value;
	}
}

function mutat(selectId){
	var s = document.getElementById(selectId);
	s.style.display = 'block';
}

function elrejt(selectId){
	var s = document.getElementById(selectId);
	s.style.display = 'none';
}

function termek_nemideillo(id) {
	new Ajax.Request('/ajaxhelper.php', {
			method:'get',
			parameters: { flagproduct: id },
			onSuccess: function(transport) {
				alert('A terméket megjelöltük.');
			}
		}
	);
}

function change_duration(){
	var duration = document.getElementById('duration');
	var div_duration = document.getElementById('div_duration');
	if(duration.value == 'egyeb'){
		div_duration.style.display = 'block';
	}else{
		div_duration.style.display = 'none';
	}
}

function change_duration1(id){
	var duration = document.getElementById('duration'+id);
	var div_duration = document.getElementById('div_duration'+id);
	if(duration.value == 'egyeb'){
		div_duration.style.display = 'block';
	}else{
		div_duration.style.display = 'none';
	}
}

function select_product(id, that) {
	new Ajax.Request('/ajaxhelper.php', {
			method:'get',
			parameters: { share_product: id },
			onSuccess: function(transport) {
				if(transport.responseText == 'hiba'){
					that.checked = false;
					alert('Maximum 10 terméket választhat!');
				}				
			}
		}
	);
}

function go_recommend() {
	location.href='/ajanlom';
/*	new Ajax.Request('/ajaxhelper.php', {
			method:'get',
			parameters: { go_recommend: '1' },
			onSuccess: function(transport) {
				if(transport.responseText == 'hiba'){
					alert('Nem választott terméket!');
				}else{
					location.href='/ajanlom';
				}				
			}
		}
	);*/
}

function show_checkbox() {
	new Ajax.Request('/ajaxhelper.php', {
			method:'get',
			parameters: { show_checkbox: '1' },
			onSuccess: function(transport) {
				location.reload();
			}
		}
	);
}

function change_duration_all(){
	var duration = document.getElementById('duration_all');
	var div_duration = document.getElementById('div_duration_all');
	if(duration.value == 'egyeb'){
		div_duration.style.display = 'block';
	}else{
		div_duration.style.display = 'none';
	}
}

function check_all_checkbox(){
	var checked = $('check_all').checked;
	var f = document.forms['rereg_form'];
	for(var i = 0; i < f.elements['check[]'].length; i++) {
		if(checked){
			f.elements['check[]'][i].checked = true;	
		}else{
			f.elements['check[]'][i].checked = false;				
		}
	}
}

function check_all_checkbox2(type){
	var f = document.forms['rereg_form'];
	for(var i = 0; i < f.elements['check[]'].length; i++) {
		if(type == 'check'){
			f.elements['check[]'][i].checked = true;	
		}else{
			f.elements['check[]'][i].checked = false;				
		}
	}
}

function osszes_ara(){
	var f = document.forms['rereg_form'];
	for(var i = 0; i < f.elements['check[]'].length; i++) {
		var akt_id = f.elements['check[]'][i].value;
		if($('min_price'+akt_id).value != '0' && $('min_price'+akt_id).value != ''){
			$('price'+akt_id).value = $('min_price'+akt_id).value;
		}
	}
}

function kijeloltek_ara(){
	var checked = $('check_all').checked;
	var f = document.forms['rereg_form'];
	for(var i = 0; i < f.elements['check[]'].length; i++) {
		var akt_id = f.elements['check[]'][i].value;
		if($('min_price'+akt_id).value != '0' && $('min_price'+akt_id).value != ''){
			if(f.elements['check[]'][i].checked){
				$('price'+akt_id).value = $('min_price'+akt_id).value;
			}			
		}
	}
}

function idotartam_osszes(){
	var dur_all = $('duration_all').value;
	var dur_all1 = $('duration1_all').value;
	if(dur_all != ''){
		var f = document.forms['rereg_form'];
		for(var i = 0; i < f.elements['check[]'].length; i++) {
			var akt_id = f.elements['check[]'][i].value;
			$('duration'+akt_id).value = dur_all;
			if(dur_all == 'egyeb'){
				$('div_duration'+akt_id).style.display = 'block';
				$('duration1'+akt_id).value = dur_all1;			
			}else{
				$('div_duration'+akt_id).style.display = 'none';
				$('duration1'+akt_id).value = '';							
			}
			
		}		
	}
}

function idotartam_kijelolt(){
	var dur_all = $('duration_all').value;
	var dur_all1 = $('duration1_all').value;
	if(dur_all != ''){
		var f = document.forms['rereg_form'];
		for(var i = 0; i < f.elements['check[]'].length; i++) {
			if(f.elements['check[]'][i].checked){
				var akt_id = f.elements['check[]'][i].value;
				$('duration'+akt_id).value = dur_all;
				if(dur_all == 'egyeb'){
					$('div_duration'+akt_id).style.display = 'block';
					$('duration1'+akt_id).value = dur_all1;			
				}else{
					$('div_duration'+akt_id).style.display = 'none';
					$('duration1'+akt_id).value = '';							
				}
			}
		}		
	}
}

function ujrareg_kijelolt(){
	var repeated_all = $('repeated_all').value;
	if(repeated_all != ''){
		var f = document.forms['rereg_form'];
		for(var i = 0; i < f.elements['check[]'].length; i++) {
			if(f.elements['check[]'][i].checked){
				var akt_id = f.elements['check[]'][i].value;
				$('repeated'+akt_id).value = repeated_all;
			}
		}		
	}
}

function ujrareg_osszes(){
	var repeated_all = $('repeated_all').value;
	if(repeated_all != ''){
		var f = document.forms['rereg_form'];
		for(var i = 0; i < f.elements['check[]'].length; i++) {
			var akt_id = f.elements['check[]'][i].value;
			$('repeated'+akt_id).value = repeated_all;			
		}		
	}
}
function add_comment(product_id) {
	var comment = $('comment_body').value;
	if(comment == ''){
		$('hiba_div').style.display = 'block';
	}else{
		new Ajax.Request('/ajaxhelper.php', {
				method:'get',
				parameters: { add_comment: '1',  product_id: product_id, comment: comment},
				onSuccess: function(transport) {
						window.location.reload();				
				}
			}
		);			
	}
}

function del_comment(id) {
		new Ajax.Request('/ajaxhelper.php', {
				method:'get',
				parameters: { del_comment: '1',  id: id},
				onSuccess: function(transport) {
						window.location.reload();				
				}
			}
		);
}

function get_wcomments(id, page) {
		new Ajax.Request('/ajaxhelper.php', {
				method:'get',
				parameters: { get_wcomments: '1',  id: id, page: page},
				onSuccess: function(transport) {
						$('commentholder').innerHTML = transport.responseText;				
				}
			}
		);			
}

function textCounter(fieldd, countfieldd, maxlimit) {
	var field = document.getElementById(fieldd);
	var countfield = document.getElementById(countfieldd);
	if (field.value.length > maxlimit){
		field.value = field.value.substring(0, maxlimit);
		countfield.value = 0;
	}else{
		countfield.value = maxlimit - field.value.length;
	}
}
