var strFront, strEnd, divHeight, scrh, count;
var intervalDROP, div_ID, dropPREV;
var divH1, divH2, divH3, divH4, divH5, divH6, divH7;
var loaded = 0;
var homeview=0;

function setup()
{
 var w, hole;
 scrh = document.getElementById("MAINTABLE").offsetHeight;
 if(homeview)
  {
   document.getElementById("dropRED").style.visibility = "hidden";
   document.getElementById("dropORANGE").style.visibility = "hidden";
   document.getElementById("dropYELLOW").style.visibility = "hidden";
   document.getElementById("dropGREEN").style.visibility = "hidden";
   document.getElementById("dropBLUE").style.visibility = "hidden";
   document.getElementById("dropINDIGO").style.visibility = "hidden";
   document.getElementById("dropVIOLET").style.visibility = "hidden";

   document.getElementById("dropRED").style.width = document.getElementById("topbarRED").offsetWidth;
   document.getElementById("dropORANGE").style.width = document.getElementById("topbarORANGE").offsetWidth;
   document.getElementById("dropYELLOW").style.width = document.getElementById("topbarYELLOW").offsetWidth;
   document.getElementById("dropGREEN").style.width = document.getElementById("topbarGREEN").offsetWidth;
   document.getElementById("dropBLUE").style.width = document.getElementById("topbarBLUE").offsetWidth;
   document.getElementById("dropINDIGO").style.width = document.getElementById("topbarINDIGO").offsetWidth;
   document.getElementById("dropVIOLET").style.width = document.getElementById("topbarVIOLET").offsetWidth;

   document.getElementById("dropRED").style.height = 1;
   document.getElementById("dropORANGE").style.height = 1;
   document.getElementById("dropYELLOW").style.height = 1;
   document.getElementById("dropGREEN").style.height = 1;
   document.getElementById("dropBLUE").style.height = 1;
   document.getElementById("dropINDIGO").style.height = 1;
   document.getElementById("dropVIOLET").style.height = 1;

   document.getElementById("SLIDETABLE").style.width="100%";
   ShowMenu();
   ShowPicture();
  }
 else
  {

 divH1 = scrh;
 divH2 = scrh;
 divH3 = scrh;
 divH4 = scrh;
 divH5 = scrh;
 divH6 = scrh;
 divH7 = scrh;
 loaded = 1;
 document.getElementById("SLIDETABLE").style.width="0%";
 document.getElementById("dropRED").style.width = document.getElementById("topbarRED").offsetWidth;
 document.getElementById("dropORANGE").style.width = document.getElementById("topbarORANGE").offsetWidth;
 document.getElementById("dropYELLOW").style.width = document.getElementById("topbarYELLOW").offsetWidth;
 document.getElementById("dropGREEN").style.width = document.getElementById("topbarGREEN").offsetWidth;
 document.getElementById("dropBLUE").style.width = document.getElementById("topbarBLUE").offsetWidth;
 document.getElementById("dropINDIGO").style.width = document.getElementById("topbarINDIGO").offsetWidth;
 document.getElementById("dropVIOLET").style.width = document.getElementById("topbarVIOLET").offsetWidth;

 /*
document.getElementById("dropRED").style.height = scrh;
 document.getElementById("dropORANGE").style.height = scrh;
 document.getElementById("dropYELLOW").style.height = scrh;
 document.getElementById("dropGREEN").style.height = scrh;
 document.getElementById("dropBLUE").style.height = scrh;
 document.getElementById("dropINDIGO").style.height = scrh;
 document.getElementById("dropVIOLET").style.height = scrh;
*/ 
 document.getElementById("dropRED").style.visibility = "visible";
 document.getElementById("dropORANGE").style.visibility = "visible";
 document.getElementById("dropYELLOW").style.visibility = "visible";
 document.getElementById("dropGREEN").style.visibility = "visible";
 document.getElementById("dropBLUE").style.visibility = "visible";
 document.getElementById("dropINDIGO").style.visibility = "visible";
 document.getElementById("dropVIOLET").style.visibility = "visible";
 document.getElementById("SLIDETABLE").style.width="0%";
 RunRainbow();
 }
 whichVersion();
 if(b=="IE")
  {
   strFront = "document.all.";
   strEnd =".style";
  }
 else
  {
   strFront = "document.";
   strEnd = "";
  }
}

function whichVersion()
{
 var myBrowser = navigator.userAgent;
 if((myBrowser.lastIndexOf("MSIE")!=-1) && (myBrowser.lastIndexOf("5.")!=-1))b = "IE";
 if((myBrowser.lastIndexOf("MSIE")!=-1) && (myBrowser.lastIndexOf("4.")!=-1))b = "IE";
 if((myBrowser.lastIndexOf("MSIE")!=-1) && (myBrowser.lastIndexOf("3.")!=-1))b = "IE";
 if((myBrowser.lastIndexOf("MSIE")==-1) && (myBrowser.lastIndexOf("2.")!=-1))b = "NS";
 if((myBrowser.lastIndexOf("MSIE")==-1) && (myBrowser.lastIndexOf("3.")!=-1))b = "NS";
 if((myBrowser.lastIndexOf("MSIE")==-1) && (myBrowser.lastIndexOf("4.")!=-1))b = "NS";
 document.getElementById("LOGO_SPACE").width = document.getElementById("topbarVIOLET").offsetWidth-84;
}








