//THIS IS A COLLECTION OF SHARED SCRIPTS FOR THE MINER ISLAND PARADISE WEBSITE

// Hides all Javascript errors
window.onerror=null;

// This script opens a new browser window and writes
// HTML to display an image with a title and caption

function show_photo( pFileName, pTitle, pCaption, pWidth, pHeight) {

 // specify window parameters dependant upon screen resolution
 if ( screen.height<768||screen.width<1024) {
 photoWin = window.open( "", "photo", "width=665,height=540,screenX=70,screenY=0,left=70,top=0,scrollbars,resizable");
 } else {
 photoWin = window.open( "", "photo", "width=665,height=620,screenX=170,screenY=40,left=170,top=40");
 }
 // write content to window
 photoWin.document.write('<html><head><title>' + pTitle + '</title></head>');        
 photoWin.document.write('<body style="margin:0px" bgcolor="#FFFFFF" link="#0000ff" vlink="#880088" background="pictures/bkgrnd.jpg">');
 photoWin.document.write('<center>');
 photoWin.document.write('<b>' + pTitle + '</b><br>');        
 if (pWidth != null) {
 photoWin.document.write('<img src="' + pFileName + '" width="' + pWidth + '" height="' + pHeight + '" alt="' + pTitle + '"><br>');
 } else {
  photoWin.document.write('<img src="' + pFileName + '" width="640" height="480" alt="' + pTitle + '"><br>');}
 photoWin.document.write('<font size="-1">' + pCaption + '</font><br>');
 photoWin.document.write('<font face="arial,helvetica" size="-2">');
 photoWin.document.write('photo &copy; Copyright 2001-2002 Miner Island Paradise</font><br>');
 photoWin.document.write('<form><input type="button" value="Close Window" onClick="self.close()"></form>');
 photoWin.document.write('</center></body></html>');
 photoWin.document.close();    
             
 // If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}

// This script opens a new browser window and writes
// HTML to display panoramic images with a title and caption

function show_pan( pFileName, pTitle, pCaption) {

 // specify window parameters
 if ( screen.height<768||screen.width<1024) {
 photoWin = window.open( "", "photo", "width=500,height=325,screenX=0,screenY=120,left=0,top=120,scrollbars");
 } else {
 photoWin = window.open( "", "photo", "width=1000,height=325,screenX=0,screenY=200,left=0,top=200,scrollbars");
 }

 // write content to window
 photoWin.document.write('<html><head><title>' + pTitle + '</title></head>');        
 photoWin.document.write('<body bgcolor="#FFFFFF" link="#0000ff" vlink="#880088" background="pictures/bkgrnd.jpg">');
 photoWin.document.write('<center>');
 photoWin.document.write('<b>' + pTitle + '</b><br>');        
 photoWin.document.write('<img src="' + pFileName + '" alt="' + pTitle + '"><br>');
 photoWin.document.write('<font size="-1">' + pCaption + '</font><p>');
 photoWin.document.write('<font face="arial,helvetica" size="-2">');
 photoWin.document.write('photo &copy; Copyright 2001-2002 Miner Island Paradise</font><br>');
 photoWin.document.write('<form><input type="button" value="Close Window" onClick="self.close()"></form>');
 photoWin.document.write('</center></body></html>');
 photoWin.document.close();    
             
 // If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}

// This script opens a new browser window and writes
// HTML to display an image with a title and caption from the photo gallery

function show_gphoto( pFileName, pTitle, pCaption, pOrigin, pWidth, pHeight) {

 // specify window parameters dependant upon screen resolution
 if ( screen.height<768||screen.width<1024) {
 photoWin = window.open( "", "photo", "width=665,height=540,screenX=70,screenY=0,left=70,top=0,scrollbars,resizable");
 } else {
 photoWin = window.open( "", "photo", "width=665,height=620,screenX=170,screenY=40,left=170,top=40");
 }
 // write content to window
 photoWin.document.write('<html><head><title>' + pTitle + '</title></head>');        
 photoWin.document.write('<body style="margin:0px" bgcolor="#FFFFFF" link="#0000ff" vlink="#880088"');
 photoWin.document.write(' background="pictures/bkgrnd.jpg">');
 photoWin.document.write('<center>');
 photoWin.document.write('<b>' + pTitle + '</b><br>');        
 if (pWidth != null) {
 photoWin.document.write('<img src="' + pFileName + '" width="' + pWidth + '" height="' + pHeight + '" alt="' + pTitle + '"><br>');
 } else {
 photoWin.document.write('<img src="' + pFileName + '" width="640" height="480" alt="' + pTitle + '"><br>');}
 photoWin.document.write('<font size="-1">' + pCaption + '</font><br>');
 photoWin.document.write('<font face="arial,helvetica" size="-2">');
 photoWin.document.write('photo &copy; Copyright 2001-2002 Miner Island Paradise</font><br>');
 photoWin.document.write('<form><input type="button" value="Visit Original Page"');
 photoWin.document.write(' onClick="opener.location.href = \'' + pOrigin + '\'\; self.close()">');
 photoWin.document.write('<input type="button" value="Return To Gallery"');
 photoWin.document.write(' onClick="self.close()"></form>');
 photoWin.document.write('</center></body></html>');
 photoWin.document.close();    
             
 // If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}

// This script opens a new browser window and writes
// HTML to display an image with a title and caption from a photo page
// with the additional ability to send to viewer to another related photo page

function show_ophoto( pFileName, pTitle, pCaption, pOrigin, pButton, pWidth, pHeight) {

 // specify window parameters dependant upon screen resolution
 if ( screen.height<768||screen.width<1024) {
 photoWin = window.open( "", "photo", "width=665,height=540,screenX=70,screenY=0,left=70,top=0,scrollbars,resizable");
 } else {
 photoWin = window.open( "", "photo", "width=665,height=620,screenX=170,screenY=40,left=170,top=40");
 }
 // write content to window
 photoWin.document.write('<html><head><title>' + pTitle + '</title></head>');        
 photoWin.document.write('<body style="margin:0px" bgcolor="#FFFFFF" link="#0000ff" vlink="#880088" background="pictures/bkgrnd.jpg">');
 photoWin.document.write('<center>');
 photoWin.document.write('<b>' + pTitle + '</b><br>');        
 if (pWidth != null) {
 photoWin.document.write('<img src="' + pFileName + '" width="' + pWidth + '" height="' + pHeight + '" alt="' + pTitle + '"><br>');
 } else {
 photoWin.document.write('<img src="' + pFileName + '" width="640" height="480" alt="' + pTitle + '"><br>');}
 photoWin.document.write('<font size="-1">' + pCaption + '</font><br>');
 photoWin.document.write('<font face="arial,helvetica" size="-2">');
 photoWin.document.write('photo &copy; Copyright 2001-2002 Miner Island Paradise</font><br>');
 photoWin.document.write('<form><input type="button" value="Go to ' +pButton + ' page" ');
 photoWin.document.write('onClick="opener.location.href = \'' + pOrigin + '\'\; self.close()">');
 photoWin.document.write('<input type="button" value="Close Window" onClick="self.close()"></form>');
 photoWin.document.write('</center></body></html>');
 photoWin.document.close();    
             
 // If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") photoWin.focus();
}



// This script opens a new browser window and writes
// HTML to display a web page from an outside link with a return feature

function show_link(pLinkName) {

 // specify window parameters
 linkWin = window.open('','link','scrollbars,resizable,status,menubar,location,toolbar');

 // write content to window
 linkWin.document.write('<html><head><title>Miner Island Paradise</title></head>');
 linkWin.document.write('<frameset framespacing=0 frameborder=1 border=4 rows="55,*">');
 linkWin.document.write('<frame name=TopFrame src=top_frame.htm noresize scrolling=no>');
 linkWin.document.write('<frame name=OutSideFrame src="' + pLinkName + '">');
 linkWin.document.write('<noframes>');
 linkWin.document.write('<body>');
 linkWin.document.write('This page uses frames, but your browser does not support them.');
 linkWin.document.write('</body>');
 linkWin.document.write('</noframes>');
 linkWin.document.write('</frameset>');
 linkWin.document.write('</html>');
 linkWin.document.close();    
             
 // If we are on NetScape, we can bring the window to the front
 if (navigator.appName.substring(0,8) == "Netscape") linkWin.focus();
}


// This function preloads a future document into cache for faster loading

function preload_document (next_doc) {
 // Am I the "next document" or the "current document"?
 if (window . name == "preloader") {
   // (next document)
   // Close the preloader window:
    self . close ();
 } else {
   // (current document)
   if (next_doc != null) {
     // Open a preloader window:
     window.open(next_doc, "preloader", "width=1,height=1,screenX=1500,screenY=1500,left=1500,top=1500");
     // Raise current window to the top:
     self . focus ();
   }
 }
  // add this line with correct file name in the body tag of both documents
  // onLoad="preload_document('filename.htm')"
}


// This function preloads image from an array created
// in each document header and called onLoad in the body tag

function preloadImages(the_images_array) {
  for(loop = 0; loop < the_images_array.length; loop++)
  { var an_image = new Image();
    an_image.src = the_images_array[loop];
  }
}


// This function retrieves a session only cookie by name
// Get cookie routine by Shelley Powers 
function get_cookie(Name) {
   var search = Name + "="
   var returnvalue = "";
   if (document.cookie.length > 0) {
   offset = document.cookie.indexOf(search)
  // if cookie exists
   if (offset != -1) { 
   offset += search.length
  // set index of beginning of value
   end = document.cookie.indexOf(";", offset);
  // set index of end of cookie value
   if (end == -1) end = document.cookie.length;
   returnvalue=unescape(document.cookie.substring(offset, end))
   }
   }
   return returnvalue;
}


// This function opens a window which allows the user to change background music

function openMusic() {
  window.open('music.htm', 'musicselection', 'width=200,height=300,screenX=0,screenY=130,left=0,top=130');
}

function checkDate() {
if (document.search_news.EndDate.options[document.search_news.EndDate.selectedIndex].value < document.search_news.StartDate.options[document.search_news.StartDate.selectedIndex].value) {
 alert('End Date must be after Start Date');
}
}

