	/*
	* File: common.js
	* Author: Alex Baskov, Devtrix, 2008.
	*/


	////
	// submits search form
	//
	function submitSearch(frm)
	{
		var frm = frm || null;
		if (frm == null) return false;
	
		var keyword = trim(frm.elements.keyword.value);

		if (keyword != "")
		{
			if (keyword.length > 2)
			{
				document.getElementById('button_search').disabled = true;
				window.location = '/search/' + encodeURIComponent(keyword);
				return true;
			}
			else
			{
				str = "Занадто коротке слово для пошуку";
				alert(str);
			}
			
		}
		else
		{
			str = "Будь ласка, введіть слово для пошуку";
			alert(str);
		}

		return false;
	} // /changeClass()
	
	

	////
	// trims the string
	//
	function trim(stringToTrim) 
	{
		var stringToTrim = stringToTrim || "";
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	} // /trim()


	
	////
	// toggles catalog div overflows...
	//
	function toggle(elmID)
	{
		var elmID = elmID || 0;
		if (!(elmID > 0)) return false;

		if ( (zzb = document.getElementById('zzb_' + elmID)) && (zzn = document.getElementById('zzn_' + elmID)) && (zzt = document.getElementById('zzt_' + elmID)) )
		{
			// assuming title is 'main' elm
			if (!zzt.style.overflowY || zzt.style.overflowY == "hidden")
			{
				zzb.style.height = "auto";
				zzb.style.overflowY = "visible";

				zzn.style.height = "auto";
				zzn.style.overflowY = "visible";

				zzt.style.height = "auto";
				zzt.style.overflowY = "visible";

			}
			else
			{
				zzb.style.height = "13px";
				zzb.style.overflowY = "hidden";

				zzn.style.height = "13px";
				zzn.style.overflowY = "hidden";

				zzt.style.height = "13px";
				zzt.style.overflowY = "hidden";
			}
		}

		return true;
	} // /toggle()