﻿// ====================================================
//	Author:			Taher Scherzay
//	Description: 	Various javascripts
// ====================================================
var arrRollovers = new Array();
var arrRollouts = new Array();
var exitPopState = true;

// ====================================================
function RegisterPageImages() 
{
    var oImage1, oImage2;
	var strImageID = "";
	var strImageSRC = "";
	
	if (!document.images) return;
	
	for (var i=0; i < document.images.length; i++)
	{
		strImageID = "";
		
		if (document.images[i] != null) {
		
			if (document.images[i].id != null)
				if (document.images[i].id != "")
					strImageID = "" + document.images[i].id;
		
			strImageSRC = "" + document.images[i].src;
		
			if (strImageID != "" && strImageSRC.indexOf(".gif") > -1)
				RegisterRollover( strImageID, strImageSRC );
		}
	}
}

// ====================================================
function RegisterRollover(inImageID, inImageSrc)
{
	var strImageRollover = "" + inImageSrc;
	var oImage1 = new Image();
	var oImage2 = new Image();
	
	if (strImageRollover.lastIndexOf(".") > -1)
		strImageRollover = strImageRollover.substring(0, strImageRollover.lastIndexOf(".")) + "_on" + strImageRollover.substring(strImageRollover.lastIndexOf("."));
    
	oImage1.src = strImageRollover;
	oImage2.src = inImageSrc;
	
	arrRollovers[inImageID] = oImage1;
	arrRollouts[inImageID] = oImage2;
}

// ====================================================
function Rollover(inImageID)
{
	if (arrRollovers[inImageID] != null)
	{	
		if (document.images[inImageID] != null)
			document.images[inImageID].src = arrRollovers[inImageID].src;
	}
}

// ====================================================
function Rollout(inImageID)
{
	if (arrRollouts[inImageID] != null)
	{
		if (document.images[inImageID] != null)
			document.images[inImageID].src = arrRollouts[inImageID].src;
	}
}

// ====================================================
function HTMLStrip(text)
{      
    var regex = /<\S[^><]*>/g
	if (text.length > 0)
	{
	    text = text.replace(regex, "")
	}
	
	return text;
}

// ====================================================
function openWin(inURL, inName, inFeatures, inWidth, inHeight)
{
	var strURL = "";
	var strFeatures = "";
	var intWidth = 0;
	var intHeight = 0;
	var intLeft = 0;
	var intTop = 0;
	var strName = "";
	
	if (inURL == null)
		return;
	
	strURL = "" + inURL;
	if (inName != null)
		strName = "" + inName;
	
	if (inFeatures != null)
		strFeatures = "" + inFeatures;
	
	if (inWidth != null)
		if (!isNaN(parseInt(inWidth, 10)))
			intWidth = parseInt(inWidth, 10);
	
	if (inHeight != null)
		if (!isNaN(parseInt(inHeight, 10)))
			intHeight = parseInt(inHeight, 10);
	
	if (intWidth == 0)
		intWidth = 500;		// Default
		
	if (intHeight == 0)
		intHeight = 400;	// Default
	
	strFeatures = strFeatures.toLowerCase();
	
	if (strFeatures.indexOf("scrollbars") == -1)
	{
		if (strFeatures.length > 0)
			strFeatures = strFeatures + ",";
		strFeatures = strFeatures + "scrollbars=1";
	}
	
	if (strFeatures.indexOf("resizable") == -1)
	{
		if (strFeatures.length > 0)
			strFeatures = strFeatures + ",";
		strFeatures = strFeatures + "resizable=1";
	}
	
	if (window.screen != null)
	{
		intLeft = (window.screen.width / 2) - (intWidth / 2);
		intTop = (window.screen.height / 2) - (intHeight / 2);
	}
	
	strFeatures = "width=" + intWidth + ",height=" + intHeight + "," + strFeatures;
	strFeatures = strFeatures + ",left=" + intLeft + ",top=" + intTop;
	
	window.open(strURL, strName, strFeatures);
}

// ====================================================
function ExitPop(url)
{     
    if (exitPopState)
    {
        openWin(url, 'LastChance', '', '640','480')
    }
}

