///////////////////////////////////////////////////////////////
// ALL SCRIPTS HANDCRAFTED @ INDEPENDENT COUNTRY dMOTION.com //
///////////////////////////////////////////////////////////////

d = document;
// preload mouse-over images
Butt1       = new Image();
Butt1.src   = '../img/sub/button1.gif';
Butt2       = new Image();
Butt2.src   = '../img/sub/button2.gif';
Form1       = new Image();
Form1.src   = '../img/sub/form_1.gif';
Form2       = new Image();
Form2.src   = '../img/sub/form_2.gif';

function ShowDetails(TheBlock)
    {
d.getElementById(ActiveBlock).style.display = 'none';
d.getElementById(TheBlock).style.display    = 'block';
ActiveBlock = TheBlock;
    }
    

function ShowXplain(TheTXT)
    {
d = document;
if(TheTXT == 0)d.getElementById('Xplain').style.display = 'none';
else
    {
d.getElementById('Xplain').style.display = 'block';
d.getElementById('Xplain').innerHTML = ChapterTXT[TheTXT];
    }
    }


function SelectRadio(TheRadio)
    {    
d.getElementById('Radio'+TheRadio).checked = 1;
    }

/////////////////////////////////////////////////////////////////
// ALL THE FORM-ACTION ON A SINGLE DOUBLE TRIPLE QUATRO ROW... //
/////////////////////////////////////////////////////////////////

function ChangeButt(WhichMove,WhichBUTT)
    {
if(WhichMove == '1')
    {
WhichBUTT.style.color       = '#FFFFFF';
WhichBUTT.style.background  = '#3E497C url("'+Butt2.src+'")';
    }
else
    {
WhichBUTT.style.color      = '#1B5779';
WhichBUTT.style.background = '#E8F5FC url("'+Butt1.src+'")';
    }
    }

// change butt text
function ChangeTXT(WhichButt)
    {
WhichButt.value = 'bezig...';
    }

function ErrorField(ActionType,Field)
    {
if(ActionType == 'Error')
    {
Field.style.color           = '#870F0F';
Field.style.background      = '#CB1432 url("'+Form2.src+'")';
Field.focus();
    }
else
    {
Field.style.color           = '#1B5779';
Field.style.background      = '#E8F5FC url("'+Form1.src+'")';

    }
    }

FieldName       = new Array();

FieldName[1]    = 'naam';
FieldName[2]    = 'telefoonnummer';
FieldName[3]    = 'emailadres';
FieldName[4]    = 'vraag';


function CheckFields(FieldTotal)
    {
for (i=1; i<FieldTotal; i++)
    {
if(i != 2) // DON'T ASK FOR CELLNUMBER...
    {
    if (d.getElementById(FieldName[i]).value.length < 4)
        {
    alert ('Vul a.u.b. ook uw ' + FieldName[i] + ' in...');
    ErrorField('Error',d.getElementById(FieldName[i]));
    return false;
        }
    }
    }
return CheckMail();
    }


function CheckMail()
    {
Field = d.getElementById("emailadres");

ValidChr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789@.-_;';

for (x=0; x<Field.value.length; x++) 
    {
TempValue = '' + Field.value.substring(x, x+1);
if (ValidChr.indexOf(TempValue) == '-1')
    {
alert('Speciale karakters zijn niet\ntoegestaan binnen een emailadres...');
ErrorField('Error',Field);
return false;
    }
    }

    if ((Field.value.indexOf('@') == -1) || (Field.value.indexOf('.') == -1))
        {
    alert('Helaas, dit emailadres is niet geldig...');
    ErrorField('Error',Field);
    return false;
        }

ConfirmURL = confirm('Uw emailadres is - ' + d.getElementById(FieldName[3]).value + ' -\n\nIs dit correct?');

    if (ConfirmURL)
		{
    if (Field.value != 'easter@egg...')
        {
    ChangeTXT(d.getElementById("SendButt"));
    return true;
        }
    else
        {
    EasterBgone(1);
    return false;
        }
		}
	else
		{
	alert('Vul a.u.b. het juiste emailadres in...')
    ErrorField('Error',Field);
    return false;
    		}

    }

/////////////////////////////////////////////////////////////////
// DYNAMIC MENU SCRIPT / (c) dMOTION.com [so don't lurk it...] //
/////////////////////////////////////////////////////////////////

d           = document;
Show        = 0; // initial visibility of the fields
TheGrowStep = 5; // amount of pixels whereby the field grows or shrinks
TheSpeed    = 1; // time in milliseconds whereby the field grows
PrevField   = 0; // which field is open at the moment

    
// show or hide the selected field
function ShowHide(TheField)
    {

if(TheField != PrevField)
    {
d.getElementById(PrevField).style.display = 'none';
d.getElementById(PrevField).style.visibility = 'hidden';
d.getElementById(PrevField).style.height = 0;
Show[PrevField] = 0;
PrevField = TheField;
    }

    if(Show[TheField] == 1)
        {
    Show[TheField] = 0;
    MoveUpDown(TheField,0);
        }
    else
        {
    Show[TheField] = 1;
    d.getElementById(TheField).style.display = 'block';
    d.getElementById(TheField).style.visibility = 'visible';
    MoveUpDown(TheField,1);
        }
    }

// animated grow or shrink of the field    
function MoveUpDown(TheField,OpenOrClose)
    {
CurrentHeight   = 1*d.getElementById(TheField).style.height.substring(0,d.getElementById(TheField).style.height.indexOf('p'));
TheNewField     = TheField;
NewOpenOrClose  = OpenOrClose;

if(OpenOrClose == 1) // grow the field
    {
d.getElementById(TheField).style.height = CurrentHeight + TheGrowStep;

    if(d.getElementById(TheField).offsetHeight < FieldHeight[TheField]) // if the field has not yet reached it full height
        {
    setTimeout("MoveUpDown(TheNewField,NewOpenOrClose)",TheSpeed);
        }
    }

if(OpenOrClose == 0) // shrink the field
    {
d.getElementById(TheField).style.height = CurrentHeight - TheGrowStep;

    if(d.getElementById(TheField).offsetHeight > TheGrowStep) // if the field has not shrinked to zero
        {
    setTimeout("MoveUpDown(TheNewField,NewOpenOrClose)",TheSpeed);
        }
    else
        {
    d.getElementById(TheField).style.display = 'none';
        }
    }

    }
    
// initialize the menu at start
function InitializeMenu()
    {
FieldHeight     = new Array();
Show            = new Array();
FieldTotal      = 2;

    for (i=1; i < FieldTotal+1; i++)
        {
    FieldHeight[i]                      = d.getElementById(i).offsetHeight;
    d.getElementById(i).style.display   = 'none';
    Show[i]                             = 0;
        }
    }

// easteregg?    
function EasterBgone(TheAction)
    {
if(TheAction == 0)d.getElementById('easter').style.visibility = 'hidden';
else{d.getElementById('easter').style.visibility = 'visible';}
    }