// -- Setup general image manipulation routines
var Dir_Image_Sources = new Array();
function Find_Img(F_Img_Id) {
 for (var F_Img_Cnt = Dir_Image_Sources.length-1; F_Img_Cnt >= 0; F_Img_Cnt-=1) {
  var Full_Path = document.getElementById("image"+F_Img_Id).src;
  var P_Start = Full_Path.length - Dir_Image_Sources[F_Img_Cnt].length;
  var Img_Path = Full_Path.substr(P_Start);
  if (Dir_Image_Sources[F_Img_Cnt] == Img_Path) return F_Img_Cnt;
 }
 return 0;
}
function Disp_Img(Img_Id,Img_Cnt) {
 document.getElementById("image"+Img_Id).src = Dir_Image_Sources[Img_Cnt];
 if (document.getElementById("inpic"+Img_Id)) document.getElementById("inpic"+Img_Id).value = Dir_Image_Sources[Img_Cnt];
}
function Prev_Img(P_Img_Id){
 if (Dir_Image_Sources.length < 3) Disp_Img(P_Img_Id,Dir_Image_Sources.length-1);
 else {
  var P_Img_Cr = Find_Img(P_Img_Id)-1;
  if (P_Img_Cr < 1) P_Img_Cr = Dir_Image_Sources.length-1;
  Disp_Img(P_Img_Id,P_Img_Cr);
 }
}
function No_Img(No_Img_Id) {
 Disp_Img(No_Img_Id,0);
}
function Next_Img(N_Img_Id) {
 if (Dir_Image_Sources.length < 3) Disp_Img(N_Img_Id,Dir_Image_Sources.length-1);
 else {
  var N_Img_Cr = Find_Img(N_Img_Id)+1;
  if (N_Img_Cr >= Dir_Image_Sources.length) N_Img_Cr=1;
  Disp_Img(N_Img_Id,N_Img_Cr);
 }
}
function Home_Image(){
 Next_Img(0);
 t = setTimeout("Home_Image()",5000);
}
function ShowHide_Element(E_Id) {
 if (document.getElementById(E_Id).style.display == "inline") document.getElementById(E_Id).style.display = "none";
 else document.getElementById(E_Id).style.display = "inline";
}
function SwapText_Value(E_Id,txt1,txt2) {
 if (document.getElementById(E_Id).value == txt1) document.getElementById(E_Id).value = txt2;
 else document.getElementById(E_Id).value = txt1;
}
function Show_Month(Mnth) {
 if (document.getElementById("month"+Mnth).style.display == "none") {
  document.getElementById("month"+Mnth).style.display = "inline";
  Nxt_Mnth = Mnth+1;
  Prv_Mnth = Mnth-1;
  if (document.getElementById("month"+Nxt_Mnth)) document.getElementById("month"+Nxt_Mnth).style.display = "none";
  if (document.getElementById("month"+Prv_Mnth)) document.getElementById("month"+Prv_Mnth).style.display = "none";
 }
}
// -- Adjust href's for all elememnts with rel="external" adding target="_blank"
function externalLinks() {
 if (!document.getElementsByTagName) return;
 var anchors = document.getElementsByTagName("a");
 for (var i=0; i<anchors.length; i++) {
   var anchor = anchors[i];
   if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external") anchor.target = "_blank";
 }
}
