/*
<script>
include("page à inclure","l'id ou le nom de l'element dans le quel vous voulez inclure la page");
</script>
*/
var frame_n = 0;
function include_HTML(file, element)
{
frame_n++;

//on cree une iframe dans la page pour recuperer le fichier qu'on veut inclure
document.body.innerHTML += "<iframe class=iframe width=95% height=70% _scrolling=yes src='" + file + "' id='fram" + frame_n +
"' name='frame" + frame_n + "' onload='lire(" + element + "," + frame_n + ")'></iframe>";
}

function lire(element, m)
{
//on ajoute le code source de l'iframe à l'element dans le quel on veut inclure la page
element.innerHTML += frames["frame" + m].document.body.innerHTML;

//on cache l'iframe
//document.getElementById("fram" + m).style.display = "none";
}

function include_script(filename)
{
   if (document.getElementsByTagName)
	{
      Script = document.createElement("script");
      Script.type = "text/javascript";
      Script.src = filename;
      Body = document.getElementsByTagName("BODY");
      if (Body)
		{
         Body[0].appendChild(Script);
      }
   }
}

//<head>
//<script language="JavaScript" src="../js/journal.js"></script>
//</head>

//var copy_year  = "";
//var Copyright0 = "Copyright Pierre LANG &copy; ";
//var Copyright1 = "Copyright Pierre LANG &copy; "
//var Copyright2 = "Tous droits réservés (textes et photographies)."

var journal_width  = "500";
var journal_border = "0";

var frame_n = 0; //on va utiliser cette variable pour donner un nom à une iframe diferent des autres

// FOOTER
function write_footer_journal(page, year)
{
copy_year = year;
Copyright1 = Copyright0 + copy_year + ".";
write_footer(page);
}

function book_title(thetitle)    { document.write("<H1>" + thetitle + "</H1>"); }
function chapter_title(thetitle) { document.write("<H2>" + thetitle + "</H2>"); }
function page_title(thetitle)    { document.write("<H3>" + thetitle + "</H3>"); }
function section_title(thetitle) { document.write("<H3>" + thetitle + "</H3>"); }
function simple_title(thetitle)  { document.write("<H4>" + thetitle + "</H4>"); }

// START OF TEXT IN TABLE
function top_of_table(width, colspan, border)
{
var tag = "";
if (border != 0)
   tag = " BORDER=" + border;
else
   tag = " BORDER=" + journal_border;

if (width == 0)
   width = journal_width;

tag = tag + " WIDTH=" + width + " ";

document.write("<TABLE CLASS=\"journal\"" + tag +">");
}

// END OF TEXT IN COLUMN
function end_of_table() {
document.write("</TD></TR></TABLE>");
}

// TOP OF PAGE
function write_top_of_page_journal()
{
copy_year = year;
Copyright1 = Copyright0 + copy_year + ".";
}

// START OF TEXT IN COLUMN
function write_top_of_page_table(thedate, thetitle)
{
var title = "";

if (thedate != "") {
   title = thedate;
   if (thetitle != "")
      title = title + " - ";
   }
if (thetitle != "")
   title = title + thetitle;

document.write("<CENTER>");
top_of_table(journal_width, 2, 0);
document.write("<TR CLASS=\"cell_row\">");
document.write("<TD CLASS=\"full_row\" COLSPAN=" + 2 + ">");
page_title(title);
}

// END OF TEXT IN COLUMN
function write_end_of_page_table() {
end_of_table();
document.write("</CENTER>");
}

// PHOTO
function image(small, large, legende) {
Photo(small, large, 0, 0, legende, "normal")
}

// PHOTO
function img(small, large, legende) {

var tag = " ALIGN=bottom";

if (large != "")
   document.write("<A TARGET=detail HREF=" + large + "><IMG CLASS=photo " + tag + " SRC=" + small + "></A> ");
else
   document.write("<IMG CLASS=photo " + tag + " SRC=" + small + "> ");
}

// PHOTO
function Photo(small, large, w, h, legende, style) {

var tag = " ALIGN=bottom";

if (w > 0)
   tag = tag + " WIDTH=" + w;
if (h > 0)
   tag = tag + " HEIGTH=" + h;
if (style == "")
   style = "left";
style = "photo_" + style;

document.write("<DIV CLASS=" + style + "><P>");

if (large != "")
   document.write("<A TARGET=detail HREF=" + large + "><IMG CLASS=photo " + tag + " SRC=" + small + "></A>");
else
   document.write("<IMG CLASS=photo " + tag + " SRC=" + small + ">");

if (legende != "")
   document.write("<BR>" + legende);

document.write("<P></DIV>");
}

// CELL
function Cell(colspan) {
   CellExt("left", "left", colspan);
}

function CellExt(type, style, colspan) {

if (style == "")
   style = "justify";
style = "text_" + style;

if (type == "")
   type = "justify";
type = type  + "_cell";
if (type == "row")
   type = "full_row";

if (colspan == 0)
   colspan = 1;

document.write("<TD  CLASS=" + type  + " COLSPAN=" + colspan + ">");
document.write("<DIV CLASS=" + style + ">");
}

// CELL
function Row() {

document.write("<TR  CLASS=cell_row>");
}

function Text(txt, style) {

if (style == "")
   document.write(txt + " ");
else
   document.write("<span class=" + style + ">" + txt + " </span>");
}

function PDF(prompt, file) {

if (prompt == "") prompt = "<BR>Lire le journal du jour...";

document.write("<A TARGET=detail HREF=" + file + ">" + prompt + "</A> ");
document.write("<A TARGET=detail HREF=\"../help/help-download.htm\"><IMG ALIGN=middle CLASS=button SRC=\"../img/bhelp.gif\"></A>");

}

function KML(prompt, file) {

if (prompt == "") prompt = "<BR>Voir la position dans Google Earth...";

document.write("<A TARGET=detail HREF=" + file + ">" + prompt + "</A> ");
document.write("<A TARGET=detail HREF=\"../help/help-google-earth.htm\"><IMG ALIGN=middle CLASS=button SRC=\"../img/bhelp.gif\"></A>");

}

function GPS(prompt, deg_lat, min_lat, sec_lat, NS, deg_long, min_long, sec_long, EW, date, hour) {

var latitude = "";
var longitude = "";
var coord = "";
var lat = 0;
var long = 0;
var time = "";

latitude  = deg_lat  + "°" + min_lat  + "\'";
if (sec_lat > 0)
   latitude  = latitude + sec_lat  + "\"";
latitude  = latitude + " " + NS;

longitude = deg_long + "°" + min_long + "\'";
if (sec_lat > 0)
   longitude  = longitude + sec_long  + "\"";
longitude  = longitude + " " + EW;

coord = latitude + " - " + longitude;

if (date == null) date = "";
if (hour == null) hour = "";
if (date != "") time = " - " + date;
if (hour != "") time = time + " @ " + hour;

if (prompt == "") prompt = "<BR>Position";
prompt = prompt + " : ";

document.write(prompt + " " + coord + " " + time + "<P>");
}


