
	/*
	* File: common.js
	* Author: Alex Baskov, Devtrix, 2007-2008.
	*/


	////
	// changes style class of the object (i.e. class="newClass")
	//
	function changeClass(obj, newClass)
	{
		//alert(newClass);
		if (obj != null && newClass != null)
		{
			obj.className = newClass;
		}

		return true;
	} // /changeClass()



	////
	// onFocus and onBlur methods processing for top search input element
	//
	function toggleTopSearchInput(elm, opt)
	{

		if (!elm || elm == null) return false;

		if (opt == 1) // focus
		{
			if (elm.value == "" || elm.value == "Enter keyword")
			{
				elm.value = '';
				elm.style.fontStyle = 'normal';
				elm.style.color = '#000000';
			}
		}
		else // blur
		{
			if (elm.value == "" || elm.value == "Enter keyword")
			{
				elm.style.fontStyle = 'italic';
				elm.style.color = '#999999';
				elm.value = 'Enter keyword';
			}
		}

		return true;
	} // /toggleTopSearchInput()



	////
	// checks search form for a valid input
	//
	function validateTopSearch(frm)
	{
		if (!frm || frm == null) return false;

		if (frm.elements.q)
		{
			if (frm.elements.q.value == "" || frm.elements.q.value == "Enter keyword")
			{
				alert("Please, enter a keyword.");
				frm.elements.q.focus();
				return false;
			}
			else
			{
				// keyword was entered... allowing form submiting
				return true;
			}
		}
		else
		{
			alert("Input field not found.");
		}

		return false;
	} // /(validateTopSearch)



	function focusScheduleZip(elm)
	{
		if (!elm || elm == null) return false;

		elm.value='';
		elm.style.fontStyle='normal';
		elm.style.color='#000000';
	} // /focusScheduleZip()



	function selectTab(elmCommonID, tabToSelect, totalTabs)
	{
		if (!(elmCommonID != "" && tabToSelect > 0 && totalTabs >= tabToSelect)) return false;

		for (var i = 0; i <= totalTabs; i++)
		{
			elmTab = document.getElementById(elmCommonID + "_" + i);
			elmTabContent = document.getElementById(elmCommonID + "_content_" + i);

			if (elmTab && elmTabContent)
			{
				if (i != tabToSelect)
				{
					elmTab.className = elmCommonID;
					elmTabContent.style.display = "none";
				}
				else
				{
					elmTab.className = elmCommonID + "_active";
					elmTabContent.style.display = "block";
				}
			}
		}

		return true;
	}