<!--
bShowPreview = false;

function switchPreview( id, url, anchor )
{
	if(id)
	{
                if (anchor) document.previewForm.action += "#" + anchor;
		document.previewForm.preview.value = id;
		document.previewForm.submit();
	}
}

function scrollToElement( elementDefault, element )
{
   if( element ) {
      setTimeout(function() {element.scrollIntoView();}, 300);
   }
   else if ( elementDefault ) {
      setTimeout(function() {elementDefault.scrollIntoView();}, 300);
   }
}

	function switchSortByGroupBy(obj)
	{
		var frm = obj.form;

		if( frm.answerSortOrGroup[1].checked == true)	{
			frm.answerSortBy.disabled = true;
			frm.answerGroupBy.disabled = false;
			checkIfGroupByIsActive(obj);
		}
		else if(frm.answerSortOrGroup[0].checked == true)	{
			frm.answerSortBy.disabled = false;
			frm.answerGroupBy.disabled = true;
			frm.answerSortGroupBy.disabled = true;
		}
	}

	function checkIfGroupByIsActive(obj)
	{
		var frm = obj.form;

		if(frm.answerSortOrGroup[0].checked == true)	{
			frm.answerGroupBy.disabled = true;
			frm.answerSortGroupBy.disabled = true;
		}
		else	{
			frm.answerSortBy.disabled = true;
			frm.answerGroupBy.disabled = false;

			if(frm.answerGroupBy.selectedIndex != 0)	{
				frm.answerSortGroupBy.disabled = false;
			}
			else
				frm.answerSortGroupBy.disabled = true;
		}
	}

	function onLoadEvents(parentCategory)
	{
		if(document.advancedUIForm)
		{

			var blnAtLeastOneIsChecked = false;
			var blnFoundUnChecked = false;

			/*
				variable to populate the hidden field which tracks the
				chechbox state (checked/unchecked) for each checkbox
				(applies to both the 'Document Formats' and the 'Document Sources'
				checkbox selections)
			*/
			var str_hdnformat = new String("");
			str_hdnformat = "true";

			for(i=1; i < document.advancedUIForm.selectedFormatItems.length; i++)
			{
				if(str_hdnformat.length > 0)
					str_hdnformat += ",";

				if(document.advancedUIForm.selectedFormatItems[i].checked == false)	{
					blnFoundUnChecked = true;
					str_hdnformat += "false";
				}
				else	{
					blnAtLeastOneIsChecked = true;
					str_hdnformat += "true";
				}
			}

			if( (blnFoundUnChecked) && (blnAtLeastOneIsChecked) )	{
				document.advancedUIForm.selectedFormatItems[0].checked = true;
				document.advancedUIForm.selectedFormatItems[0].disabled = true;
			}

			//set the hidden field with the 'Document Format' checkbox selections
			document.advancedUIForm.hdn_formats.value = str_hdnformat;

			//reset booleans
			blnAtLeastOneIsChecked = false;
			blnFoundUnChecked = false;

			/*
				variable to populate the hidden field which tracks the
				chechbox state (checked/unchecked) for each checkbox
				(applies to both the 'Document Formats' and the 'Document Sources'
				checkbox selections)
			*/
			var str_hdnsources = new String("");
			str_hdnsources = "true";

			var frm = document.advancedUIForm;
			if(typeof(frm.answerSortOrGroup) != "undefined")
				checkIfGroupByIsActive(frm.answerSortOrGroup[0]);

			if (typeof(frm.product) != "undefined")	{
				if(frm.product.selectedIndex == -1)
					frm.product.selectedIndex = 0;

				if (typeof(frm.product_all) != "undefined")	{
					if(frm.product.selectedIndex == 0)
						frm.elements["product_all"].value = "true";
					else
						frm.elements["product_all"].value = "false";
				}
			}

			if (typeof(frm.topic) != "undefined")	{
				if(frm.topic.selectedIndex == -1)
					frm.topic.selectedIndex = 0;

				if (typeof(frm.topic_all) != "undefined") 	{
					if(frm.topic.selectedIndex == 0)
						frm.elements["topic_all"].value = "true";
					else
						frm.elements["topic_all"].value = "false";
				}
			}
		}

		if(document.optionForm)	{
			var frm = document.optionForm;
			if(typeof(frm.answerSortOrGroup) != "undefined")
				checkIfGroupByIsActive(frm.answerSortOrGroup[0]);
		}

		if(document.uiForm)	{
			var frm = document.uiForm;

			if(typeof(frm.answerSortOrGroup) != "undefined")
				checkIfGroupByIsActive(frm.answerSortOrGroup[0]);
		}

		if(document._advisorIFrameLink)
		   openAdvisorIFrame(document._advisorIFrameLink, document._advisorIFrameName);

		if( bShowPreview ) loadLayer();

	}


windowCounter=0;
function openResult(url){
   if(target=="answerwindow"){
      newWindow = window.open(url.href,"answerWindow"); newWindow.focus();
   }
   else if(target=="_blank"){
      var d = new Date();
      newWindow = window.open(url.href,'window' + d.getMilliseconds() + d.getSeconds() + d.getMinutes() + d.getHours() + d.getDay());newWindow.focus();
      windowCounter++;
   }
   else{
      window.location=url.href;
   }
   return false;
}


//-->