function dateChange(day, month, year)
{
    var gMonth = parseInt(month, 10);
    var gDay = parseInt(day, 10)
    var gYear = parseInt(year);
    var mYear = gYear;
    if (gMonth == 2 && gDay == 29)
    {
        gDay = 28;
    } // end if
    if (gMonth <= 7)
    {
        if (gDay <= 25)
        {
            mYear = gYear - 1;
        }
        else if (gDay > 25 && gMonth <= 6)
        {
            mYear = gYear - 1;
        } // end if
    } // end else if
    match = searchArray(transYearArray, mYear);
    mYearTS = transYearArray[match + 1] + " " + transYearArray[match + 2];
    if (gMonth == 1)
    {
        delta = gDay + 158;
    }
    else if (gMonth == 2)
    {
        delta = gDay + 189;
    }
    else if (gMonth == 3)
    {
        delta = gDay + 217;
    }
    else if (gMonth == 4)
    {
        if (gDay < 12)
        {
            delta = gDay + 248;
        }
        else
        {
            delta = gDay - 12;
        } // end else if
    }
    else if (gMonth == 5)
    {
        delta = gDay + 18;
    }
    else if (gMonth == 6)
    {
        delta = gDay + 49;
    }
    else if (gMonth == 7)
    {
        if (gDay < 26)
        {
            delta = gDay + 79;
        }
        else
        {
            delta = gDay - 26;
        } // end else if
    }
    else if (gMonth == 8)
    {
        delta = gDay + 5;
    }
    else if (gMonth == 9)
    {
        delta = gDay + 36;
    }
    else if (gMonth == 10)
    {
        delta = gDay + 66;
    }
    else if (gMonth == 11)
    {
        delta = gDay + 97;
    }
    else if (gMonth == 12)
    {
        delta = gDay + 127;
    } // end else if
    match = searchArray(tzolkinArray, mYearTS);
    kin = match + delta;
  //  alert('match: ' + match + ' delta: ' + delta);
    if (kin > 260)
    {
        kin = kin - 260;
    } // end if
  //  alert('kin: '+ kin);
    finalTS = tzolkinArray[kin];
   // alert(finalTS);
    if (finalTS.indexOf(" ") == 2)
    {
        tone = finalTS.slice(0, 2);
        seal = finalTS.slice(3, finalTS.length);
    }
    else
    {
        tone = finalTS.slice(0, 1);
        seal = finalTS.slice(2, finalTS.length);
    } // end else if
    toneName = toneNameArray[tone];
    if (seal == "Draak" || seal == "Slang" || seal == "Maan" || seal == "Hemelwandelaar" || seal == "Aarde")
    {
        sealColor = "Rode ";
    }
    else if (seal == "Wind" || seal == "Wereldoverbrugger" || seal == "Hond" || seal == "Tovenaar" || seal == "Spiegel")
    {
        sealColor = "Witte ";
    }
    else if (seal == "Nacht" || seal == "Hand" || seal == "Aap" || seal == "Adelaar" || seal == "Storm")
    {
        sealColor = "Blauwe";
    }
    else
    {
        sealColor = "Gele";
    } // end else if
//     glyph = sealColor + " " + toneName + " " + seal;
//     glyph_mc.tone_mc.gotoAndStop(tone);
//     sealNumber = match = searchArray(sealNameArray, seal);
//     glyph_mc.seal_mc.gotoAndStop(sealNumber);
//     

  //  window.document.getElementById('form_responsemaya').innerHTML=seal + ' ' + toneName + ' kin: ' + kin;
    
  window.document.getElementById('rowform_responsemaya').style.display = "block";
  window.document.getElementById('form_responsemaya').innerHTML='<div id="profielzegel"><img src="images/zegels/' + seal + '.jpg"></div><div id="profielzegeldesc"><p>Jouw Zegel: ' + sealColor + ' ' +  seal + '<br />Jouw Toon: ' + tone + '<br />Jouw Kin: ' + kin + '</p>';
    
} // End of the function


function searchArray(array, item)
{
    var _loc1 = item;
    thisArray = array;
    l = thisArray.length;
    for (match = 0; match < l; match++)
    {
        if (thisArray[match] == _loc1)
        {
            return (match);
        } // end if
    } // end of for
} // End of the function





currentDate = new Date();
currentDay = currentDate.getDate();
currentMonth = currentDate.getMonth();
currentYear = currentDate.getFullYear();
var tone;
var glyph;
var gYear;
var mYear;
var mYearTS;
var kin;
var delta;
var maxYear = 2013;
var minYear = 1850;
var yearArray = new Array();
y = maxYear;
j = 0;
for (i = minYear; i <= maxYear; i++)
{
    yearArray[j] = y;
    --y;
    ++j;
} // end of for
var toneArray = ["", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"];
var toneNameArray = ["", "Magnetisch", "Lunair", "Electrisch", "Zelfbestaand", "Boventoon", "Ritmisch", "Resonerend", "Galaktisch", "Solair", "Planetair", "Spectraal", "Kristal", "Kosmisch"];
var sealNameArray = ["", "Draak", "Wind", "Nacht", "Zaad", "Slang", "Wereldoverbrugger", "Hand", "Ster", "Maan", "Hond", "Aap", "Mens", "Hemelwandelaar", "Tovenaar", "Adelaar", "Krijger", "Aarde", "Spiegel", "Storm", "Zon"];

var tzolkinArray = new Array();
tzolkinArray[0] = "";
t = 1;
g = 1;
//trace ("/// 260 day - TZOLKIN ///");
for (k = 1; k <= 260; k++)
{
    tzolkinArray[k] = toneArray[t] + " " + sealNameArray[g];
    //trace (tzolkinArray[k]);
    ++t;
    ++g;
    if (t > 13)
    {
        t = 1;
    } // end if
    if (g > 20)
    {
        g = 1;
    } // end if
} // end of for
var transYearArray = new Array();
t = 8;
g = 4;
y = maxYear;
i = 0;
while (y > 0)
{
    transYearArray[i] = y;
    ++i;
    transYearArray[i] = toneArray[t];
    ++i;
    transYearArray[i] = sealNameArray[g];
    ++i;
    t = t - 1;
    g = g - 5;
    y = y - 1;
    if (t < 1)
    {
        t = 13;
    } // end if
    if (g < 4)
    {
        g = 19;
    } // end if
} // end while
// globalStyleFormat.arrow = 16777215;
// globalStyleFormat.face = 39219;
// globalStyleFormat.scrollTrack = 26163;
// globalStyleFormat.background = 26112;
// globalStyleFormat.highlight = 52275;
// globalStyleFormat.highlight3D = 52224;
// globalStyleFormat.shadow = 13056;
// globalStyleFormat.textColor = 16777215;
// globalStyleFormat.textFont = "Arial";
// button1.setSize(70);
// button1.setClickHandler("dateChange");
// button1.setStyleProperty("textColor", 26112);
// globalStyleFormat.applyChanges();
// _root.comboBox1.setSize(90);
// _root.comboBox1.setSelectedIndex(currentMonth);
// _root.comboBox2.setSize(40);
// _root.comboBox2.setSelectedIndex(currentDay - 1);
// _root.comboBox3.setSize(55);
// _root.comboBox3.setDataProvider(yearArray);
// _root.comboBox3.setSelectedIndex(currentYear - 2013 - (currentYear - 2013) * 2);
