var Year=0; //????
var Moon=0;
var Day =0;
var Gyear; //????
var Gmonth;
var Gdate;
var gGuide; 

//***************ENGLISH TEXT *****************************

COLOR_E = new Array("","Red","White","Blue","Yellow");

TONE_E = new Array("",
 "Magnetic","Lunar","Electric","Self-Existing","Overtone",
 "Rhythmic","Resonant","Galactic","Solar","Planetary",
 "Spectral","Crystal","Cosmic");

SEAL_E = new Array("",
 "Dragon","Wind","Night","Seed","Serpent",
 "World Bridger","Hand","Star","Moon","Dog",
 "Monkey","Human","Skywalker","Shaman","Eagle",
 "Warrior","Earth","Mirror","Storm","Sun");

TOTEM_E = new Array("","The Bat", "The Scorpion", "The Deer", "The Owl","The Peacock","The Lizard","The Monkey",
"The Hawk", "The Jaguar", "The Dog", "The Serpent","The Rabbit","The Turtle");

TEXT_E=new Array(
"",
"What is my purpose?.<br\>  Tone of unity and purpose..<br\>  It attracts all to it.<br\>  I am the Source, Creator, Author.<br\>  I will identify my purpose, vision, intention, project, NOW,in order to be clear about what I intend to create,and align with Divine Will.",

"What is my challenge?.<br\> The 2nd or Lunar Tone is associated with the power of Stabilising and polarising.<br\> I am Risking, Open,Honest,Courageous and Authentic.<br\> I will identify Obstacles, Challenges, Fears and limitations, NOW, to create with clarity.",

"How can I best Serve?<br\> This is a tone of being active in the world.<br\> I am responsible, Open, Giving and Willing to risk.<br\> I will create Solutions from the field of all possibilities, NOW In order to serve for the higher good of all.",

"What is the Form my Service will Take?<br\> This tone is interested in itself and the way it exists and is associated with the power of defining,  measuring and creating tangible form.<br\> I am Focused, Grounded and Disciplined.<br\> I will Make, Define, and formulate my plan of action, NOW",

"How can I best empower myself?<br\> The 5 the tone, opens up with the sheer delight of being exactly who it is, where it is.<br\> Overtone people command and empower by their presence.<br\> I will recognise and gather my resources, NOW. In order to command the universe into action.",

"How can I extend my Equality to Others?<br\> Universal Energy realises its power of Movement and begins to experience the Rhythmic phase of Creation.<br\> I am Intently Conscious, Focused and CentredI will organise my life NOW. … in order to create Balance and Flow with the Rhythm of the Universe.",

"How can I attune my Service to Others? <br\>7 is the perfect midpoint in the 13 steps of creation.<br\> Relax, Let go and trust your own movements.<br\>Inspire and re-attune Self/Project/Team, NOW<br\> In order to raise the frequency and Resonate at One with the Universe.",

"Do I Live what I believe?<br\> A new octave has begun.<br\> 8 is in harmony with the world and is in a position to model Integrity. I am Accepting of Myself.<br\> I will insure Integrity and Cohesion,and move my Plan into Action, NOW In order to integrate and Embrace all in Harmony.",

"Understanding that it’s directly affecting reality at the level of Intention, the 9th Tone pulses its will into the world around it. I am an emitter of life.<br\> I am creative,  Passionate, Committed and Spontaneous.<br\> I will  Realise and Accomplish my Vision, NOW. In order to manifest, Shift, Grow and Evolve.",

"How do I perfect what I do?<br\> The energy of the 10th Tone is Manifestation, the Universal Process where the World is made Flesh.<br\> I am wholly  Committed, Grateful & Fully aware.<br\> I will manifest  in Excellence, NOW.<br\> In order to recognise Evidence of Myself as Creator, Spirit in Matter & Heaven on Earth",

"At this stage of creation comes a great letting go, the ultimate dissolving and releasing.<br\> Be active and light hearted with the world around you.<br\> I am Vulnerable, Loving, Humble, Forgiving, and Trusting.<br\> I will Release, Let go, Surrender & Honour, NOW.<br\> In order to be free, Clear & Unattached.",

"How can I dedicate myself to all lives?<br\> For the first time Universal Energy enters the mysterious Nothing or darkness from which it came.<br\>  And from this act, crystalline shapes appear.<br\> I am open, Honest, Brave, Loving Supportive and Aware.<br\> I will Discover, Share & Express my Experiences, NOW",

"How Can I expand my Joy and Love?<br\> Tone 13 is all the Tones at once, an ending that is a beginning.<br\> it is Endurance,  Presence, and Transcendence.<br\> I am joyous, Enthusiastic, Abundant and at Peace within and without. I will celebrate my connection with the source and All-That-Is, NOW.");

//************FRENCH TEXT *******************************************
COLOR_F = new Array("","Rouge","Blanc","Bleu","Jaune");

TONE_F = new Array("",
 "Magnétique","Lunaire","Electrique","Auto-existant","Harmonique","Rhythmique","Résonant","Galactique","Solaire","Planétaire","Spectral","Crystal","Cosmique");

