<!--
function MM_findObj(n, d) { //v3.0
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
 var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
   var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
   if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function pop(val){
   popup =  window.open(val,"360","height=450,width=400,scrollbars=no")
}

/* 
--------------                make javascript gallery object         -------------------- 
    function name: make_gallery
    description:   returns a gallery object that will then cycle through series of images - loading a control (div) with appropriate image
    parameters: 
            gBuffer == the chevron and pipe delimited string needed to build gallery images
            gControl == name of the control (div) that is to be loaded with gallery images 
            gAuto == true/false flag indicating if gallery is to be cycled automatically
            gInterval == number of milliseconds between image change events
            gWidth==width of images
            gHeight=height of images
            gDisplay==optional: name of area to display the alt text for an image
            
    
*/
var gallery_timer // page level variable for the gallery object
function make_gallery(gBuffer,gControl,gAuto,gInterval, gWidth,gHeight,gDisplay){
   
    var svalue=gBuffer
    if (svalue.length==0){
        this.ok=false;
        this.start=start_gallery;
        return this;
    }
    if (svalue.charAt(svalue.length - 1) == "|") svalue = svalue.substr(0,svalue.length - 1);
	var sdata=svalue.split("|"); // array of chevron delimited strings
    this.controlname=gControl;
    this.auto=gAuto;
    this.interval=gInterval;
    this.imagewidth=gWidth;
    this.imageheight=gHeight ;
    alert('here');
    this.start=start_gallery;
    alert('here2');
    this.next=get_next_image;
    this.previous=get_last_image;
    this.stop=stop_gallery;
    this.index=0;
    this.contents=new Array();
    this.get_current=get_current_gallery_item;
    this.ok=true;
    if (arguments.length==7){
        this.display=gDisplay;
        this.showtitle=true;
    }
    else{
        this.display='';
        this.showtitle=false;    
    }
    for (var i=0;i<sdata.length;i++){
        var g = new make_gallery_item(sdata[i]);
        this.contents[this.contents.length]=g;
    }
    //alert(this.contents.length);
    
//    alert(gControl);
if($(gControl)){
    if (this.contents[0].source.indexOf('http')!=0){
        var shtml='<img id="galleryimage" src="../images/' + this.contents[0].source + '" alt="' + this.contents[0].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
    }
    else{
        var shtml='<img id="galleryimage" src="' + this.contents[0].source + '" alt="' + this.contents[0].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
    }    
    $(gControl).innerHTML=shtml;
    if (this.showtitle){
        $(this.display).innerHTML=this.contents[0].title;
    }
}    
    return this;
}

function get_current_gallery_item(){
    return this.contents[this.index].id;
}
/* 
--------------             make gallery item (for use in gallery object) ---------------- 
    function name: make_gallery_item
    description: creates a single gallery item that gets loaded into the gallery display area
    parameters:
            svalue - image id ^ image title ^ image source ^ sequence ^ |
 */
function make_gallery_item(strSource){
    //alert(strSource)
    if (strSource.charAt(strSource.length - 1) == "^") strSource = strSource.substr(0,strSource.length - 1);
	var sdata=strSource.split("^"); // array 
    this.id=sdata[0];
    this.title=sdata[1];
    this.source=sdata[2];
    this.sequence=sdata[3];
    this.current=false;
    //alert(this.source.indexOf('http'))
    if (this.source.indexOf('http')!=0){
        this.code='<img id="galleryimage" src="../images/' + this.source + '" alt="' + this.title + '">'
        
        var pimage=new Image(); //get the image down into the local cache
        pimage.src='../images/' + this.source
    }
    else{
        this.code='<img id="galleryimage" src="' + this.source + '" alt="' + this.title + '">'
        var pimage=new Image(); //get the image down into the local cache
        pimage.src=this.source
    }
    return this;
}

/* 
-------------------       start gallery (for use with gallery object) ---------------------
   function name: start_gallery
   description:    starts (if auto) a gallery object cycling through images
   parameters: none
*/
function start_gallery(varname){
	alert('here');
    if (this.ok){
        if (this.auto){			
            if (this.contents.length > 1){
                gallery_timer=setTimeout(varname + ".next('" + varname + "');",this.interval);
            }
        }
    }
    return void[0];
}

/* 
-------------------      Get Next Image (for use with Gallery Object) --------------------- 

*/
function get_next_image(varname){
        this.index++
//        alert("next image " + this.index + ' of ' + this.contents.length)
        if (this.index == this.contents.length){
            this.index=0;
        }
        if (this.contents[this.index].source.indexOf('http')!=0){
            var shtml='<img id="galleryimage" src="../images/' + this.contents[this.index].source + '" alt="' + this.contents[this.index].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
        }
        else
        {
            var shtml='<img id="galleryimage" src="' + this.contents[this.index].source + '" alt="' + this.contents[this.index].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
        }
        $(this.controlname).innerHTML=shtml;
        if (this.showtitle){
            $(this.display).innerHTML=this.contents[this.index].title;
        }
        if (this.auto){

        gallery_timer=setTimeout(varname + ".next('" + varname + "');",this.interval);
        }
}
/* 
-------------------      Get Previous Image (for use with Gallery Object) --------------------- 

*/
function get_last_image(){
        this.index--
        if (this.index==-1){
            this.index=0;
        }
        if (this.contents[this.index].source.indexOf('http')!=0){
            var shtml='<img id="galleryimage" src="../images/' + this.contents[this.index].source + '" alt="' + this.contents[this.index].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
        }
        else{
            var shtml='<img id="galleryimage" src="' + this.contents[this.index].source + '" alt="' + this.contents[this.index].title + '" width="' + this.imagewidth + 'px;" height="' + this.imageheight + 'px;" style="border:0px;">'
        }
        $(this.controlname).innerHTML=shtml;
        if (this.showtitle){
            $(this.display).innerHTML=this.contents[this.index].title;
        }

}
/* 
-------------------      Stop Gallery (for use with Gallery Object) --------------------- 

*/
function stop_gallery(){
    clearTimeout(gallery_timer);
}



//-->