var preloadFlag = false, opicd, opic2d, opfirstind=true, opcount, opval=1, opvartime, opfunfrom, optim, tjpopwindow, mappopwindow;

window.onunload = closepopup;

function newImage(arg) 
{
	if (document.images) 
	{
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() 
{
	if (document.images && (preloadFlag == true)) 
	{
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function preloadImagesg() 
{
	if (document.images) 
	{
		hyp_piano_over = newImage("images/hyp_piano-over.gif");
		hyp_rest_over = newImage("images/hyp_rest-over.gif");
		hyp_repol_over = newImage("images/hyp_repol-over.gif");
		hyp_srvc_over = newImage("images/hyp_srvc-over.gif");
		hyp_about_over = newImage("images/hyp_about-over.gif");
		hyp_contact_over = newImage("images/hyp_contact-over.gif");
		hyp_home_over = newImage("images/hyp_home-over.gif");
		preloadFlag = true;
	}
}

function opvarsp(funfrom, picd, pic2d, ind)
{
     opicd = picd;
     opic2d = pic2d;
     opfunfrom = funfrom;
     opcount = 1;
     (ind == 1) ?  opvarp() : opvar2p();
}

function opvarp()
{
    if (opcount < 16)
    {
       opval = opval - .05;
       opicd.style.opacity= opval;
       opic2d.style.opacity= opval;
       opcount =  opcount +1;
       opvartime = setTimeout ("opvarp()", 0);
    }
    else
    {
       opfirstind = false;
       clearTimeout(opvartime);
       optim = setTimeout (opfunfrom, 0);
    }
}

function opvar2p()
{
    if (opcount < 16)
    {
       opval = opval + .05;
       opicd.style.opacity= opval;
       opic2d.style.opacity= opval;
       opcount =  opcount +1;
       opvartime = setTimeout ("opvar2p()", 0);
    }
    else
    {
       opfirstind = true;
       opval = 1;
       opicd.style.opacity= 1;
       clearTimeout(opvartime);
       optim = setTimeout (opfunfrom, 5000);
    }
}

function tjpopup(popurl)
{
   if (tjpopwindow != null) tjpopwindow.close();
   tjpopwindow= window.open(popurl, "", "top=5, left=5, width=795, height=570, scrollbars, resizable");
}
function mappopup()
{
   if (mappopwindow != null) mappopwindow.close();
   mappopwindow= window.open("http://www.multimap.com/map/browse.cgi?lat=52.6111&lon=-1.8858&scale=10000&icon=x",
  		 "", "top=30, left=5, width=790, height=450, scrollbars, resizable");
}
function closepopup()
{
  if(tjpopwindow != null) tjpopwindow.close();
  if (mappopwindow != null) mappopwindow.close();
}
