// var lin = 0;

var dataname
var checkIt

function findPosX(obj)
{
	var curleft = 0;
	if (document.getElementById)
	{
		while (obj.offsetParent)
		{
			curleft += obj.offsetLeft
			obj = obj.offsetParent;
		}
	}
	return curleft;
}

function findPosY(obj)
{
	var curtop = 0;
	var printstring = '';
	if (document.getElementById)
	{
		while (obj.offsetParent)
		{
			curtop += obj.offsetTop
			obj = obj.offsetParent;
		}
	}
	return curtop;
}
function clearUserInput()
{
	if (checkIt) clearTimeout(checkIt);
}
function checkUserInput()
{
	if (checkIt) clearTimeout(checkIt);
	checkIt = setTimeout('closeAll()',1000);
}
function closeAll() {
x=document.getElementById('moverreadout')
document.getElementById('cloak').appendChild(x);
}

function setLyr(obj,lyr) {
	var newX = findPosX(obj)
	var newY = findPosY(obj)
	x=document.getElementById('moverreadout')
	x.style.position = 'absolute';
	x.style.top = newY + 'px';
	x.style.left = newX+150+'px';
	x.innerHTML= document.getElementById(obj.thiscolor).innerHTML
	x.style.visibility="visible"
	obj.appendChild(x);
	document.getElementById('news').appendChild(x);
	outy=newY
}


/* tree menu */

var exploreinput

function makeTrees() {
    // We don't actually need createElement, but we do
    // need good DOM support, so this is a good check.
    if (!document.createElement) return;
    
    uls = document.getElementsByTagName("ul");
    for (uli=0;uli<uls.length;uli++) {
        ul = uls[uli];
        if (ul.nodeName == "UL" && ul.className == "tree") {
            processULEL(ul);
        }
    }
}

function processULEL(ul) {
    if (!ul.childNodes || ul.childNodes.length == 0) return;
    // Iterate LIs
    for (var itemi=0;itemi<ul.childNodes.length;itemi++) {
        var item = ul.childNodes[itemi];
        if (item.nodeName == "LI") {
            // Iterate things in this LI
            var a;
            var subul;
            for (var sitemi=0;sitemi<item.childNodes.length;sitemi++) {
                var sitem = item.childNodes[sitemi];
                switch (sitem.nodeName) {
                    case "A": a = sitem; break;
                    case "UL": subul = sitem; 
                               processULEL(subul);
                               break;
                }
            }
            if (subul) {
                associateEL(a,subul);
            } else {
              //  a.parentNode.style.listStyleImage = "url(/glasto/images/pieces/bullets/bullet.gif)";
            }
        }
    }
}

function associateEL(a,ul) { // lin=lin+1; alert('associateEL'+lin);
    a.onclick = function () {
        var display = ul.style.display;
        //this.parentNode.style.listStyleImage = (display == "block") ? "url(/glasto/images/pieces/bullets/plus.gif)" : "url(/glasto/images/pieces/bullets/minus.gif)";
        ul.style.display = (display == "block") ? "none" : "block";
        return false;
    }

    a.onmouseover = function() {
        var display = ul.style.display;
        window.status = (display == "block") ? "Collapse" : "Expand";
	return true;
    }

    a.onmouseout = function() {
        window.status = "";
	return true;
    }
}


function wherewhatinit(elm) {
n=document.getElementById(elm);
var a=n.getElementsByTagName("li");
for (var i=0; i<a.length; i++) {
  var el = a[i];
  if (el.className == "flytrig") {
		el.thiscolor = el.getAttribute('ID')+'areas';
		el.onmouseover = function() {
		setLyr(this,'moverreadout');
		clearUserInput()
    }
	el.onmouseout = function() {
    	checkUserInput()
	}
}
}
}

function galleryPop(theURL,w,h) {
  if(w==null) w = 580;
  if(h==null) h = 360;
  window.open(theURL,'gallery','width='+w+',height='+h+',scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no,resizable=no,copyhistory=no,alwaysraised=yes,hotkeys=no,titlebar=no');

}

function mailPop(name) {
  var contURL = '/dyn/contact/~'+name+'/';
  window.open(contURL,'mailform','width=480,height=430,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no,resizable=yes,copyhistory=no,alwaysraised=yes,hotkeys=no,titlebar=no');
}

//cookie stuff

function bannerPop(theURL) {
	window.open(theURL,'popban','width=480,height=120,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no,status=no,resizable=no,copyhistory=no,alwaysraised=yes,hotkeys=no,titlebar=no');
}

function CheckCookieOrPopup() {
  if (glasto_getcookie() == 0) {
	var internal_date = new Date();
 	var expires = new Date(internal_date.getTime() + 3600000); // now + 1 hour
	document.cookie = "glasto_popup=seen; expires=" + expires.toGMTString() +';path=/;domain=.glastonburyfestivals.co.uk';
	
	popMe = bannerPop('/2003/images/adverts/popup.html');
  }
}

function glasto_getcookie(){
  var name="glasto_popup";
  var cc="; "+document.cookie+";";
  var start=cc.lastIndexOf('; '+name+'=');

  if (start<0) return 0;
  return 1;
}

var start_countdown

//start it up
window.onload=function() {
	if (document.getElementById)
	{
wherewhatinit('news')

makeTrees();
if (start_countdown) {
start_countdown(); // front page countdown gizmo
}
// CheckCookieOrPopup();
	}
}

