function showError(message){
	alert("HIBA\r\n"+message);
}

function brand_form_submit(){
	url="/by_brand/"+$('brand_select').value;
	document.location=url;
	return false;
}
/*function search_form_submit(){
	url="/search/"+$('keywords').value;
	document.location=url;
	return false;
}*/
function search_form_submit(){
	url="/search/"+$('keywords').value+"/"+$('price').value+"/"+$('brand').value;
	inputs=document.getElementsByName('property[]');
	for(i=0; i<inputs.length; i++){
		if(inputs[i].checked){
			url+="/"+inputs[i].value;
		}
	}
	
	document.location=url;
	return false;
}

function send_to_friend_submit(){
	filter=/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/;
	if($("send_to_friend_email").value && filter.test($("send_to_friend_email").value)){
		url="/send_to_friend/"+$("send_to_friend_email").value;
		document.location+=url;
	}
	else{
		alert("Nem megfelelő az email cím");
	}
	
	return false;
}
function payment_submit(){
	payment=0;
	if($("payment_form").payment.length){
		for(i=0; i<$("payment_form").payment.length;i++){
			if($("payment_form").payment[i].checked){
				payment=$("payment_form").payment[i].value;
				break;
			}
		}
	}
	else{
		if($("payment_form").payment.checked){
			payment=$("payment_form").payment.value;
		}
	}
	if(!payment){
		alert("Nem választott fizetési módot");
		return false;
	}
	url="/shipping/"+payment;
	
	document.location=url;
	return false;
}
function shipping_submit(){
	shipping=0;
	if($("shipping_form").shipping.length){
		for(i=0; i<$("shipping_form").shipping.length;i++){
			if($("shipping_form").shipping[i].checked){
				shipping=$("shipping_form").shipping[i].value;
				break;
			}
		}
	}
	else{
		if($("shipping_form").shipping.checked){
			shipping=$("shipping_form").shipping.value;
		}
	}
	if(!shipping){
		alert("Nem választott szállítási módot");
		return false;
	}
	url="/pay/"+shipping;
	
	document.location=url;
	return false;
}
function newsletter_submit(button){
	shipping=0;
	if(!$("news_letter_email").value){
		alert("Nem adott meg e-mail címet");
		return false;
	}
	url="/newsletter/"+button.name+"/"+$("news_letter_email").value;
	document.location=url;
	return false;
}
function lost_password_submit(){
	if($("lost_password_email").value.length){
		
		url="/lost_password/"+$("lost_password_email").value;
	}
	document.location=url;
	return false;
}
function add_to_the_basket(form){
	if(!form.count.value){
		alert("Nem adott meg darabszámot");
		return false;
	}
	url="/basket/add/"+form.id.value+"/"+form.count.value;
	document.location=url;
	return false;
}
function modify_basket(form){
	if(!form.count.value){
		alert("Nem adott meg darabszámot");
		return false;
	}
	url="/basket/modify/"+form.id.value+"/"+form.count.value;
	document.location=url;
	return false;
}
function delete_from_basket(form){
	
	url="/basket/delete/"+form.id.value;
	document.location=url;
	return false;
}
function show_popup(path){
	window.open(path,'displayWindow','width=600, height=400, scrollbar=1, scrollbars=1, resizable=1');
	return false;
}
function open_tree(li){
	child=li.parentNode.getElementsByTagName("ul")[0];
	if(child.style.display=="none"){
		child.style.display="";
		li.src="/pics/cat_minus.gif";
	}
	else{
		child.style.display="none";
		li.src="/pics/cat_plus.gif";
	}
	
}

function show_popup_box(event, str){
	div=document.createElement("div");
	div.innerHTML=str;
	document.getElementById('container_main').appendChild(div);
	div.className="popup_box";
	div.style.position="absolute";
	div.style.left=(Event.pointerX(event)+2)+"px";
	div.style.top=(Event.pointerY(event)+2)+"px";
	
}
function hide_popup_box(){
	divs=document.getElementsByClassName("popup_box");
	document.getElementById('container_main').removeChild(divs[0]);
}
function toggle_description(){
	if(document.getElementById("item_description").style.display=="none"){
		document.getElementById("item_description").style.display="";
		document.getElementById("item_description_button").value="-";
	}
	else{
		document.getElementById("item_description").style.display="none";
		document.getElementById("item_description_button").value="+";
	}
}
function toggle_search_box(){
	if(document.getElementById("search_properties").style.display=="none"){
		document.getElementById("search_properties").style.display="";
	}
	else{
		document.getElementById("search_properties").style.display="none";
	}
}