
var dotz = 0
var linez = 0
var elez = 0
var colz = 0
var d = document;
var rand_fl
var ran_int
var hex
var wordCue = ""
var maxLines = 30;
var goLines = 1;
var multi = 0;
var letterColour = "none"

elementTop = "<font color=\"#00";
elementMiddle = "00\">";
elementTail = "</font>";
rowEnd = "\n";


function init() {
    hideAllContent()
    hideAllBig()
    hideAllprojectNames()
    setTimeout(function(){
    goLines = 0;
    Effect.Appear("bar", { delay: 0.5, duration: 1.0 });
    showContent('home');
    }, 4000); 
    
    
    setInterval("addLine()",10)
   /* 
  if (window.Event) {
    document.captureEvents(Event.MOUSEMOVE);
  }
  document.onmousemove = getXY;*/
}

function startDotz() {
    setInterval("addDot()",100)
	}
	
	function addDot()
	{
        multi +=1;
        if(multi == 8)
        {
		myDiv = document.getElementById("mydiv");
        firstline = get_firstchild(myDiv);
        fonte = get_firstchild(firstline);
        fonte.innerHTML += ".";
        dotz += 1;
        multi = 0;
        }
	}
    
    
    function checkLength()
    {

    var divheight = document.getElementById("mydiv").offsetHeight;

    var windowheight = getHeight();

    if (goLines == 1)
        {
        if ( divheight + 30 >= windowheight)return -1;
        if ( divheight + 30 < windowheight) return 1;
        }
    else
        {
        if ( divheight + 30 > windowheight)return -1;
        if ( divheight + 60 < windowheight) return 1;
        }
    return 0;
    }
    
    
    function getHeight() {
      var myWidth = 0, myHeight = 0;
      if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myHeight = window.innerHeight;
      } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myHeight = document.documentElement.clientHeight;
      } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myHeight = document.body.clientHeight;
      }
      return myHeight;
    }
    
    
    function addLine()
    {
    if (dotz < 6)
    {
        addDot();
        return;
    }
    myDiv = document.getElementById("mydiv")
    var check = checkLength()
    if (check == 1)
        {
            myDiv.appendChild(getLine())
        }
    if (check == -1)
        {
            myDiv.removeChild(get_firstchild(myDiv))
        }
    
    }
    
 
	function getEndOfLine()
		{
		return d.createTextNode("\n")
		}
        
	function getLine() 
		{
		newDivElement = d.createElement('div')
        var i;
       for(i = 0; i < 12; i++)
       {
        newDivElement.appendChild(getElement())
       }
		return newDivElement
		}
        
    function get_firstchild(n)
    {

    var x=n.firstChild;
    if (x == null)
    while (x.nodeType!=1)
      {
      x=x.nextSibling;
      }
    return x;
    }
    
   


function getXY(e) {
    changeAColour();
}

	function getElement() 
		{
       if (wordCue.length > 0)
       {
       
		newFontElement = d.createElement('font')
		newFontElement.color = "#888888"
		newFontElement.appendChild(d.createTextNode(wordCue.slice(0,2)))
       wordCue = wordCue.slice(2,wordCue.length)
		return newFontElement
       }
       
		rand_fl = Math.random() * 240
		ran_int = Math.floor(rand_fl) + 16
       pale = (ran_int/4)+192
       palehex = d2h(pale)
		hex = d2h(ran_int)
		newFontElement = d.createElement('font')
		newFontElement.color = "#" + palehex + palehex + palehex
		newFontElement.appendChild(d.createTextNode(hex))
		return newFontElement
		}
        

		
    function changeAColour()
    {

    var mydiv = document.getElementById("mydiv")
    var randomdiv = findARandomChild(mydiv)
    var randome = findARandomChild(randomdiv)
    
    changeElementColour(randome)
    }
        
	function findARandomChild(e)
		{
		var children = e.childNodes
		var len = children.length
		rand_fl = Math.random() * len
		ran_int = Math.floor(rand_fl)
       return children[ran_int]
		}


	function changeElementColour(fontElement)
		{
		if (fontElement.color)
			{
           //rand_fla = Math.random() * 5
		    //ran_inta = Math.floor(rand_fla)
            
           rand_fl = Math.random() * 240
           ran_int = Math.floor(rand_fl) + 16
           rand_fl2 = Math.random() * 240
           ran_int2 = Math.floor(rand_fl2) + 16
           rand_fl3 = Math.random() * 240
           ran_int3 = Math.floor(rand_fl3) + 16
           pale = (ran_int/4)+192
           palehex = d2h(pale)
           hex = d2h(ran_int)
           hex2 = d2h(ran_int2)
           hex3 = d2h(ran_int3)
           fontElement.color = "#" + palehex + palehex + palehex
           
           if (letterColour == "mouz")fontElement.color = "#" + "ee" + hex + palehex //pink
           if (letterColour == "dvace")fontElement.color = "#" + hex  + hex + palehex//blue
           if (letterColour == "krummz")fontElement.color = "#" + hex  + palehex + "ee"//nice blue2
           if (letterColour == "digirostrum")fontElement.color = "#" + palehex + hex  + hex//nice blue2
           if (letterColour == "swap")fontElement.color = "#" + hex + palehex  + hex//green
           if (letterColour == "mouseorgan")fontElement.color = "#" + palehex + hex  + "ee" 
           if (letterColour == "cleverplugs")fontElement.color = "#" + palehex + palehex  + palehex 
           if (letterColour == "timhead")fontElement.color = "#" + hex + hex2  + hex3 
           if (letterColour == "none")fontElement.color = "#" + palehex + palehex + palehex 
           if(fontElement.firstChild.replaceNode)
               {
                fontElement.firstChild.replaceNode(d.createTextNode(hex))
                }
			}
		}  
        


	var hD="0123456789ABCDEF";
	
	function d2h(d) 
		{
		var h = hD.substr(d&15,1);
		while(d>15) {d>>=4;h=hD.substr(d&15,1)+h;}
		return h;
		}

function rollOverId(id)
{
    var e = document.getElementById(id)
    e.style.color = "#888888"
}

function rollOutId(id)
{
    var e = document.getElementById(id)
    e.style.color = "#000000"
}

function rollOverProjectId(id)
{
    $(id).show()
}

function rollOutProjectId(id)
{
    $(id).hide()
}

function showContent(id)
{

    all = $("main").getElementsByClassName("content");
    for (var i=0;i<all.length;i++) 
    {
        if(all[i].visible && all[i].id != id+"_c")
        {
        all[i].fade({ duration: 0.4});
        }
    }

    allb = $("bigholder").getElementsByClassName("bigimage");
    for (var i=0;i<allb.length;i++) 
    {
        if(allb[i].visible && allb[i].id != id+"_b")
        {
        allb[i].fade({ duration: 0.4});
        }
    }
  
    e = $(id+"_c")
    b = $(id+"_b")
    
    if(e.visible)
    {
    setTimeout(function(){e.appear({ duration: 0.5});}, 500); 
    if(b)setTimeout(function(){b.appear({ duration: 0.5});}, 500);
    }
    
    letterColour = id
    
}

function hideAllContent()
{
    
    all = $("main").getElementsByClassName("content");
    for (var i=0;i<all.length;i++) {all[i].hide();}
}


function hideAllBig()
{
    all = $("bigholder").getElementsByClassName("bigimage");
    for (var i=0;i<all.length;i++) {all[i].hide();}
}

function hideAllprojectNames()
{
    all = $("projects").getElementsByClassName("projecttitle");
    for (var i=0;i<all.length;i++) {all[i].hide();}
}







