function openMenu(p_num)
{
        myRand=parseInt(Math.random()*99999999);
	setCookie("menu_num",p_num,1000);
        HTML_AJAX.replace('menu_content', 'ajax/getmenu.php?menu='+p_num);
	//window.location="menu.php?menu="+p_num;
}

function customisePizza(p_prod_id, p_num, p_prpr_id)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('menuItem'+p_prod_id, 'ajax/customise.php?prpr_id='+p_prpr_id+'&orpr_num='+p_num);
}

function resetPizza(p_prod_id, p_num, p_prpr_id)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('menuItem'+p_prod_id, 'ajax/uncustomise.php?prpr_id='+p_prpr_id+'&orpr_num='+p_num);
}

function resetMenu(p_prod_id, p_prpr_id)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('menuItem'+p_prod_id, 'ajax/uncustomisemenu.php?prpr_id='+p_prpr_id);
}

function replaceImages()
{
        replacement();
}

function addDips(p_num, p_prpr_id)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('menu_content', 'ajax/add_dip.php?prpr_id='+p_prpr_id+'&orpr_num='+p_num);
}

function customiseMenu(p_mede_id)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('menuItem'+p_mede_id, 'ajax/customisemenu.php?mede_id='+p_mede_id);
}

function addProduct(p_num, p_prpr_id)
{
        myRand=parseInt(Math.random()*99999999);
	HTML_AJAX.replace('checkout','ajax/add_product.php?orpr_num='+p_num+'&prpr_id='+p_prpr_id+'&rand='+myRand);
}

function deleteProduct(p_orpr_id)
{
	HTML_AJAX.replace('checkout','ajax/delete_product.php?orpr_id='+p_orpr_id);
}

function addCustomPizza()
{
	HTML_AJAX.formSubmit(document.getElementById('custompizza'),'checkout');
}

function addCustomDips()
{
	HTML_AJAX.formSubmit(document.getElementById('adddip'),'checkout');
}

function addCustomMenu()
{
	HTML_AJAX.formSubmit(document.getElementById('custommenu'),'checkout');
}

function redeemDiscountVoucher(p_divo_code, p_orde_id)
{
        myRand=parseInt(Math.random()*99999999);
	HTML_AJAX.replace('checkout', 'ajax/add_discount.php?code='+p_divo_code+'&rand='+myRand);
}

function setOrdeTwentyMin(p_orde_twenty, p_orde_id)
{
        myRand=parseInt(Math.random()*99999999);
	HTML_AJAX.replace('checkout', 'ajax/change_orde_twenty_flag.php?flag='+p_orde_twenty+'&rand='+myRand);
}

function executecheckout()
{
	HTML_AJAX.formSubmit(document.getElementById('checkout_form'),'checkout');
}

function updateTopping(p_num,p_topp_id)
{
	if (document.getElementById("top"+p_topp_id).value==1)
	{
		document.getElementById("x1"+p_topp_id).src="images/general/x1.png";
	}
	else
	if (document.getElementById("top"+p_topp_id).value==2)
	{
		document.getElementById("x2"+p_topp_id).src="images/general/x2.png";
	}
	else
	if (document.getElementById("top"+p_topp_id).value==3)
	{
		document.getElementById("lhalf"+p_topp_id).src="images/general/lhalf.png";
	}
	else
	if (document.getElementById("top"+p_topp_id).value==4)
	{
		document.getElementById("rhalf"+p_topp_id).src="images/general/rhalf.png";
	}

	if (p_num==document.getElementById("top"+p_topp_id).value)
	{
		p_num=0;
	}

	if (p_num==1)
	{
		document.getElementById("x1"+p_topp_id).src="images/general/x1H.png";
	}
	else
	if (p_num==2)
	{
		document.getElementById("x2"+p_topp_id).src="images/general/x2H.png";
	}
	else
	if (p_num==3)
	{
		document.getElementById("lhalf"+p_topp_id).src="images/general/lhalfH.png";
	}
	else
	if (p_num==4)
	{
		document.getElementById("rhalf"+p_topp_id).src="images/general/rhalfH.png";
	}
	
	document.getElementById("top"+p_topp_id).value=p_num;
}

function pulseStoreLocate(p_city_name, p_street_name, p_house_name)
{
	var cityid=document.getElementById(p_city_name).value;
	var streetid=document.getElementById(p_street_name).value;
	var housenum=document.getElementById(p_house_name).value;
	//if (cityid>0 && streetid>0)
	//{
        	myRand=parseInt(Math.random()*99999999);
        	HTML_AJAX.replace('storetd', 'ajax/pulse_store_locate.php?city_id='+cityid+'&stre_id='+streetid+'&housenum='+housenum+'&rand='+myRand);
	//}
}

function storeLocate(p_city_name, p_street_name, p_house_name)
{
	var cityid=document.getElementById(p_city_name).value;
	var streetid=document.getElementById(p_street_name).value;
	var housenum=document.getElementById(p_house_name).value;
	if (cityid>0 && streetid>0)
	{
        	myRand=parseInt(Math.random()*99999999);
        	HTML_AJAX.replace('storetd', 'ajax/store_locate.php?city_id='+cityid+'&stre_id='+streetid+'&housenum='+housenum+'&rand='+myRand);
	}
}

function loadPulseStreetDropdown(p_city_id, p_street_name, p_width)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('streetDD', 'ajax/get_pulse_street_dropdown.php?width='+p_width+'&city_id='+p_city_id+'&street_name='+p_street_name+'&rand='+myRand);
}

function loadStreetDropdown(p_city_id, p_street_name, p_width)
{
        myRand=parseInt(Math.random()*99999999);
        HTML_AJAX.replace('streetDD', 'ajax/get_street_dropdown.php?width='+p_width+'&city_id='+p_city_id+'&street_name='+p_street_name+'&rand='+myRand);
}

function setCookie(c_name,value,expiredays)
{
	var exdate=new Date();
	exdate.setDate(exdate.getDate()+expiredays);
	document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function updateLeftNavGraphics(p_num,p_lang)
{
        var el;

        for (i=1;i<=8;i++)
        {
                el=document.getElementById('menuBtn'+i);
		if (el!=null)
		{
                	if (i==p_num)
			{
				el.className="active";
			}
			else
			{
				el.className="inactive";
			}
		}

                el=document.getElementById('leftnav_'+p_lang+'_0'+i);
		if (el!=null)
		{
                	if (i==p_num && el!=null)
                	{
                        	el.className="leftNavOn";
                	}
                	else
                	{
                        	el.className="leftNavOff";
                	}
		}
        }
}