function CheckForm(inForm) 
{  
	var sre, srn, srs, sra, lsAT, lsDOT;

	sre   = (inForm.EMAIL.value);
	srn   = (inForm.NAME.value);
	sra   = (inForm.ADDRESS.value);
	srs   = (inForm.TELNUM.value);
	lsAT  = (inForm.EMAIL.value.indexOf("@"));
	lsDOT = (inForm.EMAIL.value.indexOf("."));
	
	if(sre == "" || srn == "" || sra == "" || srs == ""  ) 
	 {
		alert("Please complete all areas of the form");
		return false;	
	 }

	if (lsAT == -1 || lsDOT == -1 ) 
	 {
	  alert("Please enter a Valid Email Address");
	  inForm.EMAIL.select();
	  return false;
   }		
 return CheckTags();
}

function CheckTags()
{
  var i, j, IsTagOp, IsTagCl, GotTag; 
  GotTag = 0;
  for(j = 0; j < document.forms.length; j++)
   {
    for(i = 0; i < document.forms[j].elements.length; i++)
       {
         lsTagOp  = (document.forms[j].elements[i].value.indexOf("<"));
         lsTagCl   = (document.forms[j].elements[i].value.indexOf(">"));
   	   if (lsTagOp > -1)GotTag++;
	   if (lsTagCl  > -1)GotTag++;
         if(GotTag)
	    {
	     alert("Please remove the characters < or > from your entry as they are not allowed");
	     document.forms[j].elements[i].select();
	     return false;
	    }
       }
   }
}


function dropClip() 
{
 var dropNum = 8;
 count -= dropNum;
 if(count>0)
  {
   divH1 -= dropNum;
   if(count<=1080)divH2 -= dropNum;
   if(count<=1040)divH3 -= dropNum;
   if(count<=1000)divH4 -= dropNum;
   if(count<=960)divH5 -= dropNum;
   if(count<=920)divH6 -= dropNum;
   if(count<=880)divH7 -= dropNum;
   if(divH1>=0)document.getElementById("dropVIOLET").style.height = divH1;
   if(divH2>=0)document.getElementById("dropINDIGO").style.height = divH2;
   if(divH3>=0)document.getElementById("dropBLUE").style.height = divH3;
   if(divH4>=0)document.getElementById("dropGREEN").style.height = divH4;
   if(divH5>=0)document.getElementById("dropYELLOW").style.height = divH5;
   if(divH6>=0)document.getElementById("dropORANGE").style.height = divH6;
   if(divH7>=0)document.getElementById("dropRED").style.height = divH7;
  }
 else 
  {
   clearInterval(intervalDROP);
   ShowMenuBar();
  }
 if(divH1<=0){document.getElementById("dropVIOLET").style.height = 0;document.getElementById("dropVIOLET").style.visibility = "hidden";}
 if(divH2<=0){document.getElementById("dropINDIGO").style.height = 0;document.getElementById("dropINDIGO").style.visibility = "hidden";}
 if(divH3<=0){document.getElementById("dropBLUE").style.height = 0;document.getElementById("dropBLUE").style.visibility = "hidden";}
 if(divH4<=0){document.getElementById("dropGREEN").style.height = 0;document.getElementById("dropGREEN").style.visibility = "hidden";}
 if(divH5<=0){document.getElementById("dropYELLOW").style.height = 0;document.getElementById("dropYELLOW").style.visibility = "hidden";}
 if(divH6<=0){document.getElementById("dropORANGE").style.height = 0;document.getElementById("dropORANGE").style.visibility = "hidden";}
 if(divH7<=0){document.getElementById("dropRED").style.height = 0;document.getElementById("dropRED").style.visibility = "hidden";}
}


function RunRainbow()
{
 count = 1120; 
 intervalDROP = 0;
 intervalDROP = setInterval("dropClip()",1);
}

function ShowMenuBar()
{
 count=0; 
 intervalDROP = 0;
 intervalDROP = setInterval("tableClip()",1); 
}


function tableClip() 
{
 var dropNum = 2;
 count += dropNum;
 if(count<=100)
  {
   document.getElementById("SLIDETABLE").style.width=count+"%";
  }
 else 
  {
   clearInterval(intervalDROP);
   ShowMenu();
  }
}


