function uptext(obj) {
	if(obj.checked && !(parseInt(document.getElementById(obj.id+'q').value) > 0)) {
		document.getElementById(obj.id+'q').value="1";
	}
	else {
		document.getElementById(obj.id+'q').value="0";
	}
}

/*function upcheck(obj,item,addto,checkboxid) {
	if(parseInt(obj.value) > 0) {
		document.getElementById(obj.id.substr(0,obj.id.length-1)).checked=true;
	}
	else {
		document.getElementById(obj.id.substr(0,obj.id.length-1)).checked=false;
	}
}*/

function incq(obj,val,br) {
	if(val == 'up')
		document.getElementById(obj.id+'q').value++;

	if(document.getElementById(obj.id+'q').value > 0)
	{
		if(val == 'down')
			document.getElementById(obj.id+'q').value--;
	}

	//call this function to check or uncheck the box
	//upcheck(document.getElementById(obj.id+'q'));

	//call this function to show or hide the tick
	tick(obj,br);
}

function tick(obj,br)
{
	if(document.getElementById(obj.id+'q').value > 0)
	{
		obj.style.display='block';
	}
	else
	{
		obj.style.display='none';
	}
}

function show_extras(str,o,br,force) {
	var i=0;
	var obj;

	if(br == "MSIE")
	{
		if(o.innerHTML == '<IMG hspace=2 src="http://www.mekoota.com/plus.gif">' || force=='open')
		{
			o.innerHTML = '<img src="minus.gif" hspace="2">';

			while(obj = document.getElementById(str+'_'+i))
			{
				obj.style.display = 'block';
				i++;
			}
		}
		else
		{
			o.innerHTML = '<IMG hspace=2 src="http://www.mekoota.com/plus.gif">';

			while(obj = document.getElementById(str+'_'+i))
			{
				obj.style.display = 'none';
				i++;
			}
		}
	}
	else
	{
		if(o.innerHTML == '<img src="http://www.mekoota.com/plus.gif" hspace="2">' || force=='open')
		{
			o.innerHTML = '<img src="http://www.mekoota.com/minus.gif" hspace="2">';
	
			while(obj = document.getElementById(str+'_'+i))
			{
				obj.style.visibility = 'visible';
				i++;
			}
		}
		else
		{
			o.innerHTML = '<img src="http://www.mekoota.com/plus.gif" hspace="2">';

			while(obj = document.getElementById(str+'_'+i))
			{
				obj.style.visibility = 'collapse';
				i++;
			}
		}
	}
}

function changeScreenSize(w,h,left,top)
{
	window.resizeTo(w,h)
	window.moveTo(left, top)
}

function CreateBookmarkLink(browser,side)
{
	if(side=="ADMIN")
	{
		var urlAddress = "http://www.mekoota.com/admin";
		var pageName = "MeKoota.com Administration";
	}
	else
	{
		var urlAddress = "http://www.mekoota.com";
		var pageName = "MeKoota.com - eCatering by MeKoo";
	}
		
	if(browser=="MSIE")
		window.external.AddFavorite(urlAddress,pageName)
	else
		window.sidebar.addPanel(pageName, urlAddress,"");
}

function emptyEBox(obj)
{
	var val = obj.value;
	if(val == "Comments")
		obj.value='';
}

function pageLoader(value,category,page)
{
	if(category == "productType" && page == "add")
	{
		window.location = "addProduct.php?prodType="+value;
	}

	if(category == "value" && page == "add")
	{
		window.location = "addProduct.php?value="+value;
	}

	if(category == "productType" && page == "mod")
	{
		window.location = "modifyProduct.php?prodType="+value;
	}

	if(category == "value" && page == "mod")
	{
		window.location = "modifyProduct.php?value="+value;
	}

	if(category == "building_id" && page == "createAcc")
	{
		window.location = "createAccount.php?building_id="+value;
	}

	if(category == "building_id" && page == "confirmOrder")
	{
		window.location = "confirmOrder.php?building_id="+value;
	}

	if(category == "cafe_id" && page == "order")
	{
		window.location = "order.php?customerCafe="+value;
	}

	if(category == "cafe_id" && page == "addProdType")
	{
		window.location = "addProductType.php?cafe_id="+value;
	}

	if(category == "cafe_id" && page == "searchProdType")
	{
		window.location = "searchProductType.php?cafe_id="+value;
	}

	if(category == "cafe_id" && page == "addExtra")
	{
		window.location = "addExtra.php?cafe_id="+value;
	}

	if(category == "cafe_id" && page == "addProd")
	{
		window.location = "addProduct.php?cafe_id="+value;
	}

	if(category == "cafe_id" && page == "searchProd")
	{
		window.location = "searchProducts.php?cafe_id="+value;
	}
}

function goThere(address,email,type)
{
	if(type=='remFromBl')
		var result = window.confirm("Are you sure you want to remove "  + email + " from the blacklist?");

	if(type=='blacklist')
		var result = window.confirm("Are you sure you want to blacklist "  + email + "?");

	if(type=='site_status')
		var result = window.confirm("Are you sure you want to change the status to: " + email + "?");

	if(result==true)
		window.location=address;
}

function toggleArea(brw,page)
{
	if(brw == 'MSIE')
	{
		if(page == "beverages")
		{
			document.getElementById('beverages').style.display = 'block';
			document.getElementById('bevBut').src = 'beveragesTabBig.jpg';
			document.getElementById('fooBut').src = 'foodsTab.jpg';
			document.getElementById('foods').style.display = 'none'
			
		}

		if(page == "foods")
		{
			document.getElementById('beverages').style.display = 'none';
			document.getElementById('bevBut').src = 'beveragesTab.jpg';
			document.getElementById('fooBut').src = 'foodsTabBig.jpg';
			document.getElementById('foods').style.display = 'block'
		}
	}
	else
	{
		if(page == "beverages")
		{
			document.getElementById('beverages').style.visibility = 'visible';
			document.getElementById('bevBut').src = 'beveragesTabBig.jpg';
			document.getElementById('fooBut').src = 'foodsTab.jpg';
			document.getElementById('foods').style.visibility = 'collapse'
		}

		if(page == "foods")
		{
			document.getElementById('beverages').style.visibility = 'collapse';
			document.getElementById('bevBut').src = 'beveragesTab.jpg';
			document.getElementById('fooBut').src = 'foodsTabBig.jpg';
			document.getElementById('foods').style.visibility = 'visible'
		}
	}
}

function disen()
{
	if(document.getElementById("de").checked)
	{
		document.getElementById('catering').style.display = 'block'
	}

	if(document.getElementById("pu").checked)
	{
		document.getElementById('catering').style.display = 'none'
	}
}

function showPassword()
{
	if(document.getElementById('showPassword').style.display == 'block')
	{
		document.getElementById('showPassword').style.display = 'none';
	}
	else if(document.getElementById('showPassword').style.display == 'none')
	{
		document.getElementById('showPassword').style.display = 'block';
	}
}

