function pop_up(URL, width, height, left, top) {
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=" + width + ",height=" + height + ",left=" + left + ",top=" + top + "');");
}

/* Temporary function for Firefox bug with multipart JPEGs */
function multipartWorks() {
	var index = navigator.userAgent.indexOf('rv:');
	if (index == -1) return false;
	var version = navigator.userAgent.substring(index+3);
	version = version.replace(/\./g, '');
	version = parseFloat(version.substring(0, 1) + '.' + version.substring(1));
	if(version >= 1.905 || version < 1.82) {
		return true;
	}
	return false;
}

function axis_cam(BaseURL, Camera, ImageResolution, DisplayWidth, DisplayHeight) {
/*
var BaseURL = "http://67.140.105.54/";
var Camera = ""; // AXIS 2400/2400+
var ImageResolution = "704x480";
var DisplayWidth = "704";
var DisplayHeight = "480";
*/
var File = "axis-cgi/mjpg/video.cgi?resolution=" + ImageResolution;
if (Camera != 0) { File += "&camera=" + Camera; }
var output = "";
if(multipartWorks())
{
// Show the image as a native multipart/jpeg image stream
output = '<img src="' + BaseURL + File + '" height="' + DisplayHeight + '" width="' + DisplayWidth + '" alt="Now Loading: SkyCam 3 in St. Louisville, Ohio" title="SkyCam 3 - St. Louisville, Ohio" />';
}
else
{
// Use Cambozola java applet
output = '<applet code="com.charliemouse.cambozola.Viewer" archive="/data/cambozola.jar" width="' + DisplayWidth + '" height="' + DisplayHeight + '">' + 
'<param name="url" value="' + BaseURL + File + '" />' +
'<param name="accessories" value="none" />' +
'</applet>';
}
document.write(output);
}


// Javascript image loop functions
// Adapted from jsImagePlay, by Martin Holecko
// jsImagePlay website no longer exists
//
image_name = "latest";		// the base "path/name" of the image set without the numbers
image_type = "jpg";		// Image extension
first_image = 1;		// First image number
last_image = 16;		// Last image number
image_prefix = 1;		// Prefix the image number? (1 => 01)
// ! The size is very important - if incorrect, browser tries to 
// ! resize the images and slows down significantly
animation_height = 704;		// Height of the images in the animation
animation_width = 480;		// Width of the images in the animation

//
// Global variables
//
theImages = new Array();
normal_delay = 300;
delay = normal_delay;  //delay between frames in 1/100 seconds
delay_step = 50;
delay_max = 4000;
delay_min = 50;
current_image = first_image;     //number of the current image
timeID = null;
status = 0;            // 0-stopped, 1-playing
size_valid = 0;
resetloop = 0;
old_delay = 0;

// Makes sure the first image number is not bigger than the last image number
if (first_image > last_image) 
{
   var help = last_image;
   last_image = first_image;
   first_image = help;
};
// Preload the images - gets executed first, while downloading the page
for (var i = first_image; i <= last_image; i++) 
{
	theImages[i] = new Image();
	if(image_prefix == 1 && i < 10) {
		i_pre = "0" + i;
	} else {
		i_pre = i;
	}
	theImages[i].src = image_name + "_" + i_pre + "." + image_type;
};
// Displays image depending on the play mode in forward direction
function animate_fwd() 
{
   current_image--;
   if(current_image < first_image)
   { 
	if(resetloop) {
	resetloop = 0;
	delay = old_delay;
        current_image = last_image;	//RESET LOOP
	} else {
	resetloop = 1;
	current_image = first_image;    //LOOP PAUSE
	old_delay = delay;
	delay = 1000;
	}
   }
  document.animation.src = theImages[current_image].src;
  document.control_form.frame_nr.value = current_image;
  timeID = setTimeout("animate_fwd()", delay);
}
// Displays image depending on the play mode in reverse direction
function animate_rev() 
{
   current_image++;
   if(current_image > last_image)
   { 
         current_image = first_image; //LOOP
   }
   document.animation.src = theImages[current_image].src;
   document.control_form.frame_nr.value = current_image;
   timeID = setTimeout("animate_rev()", delay);
}
// Changes playing speed by adding to or substracting from the delay between frames
function change_speed(dv) 
{
   delay+=dv;
   if(delay > delay_max) delay = delay_max;
   if(delay < delay_min) delay = delay_min;
}
// Stop the movie
function stop() 
{
	if(status == 1) {
		clearTimeout(timeID);
	}
	status = 0;
}
// Function to play animation forward
function fwd() 
{
   stop();
   status = 1;
   animate_fwd();
}
// Jumps to a given image number
function go2image(number)
{
   stop();
   if (number > last_image) number = last_image;
   if (number < first_image) number = first_image;
   current_image = number;
   document.animation.src = theImages[current_image].src;
   document.control_form.frame_nr.value = current_image;
}
// "Play reverse"
function rev() 
{
   stop();
   status = 1;
   animate_rev();
}
// Sets everything once the whole page and the images are loaded
function launch() 
{
   stop();
   current_image = last_image;
   document.animation.src = theImages[current_image].src;
   document.control_form.frame_nr.value = current_image;
   document.control_form.start_but.value = "First (#" + first_image + ")";
   document.control_form.end_but.value = "Last (#" + last_image + ")";
}
