function changePrice(obj){
	var rawData=obj.options[obj.selectedIndex].value;
	var arrData=rawData.split("#");	
	var strPrice;
	if(arrData[3].length>3){
		strPrice=arrData[3].substr(0,arrData[3].length-3)+"."+arrData[3].substr(arrData[3].length-3)+" Ft.";
	}else{
		strPrice=arrData[3]+" Ft.";
	}
	document.getElementById('package_price').innerHTML=strPrice;

}


function shipSubmit(){
	var errors=new Array();
	var s=document.basket_options.name.value;
	if(s.length>7 && s.match(' ')==' ') document.basket_options.name.style.borderColor='#42A8F3';
	else {
		document.basket_options.name.style.borderColor='#f34545';
		document.basket_options.name.value='';
		errors.push('Név');
	}
	
	s=document.basket_options.zipShip.value;
	if(s.length==4 && s.match(/\d{4}/)!=null) document.basket_options.zipShip.style.borderColor='#42A8F3';
	else {
		document.basket_options.zipShip.style.borderColor='#f34545';
		document.basket_options.zipShip.value='';
		errors.push('Szállítási irányítószám');
	}
	s=document.basket_options.addressShip.value;
	if(s.length>10 && s.match(/\d/)!=null && s.match(/\w/)!=null) document.basket_options.addressShip.style.borderColor='#42A8F3';
	else {
		document.basket_options.addressShip.style.borderColor='#f34545';
		document.basket_options.addressShip.value='';
		errors.push('Szállítási cím');
	}
	
	s=document.basket_options.zipBill.value;
	/*if(s.length==4 && s.match(/\d{4}/)!=null) document.basket_options.zipBill.style.borderColor='#42A8F3';
	else {
		document.basket_options.zipBill.style.borderColor='#f34545';
		document.basket_options.zipBill.value='';
		errors.push('Számlázási irányítószám');
	}*/
	s=document.basket_options.addressBill.value;
	/*if(s.length>10 && s.match(/\d/)!=null && s.match(/\w/)!=null) document.basket_options.addressBill.style.borderColor='#42A8F3';
	else {
		document.basket_options.addressBill.style.borderColor='#f34545';
		document.basket_options.addressBill.value='';
		errors.push('Számlázási cím');
	}*/
	
	s=document.basket_options.email.value;
	if(s.match(/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i)!=null) document.basket_options.email.style.borderColor='#42A8F3';
	else{
		document.basket_options.email.style.borderColor='#f34545';
		document.basket_options.email.value='';
		errors.push('Emailcím');
	
	}
	
	
	s=document.basket_options.phone.value;
	if(s.length>7) document.basket_options.phone.borderColor='#42A8F3';
	else{
		document.basket_options.phone.style.borderColor='#f34545';
		document.basket_options.phone.value='';
		errors.push('Telefonszám');
	
	}
	if(errors.length==0){
		document.basket_options.submit();
	}else{
		alert("A\n"+errors.join("\n")+"\nmezőket hibásan töltötte ki!");
	}

}

function switchLogin(e){
	var node=e.target?e.target:e.srcElement;
	if(node.nodeName.toUpperCase()=="A"){
		node=node.parentNode;
		var ch=node.childNodes;
		var i=0;
		while(ch[i].nodeName.toUpperCase()!='DIV')++i;
		ch[i].style.display=ch[i].style.display=='block'?'none':'block';
	}
}

function changeThumbnail(obj){
	var bPictureContainer=document.getElementById('prod_picture');
	var bPicture=bPictureContainer.getElementsByTagName('img')[0];
	bPicture.src=obj.src.replace(/\/s\//,'/m/');
	bPicture.src=bPicture.src.replace(/_s([0-9]+)\.jpg/,'_m$1.jpg');
}

function empty(obj, s){
	if(obj.value==s){
		obj.value="";
	}
}

function copyAddress(obj){
	var f=obj.form;
	f.zip2.value=f.zip1.value;
	f.city2.value=f.city1.value;
	f.place2.value=f.place1.value;
	f.ad_num2.value=f.ad_num1.value;
	f.ad_floor2.value=f.ad_floor1.value;
	f.ad_door2.value=f.ad_door1.value;

}

function addBasket(obj, s){
	if(document.product_form.product.value.indexOf(s)==-1){
		if(obj.style){
			obj.style.background="#E1EFFC url('images/keszulek-kereso/checkbox_ON.gif') no-repeat 5px 5px";
		}
		document.product_form.product.value+=s+"|";
	}else{
		if(obj.style){
			obj.style.background="#FFF url('images/keszulek-kereso/checkbox_OFF.gif') no-repeat 5px 5px";
		}
		document.product_form.product.value=document.product_form.product.value.replace(s+'|','');
	}
}

function countUp(obj){
	var siblings=obj.parentNode.childNodes;
	var i=0;
	while(siblings[i].nodeName.toUpperCase()!='INPUT')++i;
	siblings[i].value=Number(siblings[i].value)+1;
	var c=siblings[i].value;
	var parentsSiblings=obj.parentNode.parentNode.childNodes;
	i=0;
	var j=0;
	while(j<4){
		if(parentsSiblings[i].nodeName.toUpperCase()=='LI')j++;
		i++;
	}
	i-=1;
	var countParents=parentsSiblings[i].childNodes;
	i=0;
	while(countParents[i].nodeName.toUpperCase()!='SPAN')++i;
	countParents[i].innerHTML=c;
}

function countDown(obj){
	var siblings=obj.parentNode.childNodes;
	var i=0;
	while(siblings[i].nodeName.toUpperCase()!='INPUT')++i;
	siblings[i].value=Math.max(Number(siblings[i].value)-1,1);
	var c=siblings[i].value;
	var parentsSiblings=obj.parentNode.parentNode.childNodes;
	i=0;
	var j=0;
	while(j<4){
		if(parentsSiblings[i].nodeName.toUpperCase()=='LI')j++;
		i++;
	}
	i-=1;
	var countParents=parentsSiblings[i].childNodes;
	i=0;
	while(countParents[i].nodeName.toUpperCase()!='SPAN')++i;
	countParents[i].innerHTML=c;
}