﻿
function ImageGallery(IGObj) {

		this.IE = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5, navigator.appVersion.indexOf('MSIE')+9));
		this.array = new Array();
		this.names = new Array();
		this.index = 0;
		this.t='';
		this.interval=4000;
		this.loaded=false;
		this.playstr = '';
		this.stopstr = '';
		this.add = function(img, n) {
			this.array[this.array.length] = img;
			this.names[this.names.length] = n;
		}

		this.play = function(auto) {
			if(this.imgArray[this.index].complete == 1) {
				document.getElementById('loadingdiv').innerHTML='';
				if(this.IE>=5.5)
					document.getElementById('imgFrm').filters[0].Apply();
				document.getElementById('title').innerHTML = '';
				document.getElementById('img').src = this.imgArray[this.index].src;
				this.loaded = true;
				if(this.IE>=5.5)
					document.getElementById('imgFrm').filters[0].Play();
				if(auto) {
					this.t = window.setTimeout(IGObj + '.stop(true)', this.interval);
					document.getElementById('stop').innerHTML = this.stopstr;
				} else
					document.getElementById('stop').innerHTML = this.playstr;
			} else {
				document.getElementById('loadingdiv').innerHTML='';
				this.loaded=false;
				this.t = window.setTimeout(IGObj + '.play(' + auto + ')', 150);
			}
		}

		this.stop = function(inc) {
			this.t = window.clearTimeout(this.t);
			if(inc) {
				this.index = (this.index+1) % this.array.length;
				this.play(true);
			} else {
				document.getElementById('stop').innerHTML = this.playstr;
			}
		}

		this.init = function(runIndex, run) {
			if(parseInt(runIndex))
				this.index = runIndex;
			this.HTML = '<div align="center"><table><tr><td id="imgFrm" style="filter:progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=1.0)">' +
				'<img id="img" src="' + this.array[this.index] + '" class="lgalleryimage" onload="' + IGObj + '.loaded=true"></td></tr><tr><td>';
			this.HTML += '<table width="100%"><tr><td></td>' +	'<td id="stop" nowrap>';
			this.HTML += (run) ? this.stopstr:this.playstr;
			this.HTML += '</td><td></td><td width="100%" class="at" id="loadingdiv" align="center"></td><td id="title" align="right" nowrap>' +
				'</td></tr></table>';
			this.HTML += '</td></tr></table></div>';
			document.write(this.HTML);
			this.run(run);
		}

		this.run = function(run) {
			this.imgArray = new Array();
			for(var i = 0; i <this.array.length; i++) {
				this.imgArray[i] = new Image();
				this.imgArray[i].src = this.array[i];
			}
			if(run)
				this.play(run);
		}

		this.prev = function() {
			this.stop();
			if((this.index-1) <0)
				this.index = this.array.length-1;
			else
				this.index = this.index-1;
			this.play(false);
		}

		this.next = function() {
			this.stop();
			this.index = (this.index+1) % this.array.length;
			this.play(false);
		}
	}


function ImageGalleryTwo(IGObj) {

    this.IE = parseFloat(navigator.appVersion.substring(navigator.appVersion.indexOf('MSIE')+5, navigator.appVersion.indexOf('MSIE')+9));
	this.array = new Array();
	this.names = new Array();
	this.index = 0;
	this.t='';
	this.interval=7000;
	this.loaded=false;
	this.playstr = '';
	this.stopstr = '';
	this.add = function(img, n) 
	    {
			this.array[this.array.length] = img;
			this.names[this.names.length] = n;
		}

	this.play = function(auto) 
	    {
			if(this.imgArray[this.index].complete == 1) {
				document.getElementById('loadingdiv2').innerHTML='';
				if(this.IE>=5.5)
					document.getElementById('imgFrm2').filters[0].Apply();
				document.getElementById('title2').innerHTML = '';
				document.getElementById('img2').src = this.imgArray[this.index].src;
				this.loaded = true;
				if(this.IE>=5.5)
					document.getElementById('imgFrm2').filters[0].Play();
				if(auto) {
					this.t = window.setTimeout(IGObj + '.stop(true)', this.interval);
					document.getElementById('stop2').innerHTML = this.stopstr;
				} else
					document.getElementById('stop2').innerHTML = this.playstr;
			} else {
				document.getElementById('loadingdiv2').innerHTML='';
				this.loaded=false;
				this.t = window.setTimeout(IGObj + '.play(' + auto + ')', 150);
			}
		}

		this.stop = function(inc) {
			this.t = window.clearTimeout(this.t);
			if(inc) {
				this.index = (this.index+1) % this.array.length;
				this.play(true);
			} else {
				document.getElementById('stop2').innerHTML = this.playstr;
			}
		}

		this.init = function(runIndex, run) {
			if(parseInt(runIndex))
				this.index = runIndex;
			this.HTML = '<div align="center"><table><tr><td id="imgFrm2" style="filter:progid:DXImageTransform.Microsoft.Fade(duration=0.5,overlap=1.0)">' +
				'<img id="img2" src="' + this.array[this.index] + '" class="lgalleryimage2" onload="' + IGObj + '.loaded=true"></td></tr><tr><td>';
			this.HTML += '<table width="100%"><tr><td></td>' + '<td id="stop2" nowrap>';
			this.HTML += (run) ? this.stopstr:this.playstr;
			this.HTML += '</td><td></td><td width="100%" class="at" id="loadingdiv2" align="center"></td><td id="title2" align="right" nowrap></td></tr></table>';
			this.HTML += '</td></tr></table></div>';
			document.write(this.HTML);
			this.run(run);
		}

		this.run = function(run) {
			this.imgArray = new Array();
			for(var i = 0; i <this.array.length; i++) {
				this.imgArray[i] = new Image();
				this.imgArray[i].src = this.array[i];
			}
			if(run)
				this.play(run);
		}

		this.prev = function() {
			this.stop();
			if((this.index-1) <0)
				this.index = this.array.length-1;
			else
				this.index = this.index-1;
			this.play(false);
		}

		this.next = function() {
			this.stop();
			this.index = (this.index+1) % this.array.length;
			this.play(false);
		}
	}