// Video Menu
//===================
//$(document).ready(function() {$('img.vidlink').click(function () {$('ul.vidmenu').slideToggle('medium');});});


function showLookup() {document.getElementById('lightbox').style.visibility = 'visible';showLUContent();}
function hideLookup() {document.getElementById('lightbox').style.visibility = 'hidden';hideBack();}
function showBack() {document.getElementById('icon_back').style.visibility = 'visible';}
function hideBack() {document.getElementById('icon_back').style.visibility = 'hidden';}
/////////////////////////////////////////////////////////////////////////
// DA Lookup - return  
/////////////////////////////////////////////////////////////////////////
function showLUContent()
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="dir.htm"
	//url=url+"?vidnum="+uid
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=stateChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

function showPage(refpage)
{
	xmlHttp=GetXmlHttpObject()
	if (xmlHttp==null)
	 {
	 alert ("Browser does not support HTTP Request")
	 return
	 }
	var url="dag"+refpage+".htm"
	//url=url+"?vidnum="+uid
	//url=url+"&sid="+Math.random()
	xmlHttp.onreadystatechange=pageChanged 
	xmlHttp.open("GET",url,true)
	xmlHttp.send(null)
}

// Back button functionality
function goBack() {showLUContent();hideBack();}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	document.getElementById('lookupcontent').innerHTML=xmlHttp.responseText 
 } 
}

function pageChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
	document.getElementById('lookupcontent').innerHTML=xmlHttp.responseText 
	showBack()
 } 
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
////////////////////////////////////////////////////////
// End Ajax Video Return
////////////////////////////////////////////////////////



/////////////////////////////////////////////////////////////////////////////////////////////////////
//  Draggable Content ///////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////
function Browser() {

  var ua, s, i;

  this.isIE    = false;
  this.isNS    = false;
  this.version = null;

  ua = navigator.userAgent;

  s = "MSIE";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isIE = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  s = "Netscape6/";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = parseFloat(ua.substr(i + s.length));
    return;
  }

  // Treat any other "Gecko" browser as NS 6.1.

  s = "Gecko";
  if ((i = ua.indexOf(s)) >= 0) {
    this.isNS = true;
    this.version = 6.1;
    return;
  }
}

var browser = new Browser();

// Global object to hold drag information.

var dragEle = new Object();
dragEle.zIndex = 100;

function dragBox(event, id) {

  var el;
  var x, y;

  // If an element id was given, find it. Otherwise use the element being
  // clicked on.

  if (id)
    dragEle.elNode = document.getElementById(id);
  else {
    if (browser.isIE)
      dragEle.elNode = window.event.srcElement;
    if (browser.isNS)
      dragEle.elNode = event.target;

    // If this is a text node, use its parent element.

    if (dragEle.elNode.nodeType == 3)
      dragEle.elNode = dragEle.elNode.parentNode;
  }

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Save starting positions of cursor and elements
  dragEle.cursorStartX = x;
  dragEle.cursorStartY = y;
  dragEle.elStartLeft  = parseInt(dragEle.elNode.offsetLeft, 10);
  dragEle.elStartTop   = parseInt(dragEle.elNode.offsetTop,  10);

  // Update element's z-index.
  dragEle.elNode.style.zIndex = ++dragEle.zIndex;

  // Capture mousemove and mouseup events on the page.

  if (browser.isIE) {
    document.attachEvent("onmousemove", dragB);
    document.attachEvent("onmouseup",   dragStop);
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS) {
    document.addEventListener("mousemove", dragB,   true);
    document.addEventListener("mouseup",   dragStop, true);
    event.preventDefault();
  }
}

function dragB(event) {

  var x, y;

  // Get cursor position with respect to the page.

  if (browser.isIE) {
    x = window.event.clientX + document.documentElement.scrollLeft
      + document.body.scrollLeft;
    y = window.event.clientY + document.documentElement.scrollTop
      + document.body.scrollTop;
  }
  if (browser.isNS) {
    x = event.clientX + window.scrollX;
    y = event.clientY + window.scrollY;
  }

  // Move drag element by the same amount the cursor has moved.

  dragEle.elNode.style.left = (dragEle.elStartLeft + x - dragEle.cursorStartX) + "px";
  dragEle.elNode.style.top  = (dragEle.elStartTop  + y - dragEle.cursorStartY) + "px";

  if (browser.isIE) {
    window.event.cancelBubble = true;
    window.event.returnValue = false;
  }
  if (browser.isNS)
    event.preventDefault();
}

function dragStop(event) {

  // Stop capturing mousemove and mouseup events.

  if (browser.isIE) {
    document.detachEvent("onmousemove", dragB);
    document.detachEvent("onmouseup",   dragStop);
  }
  if (browser.isNS) {
    document.removeEventListener("mousemove", dragB,   true);
    document.removeEventListener("mouseup",   dragStop, true);
  }

}
