// This script is written by Serguei Zinine for Tengye Ling Tibetan Buddhist Temple
// Part of the site scripts originally developed by Mark Segal for Club-Web

// GLOBAL VARIABLES

//This is the name of the page currently displayed in the document frame

var current_page="main";

//These are buttons images - current and previous

var current="images/nav_mainon.gif";
var precurrent="images/nav_main.gif";

// It is a constructor for a current button image

var current_image=new Image();

// It is the current Y-coordinate of the image being clicked

var currentY=0;

// Browser characteristics

var browser_type3=navigator.userAgent.indexOf ("Mozilla/3")
var browser_type4=navigator.userAgent.indexOf ("Mozilla/4")
var browser_name=navigator.appName
var browser_version=navigator.appVersion

// INITIALIZATION
current_image.src="images/nav_mainon.gif";
// current_image.name="main";

// FUNCTIONS
// These functions changes the images, and the text displayed on the status bar

function image_out(name, path, text) 
 {
	 if ((browser_type3 >= 0 | browser_type4 >= 0)
          && ((current_page < name.name) || (current_page > name.name)))
	 {
		name.src=path; 
		window.status=text;
	 }	  
  };
function image_over(name, path, text) 
 {
	 if ((browser_type3 >= 0 | browser_type4 >= 0)
          && ((current_page < name.name) || (current_page > name.name)))
	 {
	 name.src=path;
  	 window.status=text; 
	 } 
  };

function image_click(name, path, text) 
 {
	 if (browser_type3 >= 0 | browser_type4 >= 0) 
	 {
	 name.src=path;
  	 window.status=text; 
	 } 
  };

function reset_all ()
	{
	document.main.src="images/nav_main.gif";
	document.news.src="images/nav_news.gif";
	document.location.src="images/nav_location.gif";
	document.who.src="images/nav_who.gif";
	document.programme.src="images/nav_programme.gif";
	document.dharma.src="images/nav_dharma.gif";
	document.links.src="images/nav_links.gif";
	document.events.src="images/nav_events.gif";
	document.nuns.src="images/nav_nuns.gif";
	};

function define_page(text) 
 {
	reset_all();
	current_page=text;
	current="images/nav_"+text+"on.gif";
	precurrent="images/nav_"+text+".gif";

 }

function EnlargePicture (link,name,text)
{

var disp_width=screen.width-260;
var disp_height=screen.height-240;

var ratio=name.width / name.height;
var typeoffit=1;
var old_height=name.height;
var old_width=name.width;
var new_height;
var new_width;

// currentY=link.readY();
// alert(currentY);

if ((name.height > disp_height) & (name.width > disp_width))
   {typeoffit=4}
else 
   {if ((name.height > disp_height) & (name.width < disp_width))
     {typeoffit=3}
    else
       {if ((name.height < disp_height) & (name.width > disp_height))  
	   {typeoffit=2}
        else 
          {typeoffit=1}
       }
    }
;

// alert (old_height+'+'+old_width+'+'+new_height+'+'+new_width+'+'+disp_height+'+'+disp_width+'+'+ratio+'+'+typeoffit);

if (typeoffit==1) {new_height=disp_height; new_width=(disp_height*ratio)};
if (typeoffit==2) {new_height=(disp_width/ratio); new_width=disp_width};
if (typeoffit==3) {new_height=disp_height; new_width=(disp_height*ratio)};
if (typeoffit==4) {new_height=disp_height; new_width=(disp_height*ratio)};
//
var pagebody =  '<html><head><title>Picture</title></head>'+
		    '<body text="#000000" bgcolor="#FFC710"'+ 
		    'background="images/bg16.gif"  bgproperties="fixed">'+
//
		'<dd><marquee color="#800000" height="2%" vspace="0"' +
		'scrolldelay="100" border="0"'+
		'style="font-family: Arial, Times New Roman; font-size: 8pt; color: '+ 
		'rgb(128,0,0); font-weight: bolder; font-style: italic; letter-spacing: 1px"'+
    		'width="100%" behavior="alternate">Click on Picture to Return'+ 	
		'!</marquee></dd>'+
//
		'<a href="'+link+'">'+
		'<p align="center">'+
		'<img SRC="'+name.src+'"align="center"'+
		'width="'+new_width+'" height="'+new_height+'"'+	
		'>'+
		'</a>'+
		'</p>'+
		' '+
		'<br><center><font size="+1.3" color="#990000">'+
		text+'</font></center>'+
		'</body>';

document.write
(
pagebody
);

// alert (old_height+'+'+old_width+'+'+new_height+'+'+new_width+'+'+disp_height+'+'+disp_width+'+'+ratio+'+'+typeoffit);

};

// This function changes  quotations in the menu frame

function changeQuote( )
{
var quoteId=0;
var freq=1000;
var quotes=new Array(3);

quotes[0]= "images/nav_motto1.gif"
quotes[1]= "images/nav_motto2.gif"
quotes[2]= "images/nav_motto3.gif"

if (browser_type4 >= 0)
{
quoteId=Math.floor(Math.random()*quotes.length);
document.motto.src=quotes[quoteId]

setTimeout('changeQuote()', freq);
}

}

