
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;
	}
	
	//Girilen user name e-mail degilse
	if(!IsEmail(mail))
	{
		alert(CustomGetLex("ERR_USERNAMEFORMAT"));
		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("utils/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+)+/i) == str;  
}

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 CustomGetLex(lexCode)
{
	if(typeof(lexCode) != "string" || lexCode == "")
		return "";

	var lexDesc = GetXMLRes("?Action=GetLex&LexCode=" + lexCode);

	if(lexDesc == null)
		return "";
	if(lexDesc.lenght > 5 && lexDesc.slice(0, 5) == "<html" || lexDesc.slice(0, 5) == "ERROR")
	{
		var w = window.open("", "error");
		w.document.write(lexDesc);
		return "";
	}
	
	return lexDesc;
}

function GetXMLRes(url)
{
	if(url.charAt(0) == "?")
		url = "http://" + window.location.host + window.location.pathname + url;

	var xmlHttp = CreateXmlHttp();
	xmlHttp.open("GET", url, false);	
	xmlHttp.send("");

	return xmlHttp.responseText;
}

function CreateXmlHttp()
{
	try 
	{
		if (window.XMLHttpRequest) 
		{
			var req = new XMLHttpRequest();
			return req;
		}
		if (window.ActiveXObject) {
			return new ActiveXObject("Msxml2.XmlHttp");
		}
	}
	catch (ex) {}
	throw new Error("Your browser does not support XmlHttp objects");
}

function CreateXmlDocument()
{
	try 
	{
		if (document.implementation && document.implementation.createDocument) 
		{
			var doc = document.implementation.createDocument("", "", null);
			return doc;
		}
		if (window.ActiveXObject)
		{
			var xml = new ActiveXObject("Msxml2.DOMDocument");
			return xml;
		}
	}
	catch (ex) {}
	throw new Error("Your browser does not support XmlDocument objects");
}

function IsCtr(ctr)
{
	return (typeof(ctr)          != "undefined") && 
		   (ctr		             != null)        && 
		   (typeof(ctr.nodeType) != "undefined") && 
		   (ctr.nodeType         == 1);
}
