// Enables an imput element.

function enableInput(inputId)

{

	inputElement = document.getElementById(inputId);

	if (inputElement != null)

	{

		inputElement.disabled = false;

	}

}



// changes a hidden block tag to be displayed, or vice versa

function toggleBlock(tagId)

{

	blockTag = document.getElementById(tagId);

	if (blockTag != null)

	{

		if (blockTag.style.display == "none") {

			blockTag.style.display = "block";

		} else {

			blockTag.style.display = "none";

		}

	}

}



// changes all hidden blocks with same name (indexed by a number)

function toggleBlockAll(tagId)

{

	if (document.getElementById)

	{

		for (var i = 1; i <= 100; i++)

		{

			toggleBlock(tagId + i)

		}

	}

}



// changes all checkboxes with same name (indexed by a number) to be activated

function toggleCbAll(selected, tagId)

{

	if (document.getElementById)

	{

		for (var i = 1; i <= 100; i++)

		{

			if (checkbox = document.getElementById(tagId + i))

			{

				if (checkbox.checked != selected) {

					checkbox.checked = selected;

					checkbox.onclick();

				}

			}

		}

	}

}



// Shows/hides a filter's contents.

function showHide(filterId)

{

	var filterElm = document.getElementById(filterId);

	var headerElm = document.getElementById(filterId + '-header');

	if (filterElm)

	{

		if (filterElm.style.display != "block")

		{

			filterElm.style.display = "block";

			if (headerElm)

				headerElm.className = "minus";

		}

		else

		{

			filterElm.style.display = "none";

			if (headerElm)

				headerElm.className = "plus";

		}

	}

}

// Shows/hides a filter's contents.

function showHideList(listId)

{

	var listElm = document.getElementById(listId);

	var headerElm = document.getElementById(listId + '-header');

	if (listElm)

	{

		if (listElm.style.display != "block")

		{

			listElm.style.display = "block";

			if (headerElm){

				headerElm.className = "minus";
            }
		}

		else

		{
		    var isSelected = "no";
			$123('a#' + listId + '-header input').each(function(cb){
			  if(cb.checked){
			  	isSelected = "yes";
			  }
			});
			if (isSelected == "yes"){
			  return;
			}else{
			  $123('div#' + listId + ' input').each(function(cb){
			  	if (cb.checked){
			  		isSelected = "yes";
			  	}
			  });
			}
			if (isSelected == "yes") {
			  return;
			}else{
				listElm.style.display = "none";
	
				if (headerElm){
	
					headerElm.className = "plus";
				}
	        }
		 }

	}

}



// Shows/hides the filter tab.

function tabToggle(column, image, subMenu)

{

	var contentArea = document.getElementById(column);

	var theImage = document.getElementById(image);

	var subMenuArea = document.getElementById(subMenu);

	if (subMenuArea)

	{

		if (subMenuArea.style.display !="block")

		{

			subMenuArea.style.display = "block";

			if (contentArea)

				contentArea.className = "column1";

			theImage.setAttribute("src", "/images/filter_images/hide-filter.jpg");

			theImage.setAttribute("alt", "Hide filter menu");

			theImage.setAttribute("className", "tabon");

		}

		else

		{

			subMenuArea.style.display = "none";

			if (contentArea)

				contentArea.className = "columnfull";

			theImage.setAttribute("src", "/images/filter_images/show-filter.jpg");

			theImage.setAttribute("alt", "Show filter menu");

			theImage.setAttribute("className", "taboff");

		}

	}

}



/***********************************************

* Drop Down/ Overlapping Content- © Dynamic Drive (www.dynamicdrive.com)

* This notice must stay intact for legal use.

* Visit http://www.dynamicdrive.com/ for full source code

***********************************************/

function getposOffset(overlay, offsettype)

{

	var totaloffset = (offsettype=="left") ? overlay.offsetLeft : overlay.offsetTop;

	var parentEl = overlay.offsetParent;

	while (parentEl != null)

	{

		totaloffset = (offsettype=="left") ? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;

		parentEl = parentEl.offsetParent;

	}

	return totaloffset;

}



function overlay(curobj, subobjstr, opt_position)

{

	if (document.getElementById)

	{

		var subobj = document.getElementById(subobjstr)

		subobj.style.display = (subobj.style.display!="block") ? "block" : "none"

		var xpos = getposOffset(curobj, "left")+((typeof opt_position!="undefined" && opt_position.indexOf("left")!=-1) ? -(subobj.offsetWidth-curobj.offsetWidth)-80 : 0)

		var ypos = getposOffset(curobj, "top")+((typeof opt_position!="undefined" && opt_position.indexOf("bottom")!=-1) ? curobj.offsetHeight : 0)

		subobj.style.left = xpos+"px"

		subobj.style.top = (ypos - 258)+"px"

		return false

	}

	return true

}



