// Script Source: CodeLifter.com
// Copyright 2003
// Do not remove this header

isIE=document.all;
isNN=!document.all&&document.getElementById;
isN4=document.layers;
isHot=false;


startX = 600;
startY = 10;

function console_init() {
	var box = document.getElementById("theLayer");
	
	if (null != box)
	{
		if (null === getCookie("menuy"))
		{
			box.style.top = startY;	
		} else {
			box.style.top = getCookie("menuy");	
		}

		if (null === getCookie("menux"))
		{
			box.style.left = startX;	
		} else {
			box.style.left = getCookie("menux");	
		}
	}
}


function ddInit(e){
  topDog=isIE ? "BODY" : "HTML";
  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  
  hotDog=isIE ? event.srcElement : e.target;  
  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){
    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;
  }  
  if (hotDog.id=="titleBar"){
    offsetx=isIE ? event.clientX : e.clientX;
    offsety=isIE ? event.clientY : e.clientY;
    nowX=parseInt(whichDog.style.left);
    nowY=parseInt(whichDog.style.top);
    ddEnabled=true;
    document.onmousemove=dd;
  }
}

function dd(e){
  if (!ddEnabled)
  {
	var box = document.getElementById("theLayer");
	
  	//var boxX = document.getElementById("txtx");
	//var boxY = document.getElementById("txty");
	
	//boxX.innerText = getAbsX(box);
	//boxY.innerText = getAbsY(box);

	//deleteCookie("x");
	//deleteCookie("y");
	setCookie("menux", getAbsX(box));
	setCookie("menuy", getAbsY(box));
	
	
	return;
  }
  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 
  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;
  return false;  
}

function ddN4(whatDog){
  if (!isN4) return;
  N4=eval(whatDog);
  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);
  N4.onmousedown=function(e){
    N4.captureEvents(Event.MOUSEMOVE);
    N4x=e.x;
    N4y=e.y;
  }
  N4.onmousemove=function(e){
    if (isHot){
      N4.moveBy(e.x-N4x,e.y-N4y);
      return false;
    }
  }
  N4.onmouseup=function(){
    N4.releaseEvents(Event.MOUSEMOVE);
  }
}

function hideMe(){
  if (isIE||isNN) whichDog.style.visibility="hidden";
  else if (isN4) document.theLayer.visibility="hide";
}

function showMe(){
  if (isIE||isNN) whichDog.style.visibility="visible";
  else if (isN4) document.theLayer.visibility="show";
}

document.onmousedown=ddInit;
document.onmouseup=Function("ddEnabled=false");


function getAbsX(elt) { return parseInt(elt.x) ? elt.x : getAbsPos(elt,"Left"); };
function getAbsY(elt) { return parseInt(elt.y) ? elt.y : getAbsPos(elt,"Top"); };

function getAbsPos(elt,which)
{
	iPos = 0;
	
	while (elt != null) 
	{
		iPos += elt["offset" + which];
		elt = elt.offsetParent;
	}
	
	return iPos;
}



/**
 * Sets a Cookie with the given name and value.
 *
 * name       Name of the cookie
 * value      Value of the cookie
 * [expires]  Expiration date of the cookie (default: end of current session)
 * [path]     Path where the cookie is valid (default: path of calling document)
 * [domain]   Domain where the cookie is valid
 *              (default: domain of calling document)
 * [secure]   Boolean value indicating if the cookie transmission requires a
 *              secure transmission
 */
function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toGMTString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

/**
 * Gets the value of the specified cookie.
 *
 * name  Name of the desired cookie.
 *
 * Returns a string containing value of specified cookie,
 *   or null if cookie does not exist.
 */
function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

/**
 * Deletes the specified cookie.
 *
 * name      name of the cookie
 * [path]    path of the cookie (must be same as path used to create cookie)
 * [domain]  domain of the cookie (must be same as domain used to create cookie)
 */
function deleteCookie(name, path, domain)
{
    if (getCookie(name))
    {
        document.cookie = name + "=" + 
            ((path) ? "; path=" + path : "") +
            ((domain) ? "; domain=" + domain : "") +
            "; expires=Thu, 01-Jan-70 00:00:01 GMT";
    }
}


/**
 * Launches the Video Player Window.
 *
 */
function VideoLaunch() {
	var load = window.open('/greensboro/tools/playwindow.aspx','_video','scrollbars=no,menubar=no,height=423,width=655,resizable=yes,toolbar=no,location=no,status=no');
}

function VideoLaunch(type, feed) {
	var load = window.open('/greensboro/tools/playwindow.aspx?type=' + type +'&feed=' + feed,'_video','scrollbars=no,menubar=no,height=423,width=655,resizable=yes,toolbar=no,location=no,status=no');
}


