/* Functions from Default.aspx file */
function bodyscroll() 
{
	var F=document.forms[0];
    F.ScrollTop.value=Body.scrollTop;
}

function SimulateGoSearchClicked(e)
{
  // Get the key code of the pressed key
  var key = null;
  if(window.event) // IE
  {
    key = event.keyCode
  }
  else 
  {
    if(e.which) // Netscape/Firefox/Opera
    {
    key = e.which
    }
  }

  if ((key == 13) && (this.value != '')) 
  {
    // Determine what control sent the event
    var btnClick = null;
    var b = null;
    if (!e) 
    {
      var e = window.event
    }
    if (e.target) 
    { 
      b = e.target
    }
    else 
    {
      if (e.srcElement) 
      {
        b = e.srcElement
      }
    }
    if (b.nodeType == 3) // defeat Safari bug
    {
      b = b.parentNode
    }
    //var b = document.activeElement; // document.activeElement is not supportet at Firefox - find something else
    if ( b != null )
    {
      switch(b.id.substr(b.id.lastIndexOf('_')+1)) // when using modules from DNN there is an extension for the control...
      {
        // Result search page
        case 'words': 
        case 'sort':
        case 'method':
          btnClick = document.getElementById('GoInPage');
          break;
        // Forums seach page
        case 'drpForums':  
        case 'drpType':
        case 'drpMethod':
        case 'txtSearch':
          btnClick = document.getElementById(b.id.substring(0,b.id.lastIndexOf('_')) + '_lnkSearch');
          break;
        // MainPage search page
        case 'searchfield': 
          btnClick = document.getElementById('Go');
          break;
      }
      
      btnClick.focus(); 
      btnClick.click();
    }
    return false;
  }
  else
    return true;
}

function GoSearch()
{
  var value = document.getElementById('searchfield').value;
  
  //document.location.href='Default.aspx?tabid=109&method=or&words=' + value;
  document.location.href='/Portals/0/Search/searchResults.htm?cx=007830758282692865437%3Adtektrihv0m&cof=FORID%3A9&q=' + value;
  return false;
}

/* openNewWindow - used for display a demo in a new window*/
function openNewWindow(newPageURL)
{
    window.open(newPageURL, "_blank","width=740px height=600px " +
        "resizable=no scrollbars=no menubar=no location=no status=no");
}

function openNewWindowWithSize(newPageURL, width, height)
{
   window.open(newPageURL, "_blank","width=" + width + "px height=" + height + "px " +
        "resizable=yes scrollbars=yes menubar=no location=no status=no");
}


/* openWMV - used for display a demo in a new window*/
function openWMV(wmvFile)
{
    var windowType = "_self";
// Not IE
    if (!document.all)
    {
        windowType = "_blank";
    }

    window.open(wmvFile, windowType);
}

/* FAQ function */
function ShowHide(quest)
{
    var questionId = quest.replace('-Ans','-Quest');
    var answ = document.getElementById(quest);
    if (answ != null)
    {
        var question = document.getElementById(questionId);
        if (answ.style.display == 'block')
        {
            answ.style.display = 'none';
            if (question != null)
            {
                question.style.fontWeight = "normal";
            }
        }
        else
        {
            answ.style.display = 'block';
            if (question != null)
            {
                question.style.fontWeight = "bold";
            }
        }
    }
}

/* FAQ function */
function ShowHideAll(category)
{
    var displayMode = "none";
    var fontWeight = "normal";
    var showAll = document.getElementById(category + '_ShowAll');
    if (showAll != null)
    {
        var text = document.getElementById(category + '_showHideText');
        if (showAll.value == "false")
        {
            displayMode = "none";
            fontWeight = "normal";
            showAll.value = "true";
            text.innerHTML = "Show all answers";
        }
        else
        {
            displayMode = "block";
            fontWeight = "bold";
            showAll.value = "false";
            text.innerHTML = "Hide all answers";
        }
    }
    var divs = document.getElementsByTagName("div"); 
    for (var i=0; i<divs.length; i++) 
    {
      if (divs[i].id.indexOf(category) == 0)
      {
        divs[i].style.display = displayMode; 
      }
    }
    var links = document.getElementsByTagName("a"); 
    for (var i=0; i<links.length; i++) 
    {
      if (links[i].id.indexOf(category) == 0)
      {
        links[i].style.fontWeight = fontWeight; 
      }
    }
}

/* UrchinTracker script*/
function identifiedUrchinTracker(id)
{
        var fromPage = location.pathname + location.search;
        if (fromPage == "/")
        {
                fromPage = "/Default.aspx";
        }
        var identifier = id + "_" + fromPage;
	urchinTracker(identifier);
}

function onPageShow()
{
	var obj;
	if (this.delegateObj)
	{
		obj = this.delegateObj;
		if (obj != null)
		{
			return obj.method.call(obj);
		}
	}
}