function ShowMenu()
{
 var strText;
 strText = "<table width='100%' border='0' cellspacing='0' cellpadding='5'>";
 strText = strText + "<tr><td><a ID='RAINBOW' class='opening' href='javascript:ShowPicture();'>rainbow</a></td></tr>";
 strText = strText + "<tr><td><a class='mainmenu' href='people.asp'>people</a></td></tr>";
 strText = strText + "<tr><td><a class='mainmenu' href='portfolio.asp'>portfolio</a></td></tr>";
// strText = strText + "<tr><td><a class='mainmenu' href='parkour.asp'>parkour</a></td></tr>";
// strText = strText + "<tr><td><a class='mainmenu' href='news.asp'>news</a></td></tr>";
// strText = strText + "<tr><td><a class='mainmenu' href='vocabulary.asp'>vocabulary</a></td></tr>";
// strText = strText + "<tr><td><a class='mainmenu' href='links.asp'>links</a></td></tr>";
 strText = strText + "<tr><td><a class='mainmenu' href='contact.asp'>contact / map</a></td></tr></table>";
 document.getElementById("MENUBAR").innerHTML = strText;
}


function ShowPicture()
{
 var strText;
 strText = "<table width='100%' border='0' cellspacing='0' cellpadding='0'>";
 strText = strText + " <tr><td height='150'>&nbsp; </td></tr>";
 strText = strText + "<tr align='center'><td><img src='images/rainbow.jpg' width='220' height='300'> </td></tr>";
 strText = strText + "</table>";
 document.getElementById("MAINPIC").innerHTML = strText;
 ShowText();
}

function ShowText()
{
 var strText;
 strText = "<p class='blurb_title'>bringing colour to business</p>";
 strText = strText + "<p class='blurb'>Rainbow is a creative design and marketing<br>resource with a firm focus on business strategy.</p>";
 strText = strText + "<p class='blurb'>We have local, regional, national and global experience<br>of design, marketing initiatives, communications projects<br>and their implementation.</p>";
 strText = strText + "<p class='blurb'>Our people are able to offer a unique blend of skills<br>that can be tailored to match your requirement and objectives.</p>";
 strText = strText + "<p class='blurb_title'>in beautiful Suffolk where rainbows are plentiful</p>";
 document.getElementById("MAINTEXT").innerHTML = strText;  
 document.getElementById("RAINBOW").className = "current";              
}

function ShowLink(set, linktype, setlink)
{
 var linkText;
 document.getElementById("MEDIA").style.visibility = "hidden";
 if(set)
  {
   switch(linktype)
	  {
		 case 0: break;
		 case 1: break;
		 case 2: linkText = "<embed src='" + setlink + "' /></embed>";break;
//     case 2: linkText = "<object data='" + setlink + "' type='video/avi' />";break;
// 		 case 2: linkText = "<a href='" + setlink + "' target='_blank'/>CLICK HERE TO PLAY</a>";break;
		}
   document.getElementById("MEDIA_TARGET").innerHTML = linkText;
   document.getElementById("MEDIA").style.visibility = "visible";
  }               
}

/*
<script type="text/javascript">
  var intervalID;    
  var origLayerWidth = 0
  var origLayerHeight = 0
  var currTop, currRight, currBottom, currLeft
  setTimeout("revealClip()", 2100);
  origLayerWidth = parseInt(document.getElementById("FRONTWINDOW").style.width);
  origLayerHeight = parseInt(document.getElementById("FRONTWINDOW").style.height);
  currTop = 0;
  currRight = origLayerWidth;
  currBottom = origLayerHeight;
  currLeft = 0;
var midWidth = Math.round(origLayerWidth /2);
document.getElementById("FRONTWINDOW").style.left = (parseInt(document.getElementById("MAINTABLE").offsetWidth)/2) - (parseInt(document.getElementById("FRONTWINDOW").style.width)/2);
document.getElementById("FRONTWINDOW").style.top  = (parseInt(document.getElementById("MAINTABLE").offsetHeight)/2) - (parseInt(document.getElementById("FRONTWINDOW").style.height)/2);
//document.getElementById("FRONTWINDOW").style.left = 200;//(document.getElementById("FRONTWINDOW").style.width/2);
 function clearSelection() 
  {
   document.getElementById("FRONTWINDOW").style.visibility = "hidden";
   //status = "Window Cleared";
  }
    
 function adjustClip() 
  {
   document.getElementById("FRONTWINDOW").style.clip = "rect(" + currTop + "px " +
   currRight + "px " + currBottom + "px " + currLeft + "px)";
  }
      
      
      
      function revealClip() {
         
         //currRight = midWidth;
         //currLeft = midWidth;
         intervalID = setInterval("stepClip()",1);
      }
      function stepClip() 
       {
         var widthDone = false;
         var heightDone = false;
         if (currLeft < midWidth) 
           {
            currLeft +=  2;
            currRight+= -2;
           } 
         else widthDone = true;
         adjustClip();
         if (widthDone)
           {
            clearInterval(intervalID);
            FRONTWINDOW.style.visibility = "hidden";
           }
      }
      </script>
*/
