var ContentHeight = 00;
var TimeToSlide = 250.0;

var openAccordion = '';
var rtArrow=new Image(6,9);
rtArrow.src="../images/w-rt-arrow.gif";
var dnArrow=new Image(9,6);
dnArrow.src="../images/w-dn-arrow.gif";
var lastIndex = "";
var elmntId = "";
var oldElId = "";

function runAccordion(index)
{
var nID = "Accordion" + index + "Content";
elmntId = "Arrow" + index;
if(lastIndex != "") {
	oldElId =  "Arrow" + lastIndex;
}

if(openAccordion == nID)
nID = '';


setTimeout("animate("
  + new Date().getTime() + "," + TimeToSlide + ",'"
  + openAccordion + "','" + nID + "')", 33);

openAccordion = nID;
lastIndex  = index;
}
function animate(lastTick, timeLeft, closingId, openingId)
{
var curTick = new Date().getTime();
var elapsedTicks = curTick - lastTick;

var opening = (openingId == '') ? null : document.getElementById(openingId);
var closing = (closingId == '') ? null : document.getElementById(closingId);

if(timeLeft <= elapsedTicks)
{
if(opening != null)
{
  opening.style.height = 'auto';
//opening.style.height = ContentHeight + 'px';
ContentHeight = document.getElementById(openingId).offsetHeight;
}

if(closing != null)
{
  closing.style.display = 'none';
  closing.style.height = '0px';

}
return;
}

timeLeft -= elapsedTicks;
var newClosedHeight = Math.round((timeLeft/TimeToSlide) * ContentHeight);

if(opening != null)
{
if(opening.style.display != 'block')
  opening.style.display = 'block';
opening.style.height = (ContentHeight - newClosedHeight) + 'px';
document.getElementById(elmntId).src=dnArrow.src;
}

if(closing != null)
{
closing.style.height = newClosedHeight + 'px';
document.getElementById(oldElId).src=rtArrow.src;
}
setTimeout("animate(" + curTick + "," + timeLeft + ",'"
  + closingId + "','" + openingId + "')", 33);

}
function checkdetails(form) {
	//< ![CDATA[
	if(form.Schoolname.value=="") {
		alert("Please enter the name of your School or College.");
		form.Schoolname.focus();
		return false;
	}
	if(form.Postcode.value=="") {
		alert("Please enter your postcode.");
		form.Postcode.focus();
		return false;
	}
	if(form.Name.value=="") {
		alert("Please enter your name.");
		form.Name.focus();
		return false;
	}
	if(form.Position.value=="") {
		alert("Please enter your job title.");
		form.Position.focus();
		return false;
	}
	if(form.Email.value=="") {
		alert("Please enter a valid email address.");
		form.Email.focus();
		return false;
	}
	if(form.Pupilnumbers.value=="") {
		alert("Please enter the number of pupils/students.");
		form.Pupilnumbers.focus();
		return false;
	}
}
function getElementLeft(elm) 
{
    var x = 0;

    //set x to elm’s offsetLeft
    x = elm.offsetLeft;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        x = parseInt(x) + parseInt(elm.offsetLeft);
        elm = elm.offsetParent;
    }
    return x;
}

function getElementTop(elm) 
{
    var y = 0;

    //set x to elm’s offsetLeft
    y = elm.offsetTop;

    //set elm to its offsetParent
    elm = elm.offsetParent;

    //use while loop to check if elm is null
    // if not then add current elm’s offsetLeft to x
    //offsetTop to y and set elm to its offsetParent

    while(elm != null)
    {
        y = parseInt(y) + parseInt(elm.offsetTop);
        elm = elm.offsetParent;
    }

    return y;
}
function Large(obj)
{
    var imgbox=document.getElementById("imgbox");
    imgbox.style.visibility='visible';
    var img = document.createElement("img");
		var imgwidth=obj.width*3;
		var imgheight=obj.height*3;
		//document.write("Width: "+imgwidth);
		//imgwidth=500;
		//imgheight=221;
    img.src=obj.src;
    img.style.width=imgwidth+'px'; //'500px';
    img.style.height=imgheight+'px'; //'221px';
    
    if(img.addEventListener){
        img.addEventListener('mouseout',Out,false);
    } else {
        img.attachEvent('onmouseout',Out);
    }             
    imgbox.innerHTML='';
    imgbox.appendChild(img);
    imgbox.style.left=(getElementLeft(obj)-150) +'px';
    imgbox.style.top=(getElementTop(obj)-150) + 'px';
}

function Out()
{
    document.getElementById("imgbox").style.visibility='hidden';
}
