
function OpenCategory(btn)
{
	var subList = btn;
	while(subList.nodeName.toLowerCase() != "ul")
	{
		subList = subList.nextSibling;
		if(typeof subList == "undefined" || subList == null)
			return;
	}
	
	if(getStyleAttr(subList, "display") == "none" || getStyleAttr(subList, "display") == 0)
	{
		subList.style.display = "block";
		btn.value = "-";
	}
	else
	{
		subList.style.display = "none";
		btn.value = "+";
	}
}

function OpenSubCategory(bullet)
{
	var subCatId = "SubCat_" + bullet.getAttribute("category");
	var sub = document.getElementById(subCatId);
	
	if(typeof(sub) == "undefined" || sub == null)
		return;
		
	if(getStyleAttr(sub, "display") == "none" || getStyleAttr(sub, "display") == 0)
	{
		sub.style.display = "block";
		bullet.style.backgroundImage = "url(./IMG/minus.gif)";
	}
	else
	{
		sub.style.display = "none";
		bullet.style.backgroundImage = "url(./IMG/plus.gif)";
	}
}
function SetBulletBackImg(bullet)
{
	var subCatId = "SubCat_" + bullet.getAttribute("category");
	var sub = document.getElementById(subCatId);
	
	if(typeof(sub) == "undefined" || sub == null)
		return;

	if(getStyleAttr(sub, "display") == "none" || getStyleAttr(sub, "display") == 0)
		bullet.style.backgroundImage = "url(./IMG/plus.gif)";
	else
		bullet.style.backgroundImage = "url(./IMG/minus.gif)";

	bullet.style.backgroundPosition = "center center";
	bullet.style.backgroundRepeat= "no-repeat";
}

function OpenForgotPass()
{
	var mail = document.getElementById("Login1_LoginUserBox").value;
	
	//User name girilmemisse			
	if(typeof mail == "undefined" || mail == null || mail == "")
	{
		alert(CustomGetLex("ERR_NOUSERNAME"));
		return;
	}

	features = "top=" + parseInt((screen.availHeight - 300) / 2) + "px,left=" + parseInt((screen.availWidth - 400)/2) + "px,height=300px,width=400px,status=no,titlebar=no,toolbar=no,menubar=no,location=no";
	window.open("utl/forgotmail.aspx?UserCode=" + mail, "_blank", features);
}

function IsEmail(str)
{	
	if(typeof str == "undefined" || str == null || str == "")
		return false;
	
	return str.match(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/i) != null;  
}

function StartSearch(srchBoxID)
{
	var srchStr = document.getElementById(srchBoxID).value;
	if(srchStr == "")
	{
		alert(CustomGetLex("MSG_ENTERSEARCHKEYS"));
		return;
	}
	window.open("?Action=Search&Keys=" + escape(srchStr), "_self");
}

function CheckEnterForSearch(e, srchBoxID)
{
	//if enter pressed
	if(e.keyCode == 13)
	{
		if(!isIE)
			e.preventDefault();
		StartSearch(srchBoxID);
		return false;
	}
		
	return true;	
}

function StartProdSearch(srchBoxID)
{
	var srchStr = document.getElementById(srchBoxID).value;
	if(srchStr == "")
	{
		alert(CustomGetLex("MSG_ENTERSEARCHKEYS"));
		return;
	}
	window.open("?Action=ShowProduct&Product=" + escape("AG-" + srchStr), "_self");
}

function CheckEnterForProdSearch(e, srchBoxID)
{
	//if enter pressed
	if(e.keyCode == 13)
	{
		if(!isIE)
			e.preventDefault();
		StartProdSearch(srchBoxID);
		return false;
	}
		
	return true;	
}

function CustomGetLex(lexCode)
{
	if(typeof(lexCode) != "string" || lexCode == "")
		return "";

	var msg = new XmlMessage("GetLex");
	msg.AddParam("LexCode", lexCode);
	msg.SendAndReceive();
	
	if(!msg.IsResponseReceived())
		return "";
	
	return msg.GetResponse("LexDesc");
}

function IsCtr(ctr)
{
	return (typeof(ctr)          != "undefined") && 
		   (ctr		             != null)        && 
		   (typeof(ctr.nodeType) != "undefined") && 
		   (ctr.nodeType         == 1);
}

