function HandleAndroidMenuOver(e)
{
  window.AndroidAllowClick = false;
}

function HandleAndroidMenuClick(e)
{
  if(!window.AndroidAllowClick)
  {
    window.AndroidAllowClick = true;
    if(navigator.userAgent.toLowerCase().search('android') > -1)
      return false;
  }
  
  return true;
}


function stringEndsWith(self, s) { return self.length >= s.length && self.substr(self.length - s.length) == s; };

function setCatList(idCategory)
{
	var elem = document.getElementById('imgSubCat'+idCategory);
	var list = document.getElementById('subCatsList'+idCategory);
	
	if (elem && list)
	{
		if (stringEndsWith(elem.src, 'arrow-category.gif'))
		{
			if (subCats[idCategory] != "")
			{
				list.innerHTML = subCats[idCategory];
				list.style.display = "inline";
			}
			elem.src=JURL+'/www/img/arrow-category-down.gif';
			elem.style.height='10px';
		}
		else
		{
			elem.src=JURL+'/www/img/arrow-category.gif';
			elem.style.height='10px';
			if (subCats[idCategory] != "")
			{
				list.style.display = "none";
			}
		}
	}
}


	function toggle(theDiv) {
		var elem = document.getElementById(theDiv);
		elem.style.display = (elem.style.display == "none")?"":"none";
	}


	function createAjax()
	{
		var objectAjax=false;
		try {
			objectAjax = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try {
				objectAjax = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (E) {
				objectAjax = false;
			}
		}

		if (!objectAjax && typeof XMLHttpRequest!='undefined') {
			objectAjax = new XMLHttpRequest();
		}
		return objectAjax;
	}

	function FAjax (url,layer,values,method)
	{
		var ajax=createAjax();
		var contentLayer = document.getElementById(layer);

		if(method.toUpperCase()=='POST'){

		ajax.open ('POST', url, true);

		ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
					contentLayer.innerHTML='<div align="left">Logging in...<' + '/div>';
			}
			else if (ajax.readyState==4){
			
				if(ajax.status==200)
				{
					if(ajax.responseText.indexOf("passSh")==0)
						window.location = JURL+"/shippingInformation/";
					else if(ajax.responseText.indexOf("passCart")==0)
						window.location = JBASEURL + "cart/";
					else if(ajax.responseText.indexOf("pass")==0)
						window.location = JURL+"/myAccount/";
					else
						document.getElementById(layer).innerHTML=ajax.responseText;
				}
				else if(ajax.status==404)
					{

						contentLayer.innerHTML = "Message";
					}
				else
					{
						contentLayer.innerHTML = "Error: ".ajax.status;
					}
				}
			}
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajax.send(values);
			return;
		}

		if (method.toUpperCase()=='GET'){

			ajax.open ('GET', url, true);
			ajax.onreadystatechange = function() {
			if (ajax.readyState==1) {
					contentLayer.innerHTML="<div align='left'>Logging in...<" + "/div>";
			}
			else if (ajax.readyState==4){
				if(ajax.status==200){
					document.getElementById(layer).innerHTML=ajax.responseText;
				}
				else if(ajax.status==404)
					{

						contentLayer.innerHTML = "Message";
					}
					else
					{
						contentLayer.innerHTML = "Error: ".ajax.status;
					}
				}
			}
			ajax.setRequestHeader('Content-Type','application/x-www-form-urlencoded');
			ajax.send(null);
			return
		}
	}


