﻿var Exx = {};
    


Exx.calendar = function (o){
    var date = document.getElementById("DateTime").value;
    var indexMonthDate = date.indexOf("/");
    var indexYearDate = date.indexOf("/", indexMonthDate + 1);
    var pgDate = date.substring(0, indexMonthDate) + date.substr(indexYearDate);
    
    Exx.calendar.cal1 = new YAHOO.widget.Calendar("cal1","calendar",{ pagedate:pgDate,
								      selected:date });
        
    Exx.calendar.cal1.render();
};

Exx.calendar.cal1 = "";

Exx.Editor = new YAHOO.widget.Editor("Description", {
    height: '300px',
    width: '522px',
    dompath: true, //Turns on the bar at the bottom
    animate: true //Animates the opening, closing and moving of Editor windows    
});

Exx.calendar.arrDates = "";
Exx.calendar.getDates = function (){
    Exx.calendar.arrDates = Exx.calendar.cal1.getSelectedDates();
    document.getElementById("DateTime").value = Exx.calendar.arrDates[0].getFullYear() + "-" + (Exx.calendar.arrDates[0].getMonth() + 1) + "-" + Exx.calendar.arrDates[0].getDate();
    
};

Exx.initEditorCalendar = function (){
    try {Exx.Editor.render();}
    catch (e){}
    try {Exx.calendar();}
    catch (e){}
    }
    
Exx.cocheinput = function(){
    if (document.getElementById("coche").checked == true)
        document.getElementById("cocheinput").value = "True";
    else
        document.getElementById("cocheinput").value = "False";
}

Exx.Submit = function (){
    try {Exx.Editor.saveHTML();}
    catch (e){}
    try {Exx.calendar.getDates();}
    catch (e){}
    try {document.getElementById("gmapcoor").value = Exx.marker.getLatLng().y + ", " + Exx.marker.getLatLng().x;}
    catch (e){}
    try {Exx.cocheinput();}
    catch (e){}
    document.getElementById("modform").submit();};
    
Exx.Submit2 = function (){
    try {Exx.Editor.saveHTML();}
    catch (e){}
    document.getElementById("mailform").submit();};

	    




