var pagedesc, pageimg, preloadFlag = false, cedarpopwindow, specpopwindow, tjpopwindow, mappopwindow;
var preloadimgs = new Array(), showstart = true, showtime, stopind=true, n = 0;
var opcount=0, opvalfg=1, opval=0, showtime, optime, stopind=true;

preloadImagesg();
var ie = document.all ? 1 : 0;
var nn = (navigator.vendor == 'Netscape' || navigator.vendor == 'Netscape6') ? 1 : 0;
window.onunload = closepopup;

if (navigator.appName == "Netscape")
  window.captureEvents(Event.MOUSEMOVE);

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_door_over = newImage("images/hyp_door-over.gif");
		hyp_ctrl_over = newImage("images/hyp_ctrl-over.gif");
		hyp_shut_over = newImage("images/hyp_shut-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 page_desc(descp, img)
{
   pagedesc = descp;
   pageimg = img;
}

function showpics(firstind, delayinit, delay, loop, valinc, loopnn, valincnn)
{
   if (firstind == 1)
   {
     delayst = delayinit;
     delayo = delay;
     loopo = loop;
     valinco = valinc;
     looponn = loopnn;
     valinconn = valincnn;
     showtime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayst);
   }
   else
   {
       if (ie)
       {
          (n == (imgs.length - 1)) ? n = 0: n++;
          showd.style.filter="blendTrans(duration=0.75)";
          showd.filters.blendTrans.Apply();
          showd.src= preloadimgs[n].src;
          showd.filters.blendTrans.Play();
          showtime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
       }
       else
       {
          if (!nn)
          {
	(n == (imgs.length - 1)) ? n = 0: n++;
             shownd.src = preloadimgs[n].src;
             opvar();
          }
          else
             opvarnn();
       }
   }
}

function opvar()
{
    if (opcount < loopo)
    {
       opvalfg = opvalfg - valinco;
       opval = opval + valinco;
       showfgd.style.opacity = opvalfg;
       shownd.style.opacity = opval;
       opcount +=  1;
       opvartime = setTimeout ("opvar()", 0);
    }
    else
    {
       showfgd.src = preloadimgs[n].src;
       showfgd.style.opacity = 1;
       shownd.style.opacity = 0;
       clearTimeout(opvartime);
       opcount = 0;
       opvalfg = 1;
       opval = 0;
       optime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
    }
}

function opvarnn()
{
    if (opcount < looponn)
    {
       opvalfg = opvalfg - valinconn;
       opval = opval + valinconn;
       if (opcount == 1)
       {
          (n == (imgs.length - 1)) ? n = 0: n++;
          shownd.src = preloadimgs[n].src;
       }
       else
       if (opcount == looponn - 1)
            shownnd.src = preloadimgs[n].src;
       showfgd.style.opacity = opvalfg;
       shownd.style.opacity = opval;
       opcount +=  1;
       opvartime = setTimeout ("opvarnn()", 0);
    }
    else
    {
       showfgd.src = preloadimgs[n].src;       
       showfgd.style.opacity = 1;
       shownd.style.opacity = 0;
       clearTimeout(opvartime);
       opcount = 0;
       opvalfg = 1;
       opval = 0;
       optime = setTimeout ("showpics(0, 0, 0, 0, 0, 0, 0)", delayo);
    }
}

function cedarpopup()
{
   if (cedarpopwindow != null) cedarpopwindow.close();
   cedarpopwindow= window.open("http://www.cedardoor.co.uk/products.asp?d=3", "", "top=5, left=5, width=970, height=620, scrollbars, resizable");
}
function specpopup(specprod, specwidth, specheight)
{
   if (specpopwindow != null) specpopwindow.close();
   specpopwindow= window.open(specprod, "", "top=5, left=5, width=" + specwidth + ", height=" + specheight +", scrollbars, resizable");
}

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=55.0423&lon=-1.4508&scale=10000&icon=x",
  		 "", "top=30, left=5, width=790, height=450, scrollbars, resizable");
}
function closepopup()
{
  if (cedarpopwindow != null) cedarpopwindow.close();
  if (specpopwindow != null) specpopwindow.close();
  if (tjpopwindow != null) tjpopwindow.close();
  if (mappopwindow != null) mappopwindow.close();
}