var new_path="0" //marker to indicate picture from folder other than default
var pic_path= "";
var pic_ext = ".jpg";
var mov_ext = ".mov";
var pic_ext = ".jpg";
var mov_ext = ".mov";
var win = "dummy";
var do_480 = "no"
var do_640 = "no"
var do_800 = "no"
var do_screen = "no"
var do_full = "no"
var do_postcard = "no"
var new_path = "0"
var orig_w = "";
var orig_h = "";
var max_w = "";
var max_h = "";
var display_w = "";
var display_h = "";
//myServer="http://www.hardchalk.com/cgi-bin/softchalk/";
myServer="http://www29.pair.com/godwinyj/softchalk/cgi-bin/";
//my_pic_url="file://localhost/WWW/gj/03/sept-dec/";  //this is in picture index file

function getKey() {
 if (event.altKey==true) {
   do_postcard = "yes";
 }
}
  
function showPic(f,w,h) {
try {
if (document.forms[0].res[0].checked == true) {do_full = "yes";}
if (document.forms[0].res[1].checked == true) {do_screen = "yes";}
if (document.forms[0].res[4].checked == true) {do_480 = "yes";}
if (document.forms[0].res[3].checked == true) {do_640 = "yes";}
if (document.forms[0].res[2].checked == true) {do_800 = "yes";}
if (document.forms[0].postcard.checked == true) {do_postcard = "yes";}

  if (do_full != "yes") {
    orig_w = w;
    orig_h = h;
  if (do_480 == "yes") {
     max_w=480;
     max_h=360;
   }
  if (do_640 == "yes") {
      max_w=640;
      max_h=480;
  }
  if (do_800 == "yes") {
      max_w=800;
      max_h=600;
   }
  if (do_screen == "yes") {
      max_w=screen.width;
      max_h=screen.height;
  }
  if (w > max_w || h > max_h) {
      if (w > max_w) {
        w = max_w;
        h = h * (max_w/orig_w)
      } else {
        h = max_h;
        w = w * (max_h/orig_h)
      }
      if (h > max_h) {
       h = max_h
       w =  orig_w * (max_h/orig_h)
     }
    }
  }

  pic_name =  reName(f);
 if (do_postcard == "no") {
 
  scroll_status = "no"
  if (w > screen.width) {
    scroll_status = "yes"
  }
  if (h > screen.height) {
    scroll_status = "yes"
  }
 
   // display_w = (w+15); 
    //display_h = (h+15);
    display_w = w; 
    //display_h = (h+50);
    display_h = h;
    winSpecs = 'width=' + display_w + ',height=' + display_h + ',resizable=yes,scrollbars=' + scroll_status
   
   if (new_path == "1") {f = f + pic_ext} else {f = pic_path + f + pic_ext}
   win = window.open ("",'pic', winSpecs);
   win.document.clear()
   win.document.open()
  // win.document.write("<html><head><title>" + pic_name + "</title></head><body background="+f+"  leftmargin=0 topmargin=0 marginheight=0 marginwidth=0>")
  // win.document.write("<a href='javascript: void window.close()'><img src = '../../gifs/close.gif' width=50 height=50 border=0>")
  // win.document.write("<div align=center><form><input type=button value='Close this window' onClick=window.close()></form><div></body></html>")
   win.document.write("<html><head><title>" + pic_name + "</title></head><body bgcolor=ffffff  leftmargin=0 topmargin=0 marginheight=0 marginwidth=0><a href=javascript:window.close()><img src = "+f+" height = "+h+" border=0></a></body></html>")
   //win.document.write("<form><div align=center><b>Image location:</b>&nbsp; "+document.images[0].src.substring(0,document.images[0].src.length-6)+".jpg&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=button value='Close this window' onClick=window.close()></form><div></body></html>")

   if (parseInt(navigator.appVersion)>=4) { 
       win.resizeTo(display_w,display_h)
   }
   if (((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)>=3)) || ((navigator.appName=="Microsoft") && (parseInt(navigator.appVersion)>=4))) { 
      win.focus()
   }
    win.document.close()
   
  } else {  //if postcard
    //alert("postcard")
    var my_new2="";
    var my_split2="";
    if (f.indexOf("&") != -1){my_split2 = f.split("&")}
    if (f.indexOf("%26") != -1){my_split2 = f.split("%26")}
    for (var k=0; k < (my_split2.length); k++) {
        if (k!=my_split2.length-1) {
          my_new2 = my_new2 + my_split2[k].substring(0,1) + my_split2[k].substring(1,my_split2[k].length) + "-and-";
        } else {
          my_new2 = my_new2 + my_split2[k].substring(0,1) + my_split2[k].substring(1,my_split2[k].length)
        }
        f = my_new2;
     }
      pic = f+".jpg"
      pic_url = my_pic_url+"/"+pic
      //alert(my_pic_url)
      new_name = pic_name.replace(/ /g,'-space-');
      new_name2 = new_name.replace(/&/g,'-and-');
     my_url = eval('myServer +"postcard.cgi?my_pic=" + pic_url + "&pic_height=" + h + "&pic_width=" + w + "&pic_name=" + new_name2');
     win = window.open(my_url,'pic','width=685,height=500');
     win.focus();
    img="";pic="";my_pic="";pic_height="";pic_width="";
    do_postcard = "no"
  }
    do_480 = "no"
    do_640 = "no"
    do_800 = "no"
    do_screen = "no"
    do_full = "no"
    new_path = "0"
 } catch (e){
   alert("Error: " + e.name + " - " + e.message)
 }
 }