SEAL_F = new Array("",
 "Dragon","Vent","Nuit","Graine","Serpent",
 "Enlaceur des Mondes","Main","Etoile","Lune","Chien",
 "Singe","Humain","Voyageur du ciel","Shaman","Aigle",
 "Guerrier","Terre","Mirroir","Tempête","Soleil");

TOTEM_F = new Array("","La Chauve-souris", "Le Scorpion", "Le Cerf", "La Chouette","Le Paon","Le Lezard","Le Singe",
"Le Faucon", "Le Jaguar", "Le Chien", "Le Serpent","Le Lapin","La Tortue");

TEXT_F=new Array("",
"Identifie le but. Intention. Un est la sagesse qui cherche l’amour inconditionnel, l’essence indivisible, le nouveau commencement.<br/> Tu es l’initiateur, celui qui ouvre les chemins. Appelle avec force et conviction la résonance de ta vibration.",

"Identifie le défi, analyse, fait le tri. <br/>C’est le métier à tisser la réalité, polarité  du masculin et du féminin, dualité qui reflète vos conflits,  et l’apparente séparation crée par votre croyance en la dualité.",

"Quel est mon service ? <br/>Le 3 est l’énergie créatrice du mouvement, du changement,de la fluidité, créativité et intégration.<br/> C’est le rayonnement du rythme. <br/>Aligne-toi avec l’intention d’exprimer la vérité. ",

"Quelle est la forme de mon service ?<br/> Qualités: ordre, définition, discernement, cycle naturel.<br/> Le temps est venu de manifester ton rêve ou ta vision. <br/>Observe la logique naturelle, l’ordre et la définition.<br/> Prends tes idées et donne leur discipline et forme.",

"5 est l’intention centrale, le rayonnement du centre, la première barrière, le fondement de l’humanité et du soi individuel. <br/>Accepte ton état d’humain.<br/> Quel est ton pouvoir?<br/> Tu es le maître zen assis dans le mental débutant.",

" Rencontre le défi. <br/>Découvre que tout est sacré. <br/>6 est le rayonnement de l’équilibre organique:Ciel et Terre en union symbiotique.<br/> Réponds à la vie avec amour, amène le Ciel à la Terre.<br/> L’équilibre organique émerge de qui tu es dans toutes les dimensions. ",

"Pouvoir mystique. <br/>Harmonise le service, met la théorie à l’épreuve.<br/> Ouvre tes centres au monde. <br/>Libère-toi du besoin d’approbation extérieure.<br/> Aligne-toi avec le mystère vertébral du 7 : 7 chakras, 7 planètes, 7 rayons, 7 niveaux de la conscience unie.",

" Questionne l’intégrité.<br/> Est-ce que je vis bien ce que je crois ? <br/>8 est l’amour rendu visible,la puissance, la structure galactique, la voie du cœur unique.<br/> Sois réceptif. <br/>Tu es le divin de l’harmonie, le champ de rencontre de la réalité physique et de l’infini. ",

" L’action se met en mouvement, 9 est le rayonnement des grands cycles.<br/> Incarne le commandement et la sagesse. <br/>Deviens celui qui fait briller la lumière pour les autres.<br/> A mesure que tu t’étends, laisse tomber les vieux modèles qui empêchent ta croissance. ",

" 10 est le rayonnement de la Manifestation. <br/>Ouvre les portes aux grands mystères qui se manifestent à travers toi.<br/> Sur quelles structures et croyances est construite ta réalité?<br/>  Quand tu es en résonance avec l’Univers, Manifestation est la résultante naturelle.",

"Comment me libérer?<br/> 11 est le rayonnement de la dissonance et du changement.<br/> Les idéaux & croyances de toutes sortes sont attirés vers toi pour être ré-examinés,  illuminés et transformés. <br/>Ta façade se fissure, quand tes murs tomberont, l’illumination véritable du soi jaillira.",

"Comment je coopère dans la forme ? <br/>12 est le rayonnement de la stabilité complexe, de l’union de la polarité. <br/>Toutes les choses sont entre-tissées dans la danse du yin et du yang.<br/> Demande la sagesse etla force que tu possèdes. <br/>Le mystérieux équilibre du cosmos se dévoile.",

"Comment puis-je vivre ma joie et mon amour ? <br/>13 est le rayonnement du mouvement universel, des forces occultes, des changements inespérés.<br/>  Sois attentif aux synchronicités et aux apparentes coïncidences qui jaillissent à ta conscience.<br/> Deviens celui qui chemine dans les étoiles.");


//******************************************************************

function Main(){

 if(First==true){
  FirstCalc();
  First= false;
 }else{
  ReCalc();
 }
 OneDay();
 
}


function RetToday(){
 First= true;
 Main();
}


function Main_f(){

 if(First==true){
  FirstCalc();
  First= false;
 }else{
  ReCalc();
 }
 OneDay_f();
 
}


function RetToday_f(){
 First= true;
 Main_f();
}


