which_image_loaded = 0;
NUMBER_OF_IMAGES = 6;

ImageNames = new Object();
ImageNames.length = NUMBER_OF_IMAGES - 1;

for (counter = 0; counter < NUMBER_OF_IMAGES; counter++){
    file_number = counter + 1;
    filename = ("images/gallery/image" + file_number + "_small.jpg");
    ImageNames[counter] = filename;
}

function changeImage(direction) {
    which_image_loaded += direction;
    if (which_image_loaded < 0)
        which_image_loaded = NUMBER_OF_IMAGES - 1;
    if (which_image_loaded == NUMBER_OF_IMAGES)
        which_image_loaded = 0;
    if (document.images)
        document.myimage.src = ImageNames[which_image_loaded];
}

function openWindow(imageName,alt) {
    var w = window.open("","newWindow","resizable=1,status=1,scrollbars=1,width=800,height=650");
    w.document.open();

    var t="";
    t+='<HTML>\n<TITLE>'+alt+'</TITLE>\n';
    t+='<HEAD>';
    t+='<SCRIPT LANGUAGE="Javascript">\n';
    t+='\<!--\n';
    t+='function enlarge() {\n';
    t+=' var pic=new Image;\n';
    t+=' pic.src="'+imageName+'";\n';
    t+=' var wd=pic.width+10;\n';
    t+=' var ht=pic.height+10;\n';
    t+=' document.getElementById("foo").src=pic.src;\n';
    t+='}\n';
    t+='\/\/-->\n';
    t+='<\/SCRIPT>\n';
    t+='</HEAD>\n';
    t+='<BODY onLoad="enlarge();" style="margin:20 30 30 20">\n';
    t+='<IMG ID="foo" ALT="'+alt+'">\n';
    t+='</BODY>\n</HTML>\n';
    w.document.write(t)
    w.document.close();
    w.focus();
//t+=' window. resizeTo(wd,ht);\n';
}


var tip=new Array
   tip[0]='JBFCS DONATE - Ways to Give'
   tip[1]='JBFCS VOLUNTEER OPPORTUNITIES'
   tip[2]='ADOBE Reader page'

function showtip(current,e,num)
{
 if (document.layers) // Netscape 4.0+
    {
     theString="<DIV CLASS='ttip'>"+tip[num]+"</DIV>"
     document.tooltip.document.write(theString)
     document.tooltip.document.close()
     document.tooltip.left=e.pageX+14+'px'
     document.tooltip.top=e.pageY+2+'px'
     document.tooltip.visibility="show"
    }
 else
   {
    if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
      {
       elm=document.getElementById("tooltip")
       elml=current
       elm.innerHTML=tip[num]
       elm.style.height=elml.style.height
       elm.style.top=parseInt(elml.offsetTop+elml.offsetHeight)+'px'
       elm.style.left=parseInt(elml.offsetLeft+elml.offsetWidth+10)+'px'
       elm.style.visibility = "visible"
      }
   }
}
function hidetip(){
if (document.layers) // Netscape 4.0+
   {
    document.tooltip.visibility="hidden"
   }
else
  {
   if(document.getElementById) // Netscape 6.0+ and Internet Explorer 5.0+
     {
      elm.style.visibility="hidden"
     }
  }
}

var min=15;
var max=22;
function increaseFontSize()
{
   var p = document.getElementsByTagName('p');
    //alert("var p is -> "+p);
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
          //alert(p[i].style.fontSize);
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 15;
      }
      if(s!=max) {
         s += 1;
      }
      p[i].style.fontSize = s+"px"
   }
}

function decreaseFontSize()
{
   var p = document.getElementsByTagName('p');
   for(i=0;i<p.length;i++) {
      if(p[i].style.fontSize) {
         var s = parseInt(p[i].style.fontSize.replace("px",""));
      } else {
         var s = 15;
      }
      if(s!=min) {
         s -= 1;
      }
      p[i].style.fontSize = s+"px"
   }
}

function set_FontSize(imageName)
{
    //alert("Reached set_FontSize");
    var now = new Date();
    // fix the bug in Navigator 2.0, Macintosh
    fixDate(now);
    var startPosition = imageName.indexOf("-");
    var endPosition = imageName.length;
    //alert("startPosition "+startPosition+"  endPosition  "+endPosition);
    var fontSize = imageName.substring(startPosition+1,endPosition);
    var s = parseInt(fontSize);
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000);
    // set the new cookie
    setCookie("fntSize", s, now);
    var s = getCookie( 'fntSize' );
    //alert("Reached select_FontSize Font Size is -> "+s);
    if (s!= null )
    {
        change_Para_FontSize(s);
    }
    else
    {
        alert("Please Enable Cookies in your browser.\nThe font cannot be set for all pages if cookies are disabled.")
    }
}

function select_FontSize()
{

    //alert("Reached select_FontSize");
    var s = getCookie( 'fntSize' );
    //alert("Reached select_FontSize Font Size is -> "+s);
    if (s!= null )
    {
        change_Para_FontSize(s);
    }
    else
    {
        s=13;
        change_Para_FontSize(s);
    }
}

function change_Para_FontSize(fntSize)
{
    var p = document.getElementsByTagName('p');
    //alert("fntSize is -> "+fntSize);
    for(i=0;i<p.length;i++)
    {
        p[i].style.fontSize = fntSize+"px"
    }
}



function roll_over(img_name, img_src)
{
    document[img_name].src = img_src;
}


function ElementPosition(param){
var x=0, y=0;
var obj = (typeof param == "string") ? document.getElementById(param) : param;
if (obj) {
x = obj.offsetLeft;
y = obj.offsetTop;
var body = document.getElementsByTagName('body')[0];
while (obj.offsetParent && obj!=body){
x += obj.offsetParent.offsetLeft;
y += obj.offsetParent.offsetTop;
obj = obj.offsetParent;
}
}
this.x = x;
this.y = y;
}

/*
Photo Gallery functions Start
*/
function showDiv(divId, imageId, imageName)
{
    var state = 'visible';
    var ImageDivToShow;
    if (document.all)
    { //IS IE 4 or 5 (or 6 beta)
        eval( "document.all." + divId + ".style.visibility = state");
    }
    if (document.layers)
    { //IS NETSCAPE 4 or below
        document.layers[divId].visibility = state;
    }
    if (document.getElementById && !document.all)
    {
        ImageDivToShow = document.getElementById(divId);
        ImageDivToShow.style.visibility = state;
    }
    var ImageToShow = returnObjById(imageId);
    ImageToShow.src=imageName;
}

function hideDiv(divId)
{
    var state = 'hidden';
    if (document.all)
    { //IS IE 4 or 5 (or 6 beta)
        eval( "document.all." + divId + ".style.visibility = state");
    }
    if (document.layers)
    { //IS NETSCAPE 4 or below
        document.layers[divId].visibility = state;
    }
    if (document.getElementById && !document.all)
    {
        ImageDivToHide = document.getElementById(divId);
        ImageDivToHide.style.visibility = state;
    }
}

function returnObjById( id )
{
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}

function getBigFileName(jsFileName)
{
//    jsFileName = document.myimage.src.toString().substring(0,document.myimage.src.toString().length-10)+".jpg";
    //alert("getBigjsFileName -> "+jsFileName);
    openWindow(jsFileName,"Big Image");
    return false;
}
/*
Photo Gallery functions End
*/
