// Aquacide Common script

// Global variables
var thumbWidth = 100;
var thumbHeight = 100;
var imageArray = new Array();

// Get browser info
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
var isFirefox = navigator.userAgent.indexOf("Firefox") != -1;
var isChrome = navigator.userAgent.indexOf("Chrome") != -1;
var isSafari = (navigator.userAgent.indexOf("Safari") != -1) && (isFirefox == false) && (isChrome == false);

function OpenSubWin(theFile, theWidth, theHeight) {
	//var theTop = 0;
	var theTop = (screen.height/2) - (theHeight/2);
	var theLeft = (screen.width/2) - (theWidth/2);
	var winFeatures = "top="+theTop+",left="+theLeft+",width="+theWidth+",height="+theHeight+",scrollbars=yes,resizable=yes";
	var newWin = window.open(theFile, "", winFeatures);
	if (newWin!=null) {
		newWin.focus();
		window.childWin = newWin;
	} else {
		alert("Failed to open new window. Please turn off any pop-up blockers you may have.");
	}

	return newWin;
}

function ShowSampleSecurityCode(theFile) {
	//240x151
	if (isInternetExplorer == true) {
		var newWin = OpenSubWin(theFile, 258, 158);
	} else {
		var newWin = OpenSubWin(theFile, 258, 158);
	}
	return newWin;
}

function CloseChildWindow() {
	if (window.childWin != null) {
		window.childWin.close();
	}
}

function InitImageThumbs() {
	imageArray = [];
}

function InitImage(index, imgID, imgThumbSrc, imgNormalSrc) {
	// Save image info
	imageArray[index] = new Array();
	imageArray[index][0] = imgID;
	imageArray[index][1] = imgThumbSrc;
	imageArray[index][2] = imgNormalSrc;
}

function HandleImageRollOver(index) {
	// Resize image to original size
	try {
		if (index < imageArray.length) {
			var imgID = imageArray[index][0];
			var imgSrc = imageArray[index][2];
			var target = document.getElementById(imgID);
			if (target) {
				var left = target.offsetLeft;
				var top = target.offsetTop;
				//target.src = imgSrc;
			}
		}
	}
	catch(e) {
	}
}

function HandleImageRollOff(index) {
	// Resize image to thumbnail size
	try {
		var imgID = imageArray[index][0];
		var imgSrc = imageArray[index][1];
		var target = document.getElementById(imgID);
		if (target) {
			//target.src = imgSrc;
		}
	}
	catch(e) {
	}
}