function OneDay_f(){
Gset();

DfromG(Gyear,Gmonth,Gdate);
KINfromD(Year,Moon,Day);
GalacticSignatureF();

}




function FirstCalc(){
 now= new Date(); 
 Gyear = now.getFullYear();
 Gmonth= now.getMonth()+1;
 Gdate = now.getDate();



}

function ReCalc(){

    Gyear = new Number(document.gregorian.year.value);
    Gmonth = document.gregorian.month.value;
    Gdate = new Number(document.gregorian.day.value);



}

function OneDay(){
//alert(Gmonth);
 Gset();

DfromG(Gyear,Gmonth,Gdate);
KINfromD(Year,Moon,Day);
GalacticSignatureE();

}

function Gset(){
 document.gregorian.year.value =Gyear;
 document.gregorian.month.value=Gmonth;
 document.gregorian.day.value =Gdate;
}

DaddG = new Array(0,158,189,217,248,278,309,0,5,36,66,97,127);

function DfromG(y,m,d){
 var sum;
 Year=y;
 sum=DaddG[m]+d;
 if(m<=6){ Year--; }

 if(m==7){
   if(d<26){
     sum=339+d;
     Year--;
   }else{
     sum=d-26;
   }
 }
 sum++;
 Moon= Dint(sum,28);
 Day = Dmod(sum,28);
}

function Dint(x,y){
 return( Math.floor((x-1)/y)+1 );
}

function Dmod(x,y){
 return( ((x-1)%y)+1 );
}



function KINfromD(y,m,d){
 sum= ((y-1900)*365)+((m-1)*28)+d+258;
 kin= Dmod(sum,260);
 return(kin);
}

function GetCTSfromKIN(Kin){
 color=Dmod(Kin,4);  //?
 tone =Dmod(Kin,13); //??
 seal =Dmod(Kin,20); //??

// gGuide=((tone-1)*12)+seal; //????
// gGuide=Dmod(gGuide,20);
}

function ColorE(color){
 //document.write(COLOR_E[color]);
document.getElementById('glyphpic').innerHTML = COLOR_E[color] + " " + TONE_E[tone] + " " + SEAL_E[seal] ;


}

function ToneE(tone){
 
document.getElementById('tonename').innerHTML = "Tone: " +  TONE_E[tone];
}

function SealE(seal){
 //document.write(SEAL_E[seal]);
}

function GalacticSignatureE(){
//set values for colour, tone and seal
 GetCTSfromKIN(kin);

//display number image (dots or bars)1,2,3.jpg etc in left col
numberpic="<table><tr><td><img src='dots_only/" + tone + ".jpg'></td></tr></table>";
document.getElementById('may_num').innerHTML = numberpic;;


//display small glyph image (Seal array earth, dog.jpg etc.)in left col
smallglyphhtml="<table><tr><td><img src='" + SEAL_E[seal]  + ".jpg'></td></tr></table>";
document.getElementById('smallglyphpic').innerHTML = smallglyphhtml;

 
//display colour tone seal combination in left column
document.getElementById('glyphpic').innerHTML = COLOR_E[color] + " " + TONE_E[tone] + " " + SEAL_E[seal] ;


//display tone name above painting
document.getElementById('tonename').innerHTML = "Tone : " +  TONE_E[tone] ;


//display totem name above painting

document.getElementById('totemname').innerHTML = "Totem : " + TOTEM_E[tone]; 




//display painting based on tone name 
pichtml="<table><tr><td><img src='" + TONE_E[tone] + ".jpg' class='ileft'></td></tr></table>";
document.getElementById('tonepic').innerHTML = pichtml;

//display tone text


document.getElementById('tonetext').innerHTML = TEXT_E[tone];


}

//****FRENCH LANGUAGE DISPLAYS

function GalacticSignatureF(){
//set values for colour, tone and seal
 GetCTSfromKIN(kin);

//display number image (dots or bars)1,2,3.jpg etc in left col
numberpic="<table><tr><td><img src='dots_only/" + tone + ".jpg'></td></tr></table>";
document.getElementById('may_num').innerHTML = numberpic;;


//display small glyph image (Seal array earth, dog.jpg etc.)in left col
smallglyphhtml="<table><tr><td><img src='" + SEAL_E[seal]  + ".jpg'></td></tr></table>";
document.getElementById('smallglyphpic').innerHTML = smallglyphhtml;

 
//display colour tone seal combination in left column
document.getElementById('glyphpic').innerHTML = SEAL_F[seal] + " " + COLOR_F[color] + " " + TONE_F[tone] ;


//display tone name above painting
document.getElementById('tonename').innerHTML = "Tonalité : " +  TONE_F[tone] ;


//display totem name above painting

document.getElementById('totemname').innerHTML = "Totem : " + TOTEM_F[tone]; 




//display painting based on tone name 
pichtml="<table><tr><td><img src='" + TONE_E[tone] + ".jpg' class='ileft'></td></tr></table>";
document.getElementById('tonepic').innerHTML = pichtml;

//display tone text


document.getElementById('tonetext').innerHTML = TEXT_F[tone];


}

