function szmodmodosit(szmod, jump){
	if(jump == 0) {
		window.location = "process.php?m=szmod&mode=" + szmod + "&jump=" + jump;
	}
	if (szmod == 1) {
		document.getElementById('kosar_box1').style.display = 'block';
		document.getElementById('kosar_box2').style.display = 'none';
	} else {
		document.getElementById('kosar_box1').style.display = 'none';
		document.getElementById('kosar_box2').style.display = 'block';
	}
}
function openCat(catID)
{
	var actList = document.getElementById(catID);
	if (actList.style.display != 'block')
	{
		var allList = document.getElementsByTagName('ul');
		for (i=0; i<allList.length; i++)
		{
			var actElmntId = allList[i].id;
			if (actElmntId.indexOf('cat_') != -1 && actElmntId.indexOf('subcat_') == -1)
				allList[i].style.display = 'none';
		}
		actList.style.display = 'block';
	}
	else
		actList.style.display = 'none';
}
function openSubCat(subcatID)
{
	var actList = document.getElementById(subcatID);
	if (actList.style.display != 'block')
	{
		var allList = document.getElementsByTagName('ul');
		for (i=0; i<allList.length; i++)
		{
			var actElmntId = allList[i].id;
			if (actElmntId.indexOf('subcat_') != -1)
				allList[i].style.display = 'none';
		}
		document.getElementById(subcatID).style.display = 'block';
	}
	else
		actList.style.display = 'none';
}
function submitSearchForm()
{
	var f = document.getElementById('searchform2');
	//f.action = "/index.php?m=productlist&mode=search";
	f.submit();
}
function submitSearchFormText(e)
{
	var k_code = e.keyCode || e.which;
	if (k_code == 13)
		submitSearchForm();
}
function vote()
{
	var f = document.getElementById('voteform');

	var radio_choice = false;
	for (counter = 0; counter < f.voteanswer.length; counter++)
	{
		if (f.voteanswer[counter].checked)
			radio_choice = true;
	}
	if (!radio_choice)
	{
		alert("Kérjük válasszon egy szavazási opciót!")
	}
	else {
		f.submit();
	}
}

function cartsubmit(productID, mode)
{
	if(mode==2) {
		$.ajax({ url: '/process.php?m=addcart',
				 cache: false,
				 data: { 'product_id': productID,
						 'count': $('#details_' + productID).attr('value'),
						 'mode': 'ajax'
					   },
				 type: 'POST',
				 success: function() {
					 window.location = 'http://www.petnet.hu/kosar';
					//temp = arguments[0].split("%end%");
					//alert("A termék bekerült a kosarába!");
					//$('#items').html('Jelenleg <span class="orangebold">'+temp[0]+'</span> tétel');
					//$('#price').html('Összeg: <span class="orangebold">'+temp[1]+'</span>');
				 }
		});

	} else {
		$.ajax({ url: '/process.php?m=addcart',
				 cache: false,
				 data: { 'product_id': productID,
						 'count': $('#count_' + productID).attr('value'),
						 'mode': 'ajax'
					   },
				 type: 'POST',
				 success: function() {
					 window.location = 'http://www.petnet.hu/kosar';
					//temp = arguments[0].split("%end%");
					//alert("A termék bekerült a kosarába!");
					//$('#items').html('Jelenleg <span class="orangebold">'+temp[0]+'</span> tétel');
					//$('#price').html('Összeg: <span class="orangebold">'+temp[1]+'</span>');
				 }
		});
	}
/*
//	alert($('count_'+productID).value);
	var kosar_req = {
					 product_id: productID,
					 count: $('count_'+productID).value,
					 mode: "ajax"
					}
	req = $H(kosar_req);
	url = "/process.php?m=addcart";

	pars = req.toQueryString();
	var myAjax = new Ajax.Request(
		url,
			{
			method: 'post',
			parameters: pars,
			onComplete: showBasketResponse
		});
	//document.getElementById('addtocart_' + productID).submit();
*/
}
function showBasketResponse(req){
	/*temp = req.responseText.split("%end%");

	alert("A termék bekerült a kosarába!");
	$('items').innerHTML = 'Jelenleg <span class="orangebold">'+temp[0]+'</span> tétel';
	$('price').innerHTML = 'Összeg: <span class="orangebold">'+temp[1]+'</span>';*/
	window.location = 'http://www.petnet.hu/kosar';
}
function loginformSubmit()
{
	var f = document.getElementById('loginform');
	f.submit();
}
function formatPrice(price)
{
	var cnt = 0;
	var newprice = "";

	for (i=price.length - 1; i>=0; i--)
	{
		cnt++;
		newprice = price.charAt(i) + newprice;
		if (cnt == 3)
		{
			newprice = " " + newprice;
			cnt = 0;
		}
	}

	return newprice;
}
function prepNewsletterSubmit()
{
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	var f = document.getElementById('newsletterform');
	if (!filter.test(f.email.value))
		alert("A beírt e-mail cím szintaktikailag nem megfelelő!");
	else
		f.submit();
}
function SetCookie(cookieName,cookieValue,nDays) {
	var today = new Date();
	var expire = new Date();
	if (nDays==null || nDays==0) {
		nDays=1;
	}
	expire.setTime(today.getTime() + 3600000*24*nDays);
	document.cookie = cookieName+"="+escape(cookieValue) + ";path=/;expires="+expire.toGMTString();
}
function hideBeuszo(){
	document.getElementById("popup_layer").style.display="none";
	SetCookie("PetnetPopup", 1, 7);
}
function erdeklodjon()
{
	alert('Ez a termék átmenetileg nem elérhető. Kérjük, elérhetőségéről érdeklődjön a PETNET ügyfélszolgálatán a 70/9326-333-as telefonszámon. Köszönjük!')
}
$('document').ready(function() {
	$('#searchstring').searchAutocomplete( { url : '/for_searchautocomplete.php' } );
} );

function forceNumericInput(el, event) {
	var allowed = false,
	key = String.fromCharCode(event.charCode || event.keyCode);
	if (key >= '0' && key <= '9') {
	   allowed = true;
	}
	return allowed;
}