function showMov(f,w,h) {
 if ((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)>=4)) {
  if (win != "dummy") {
     if (win.closed == false) {
       win.close()
     }
   }
  }
   winSpecs = 'width=' + w + ',height=' + h
   f = mov_path + f + mov_ext
   win = window.open (f,"", winSpecs);
   if (((navigator.appName=="Netscape") && (parseInt(navigator.appVersion)>=3)) || ((navigator.appName=="Microsoft") && (parseInt(navigator.appVersion)>=4))) { 
      win.focus()
   }
 }
 function reName(f,w,h) {
   var my_name="";
   var my_new="";
   var my_split_name = "";
   var my_recombined = "";
   f = f.replace(/\//g,' - _');
   filename_split = f.split("_");
   for (var i=0; i < filename_split.length; i++) {
    if (filename_split[i]) {
     if (filename_split[i].indexOf("%26") != -1  || filename_split[i].indexOf("&") != -1) {
      my_recombined = filename_split[i];
      if (filename_split[i].indexOf("&") != -1){my_split = my_recombined.split("&")}
      if (filename_split[i].indexOf("%26") != -1){my_split = my_recombined.split("%26")}
      for (var j=0; j < (my_split.length); j++) {
        if (j!=my_split.length-1) {
          my_new = my_new + my_split[j].substring(0,1).toUpperCase() + my_split[j].substring(1,my_split[j].length) + " and ";
        } else {
          my_new = my_new + my_split[j].substring(0,1).toUpperCase() + my_split[j].substring(1,my_split[j].length)
        }
        my_recombined = my_new;
      }
     } else {
       my_recombined = filename_split[i]
     }
    }
    var cap_name = my_recombined.substring(0,1).toUpperCase() + my_recombined.substring(1,my_recombined.length)
     my_name = my_name + cap_name + " "
   }
   my_name = my_name
    if (my_name.substring(my_name.length-1,my_name.length) == " "){my_name = my_name.substring(0,my_name.length-1)}
   return my_name
 }
 
 function get_Name(f,w,h){
   window.status=reName(f,w,h) + " (Picture size is " + w + " pixels wide and " + h + " pixels high)"
   return true
 }
