function AHAonLoad()
{
	if(document.getElementById("TdMapPicture"))
		PreloadMapPictures();
	
	if(document.getElementById("ImgLaserPicA"))
		StartLaserRotation();
	
	if(document.getElementById("ImgMicrodermabrasionPicA"))
		StartMicrodermabrasionRotation();
	
	if(document.getElementById("ImgCellulitePicA"))
		StartCelluliteRotation();
	
	if(document.getElementById("ImgMassagePicA"))
		StartMassageRotation();
	
	if(document.getElementById("ImgEuroFacialPicA"))
		StartEuroFacialRotation();
	
	if(document.getElementById("ImgXtremeLashesPicA"))
		StartXtremeLashesRotation();
	
	if(document.FormAdminPassword)
		document.FormAdminPassword.TextLoginPassword.focus();
}

function AHAonUnload() {
	CloseAllPopups();
}

function visitorLog(page)
{
	var now = new Date;
	var cacheOverride;
	var xmlHttp = null;

	cacheOverride = escape(now.toUTCString() + " " + now.getUTCMilliseconds() + " " + Math.floor(Math.random()*100000));

	try {
		xmlHttp = new XMLHttpRequest();
	} catch(e) {
		try {
			xmlHttp = new ActiveXObject("Msxml2.xmlHttp");
		} catch (e) {
			try {
				xmlHttp = new ActiveXObject("Microsoft.xmlHttp");
			} catch (e) {
				return;	
			}
		}
	}

	try {
		xmlHttp.open("get", "AppVisitorLog.asp?Page=" + page + "&CacheOverride=" + cacheOverride, true);
		xmlHttp.send(null);
	} catch(e) {
		return;
	}
}

// Popups

function OpenLaserFAQ1() { OpenPopupPageResizable("PopupLaserFAQ1.asp", 550, 226, false); }
function OpenLaserFAQ2() { OpenPopupPageResizable("PopupLaserFAQ2.asp", 550, 226, false); }
function OpenLaserFAQ3() { OpenPopupPageResizable("PopupLaserFAQ3.asp", 550, 208, false); }
function OpenLaserFAQ4() { OpenPopupPageResizable("PopupLaserFAQ4.asp", 550, 275, false); }
function OpenLaserFAQ5() { OpenPopupPageResizable("PopupLaserFAQ5.asp", 550, 246, false); }
function OpenLaserFAQ6() { OpenPopupPageResizable("PopupLaserFAQ6.asp", 550, 171, false); }
function OpenLaserFAQ7() { OpenPopupPageResizable("PopupLaserFAQ7.asp", 550, 189, false); }
function OpenLaserFAQ8() { OpenPopupPageResizable("PopupLaserFAQ8.asp", 550, 208, false); }
function OpenLaserFAQ9() { OpenPopupPageResizable("PopupLaserFAQ9.asp", 550, 171, false); }

function OpenMicrodermabrasionFAQ1() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ1.asp", 550, 171, false); }
function OpenMicrodermabrasionFAQ2() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ2.asp", 550, 285, false); }
function OpenMicrodermabrasionFAQ3() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ3.asp", 550, 208, false); }
function OpenMicrodermabrasionFAQ4() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ4.asp", 550, 296, false); }
function OpenMicrodermabrasionFAQ5() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ5.asp", 550, 246, false); }
function OpenMicrodermabrasionFAQ6() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ6.asp", 550, 131, false); }
function OpenMicrodermabrasionFAQ7() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ7.asp", 550, 246, false); }
function OpenMicrodermabrasionFAQ8() { OpenPopupPageResizable("PopupMicrodermabrasionFAQ8.asp", 550, 208, false); }

function OpenSunFXFAQ1() { OpenPopupPageResizable("PopupSunFXFAQ1.asp", 550, 171, false); }
function OpenSunFXFAQ2() { OpenPopupPageResizable("PopupSunFXFAQ2.asp", 550, 189, false); }
function OpenSunFXFAQ3() { OpenPopupPageResizable("PopupSunFXFAQ3.asp", 550, 171, false); }
function OpenSunFXFAQ4() { OpenPopupPageResizable("PopupSunFXFAQ4.asp", 550, 208, false); }
function OpenSunFXFAQ5() { OpenPopupPageResizable("PopupSunFXFAQ5.asp", 550, 171, false); }

// Map Picture Rotation

var CurrentMapPic = "C";
function PreloadMapPictures()
{
	PicMapB     = new Image();
	PicMapB.src = "images/MapB.gif";
	PicMapC     = new Image();
	PicMapC.src = "images/MapC.gif";
}
function ShowMapB()
{
	if(CurrentMapPic != "B") {
		document.getElementById("TdMapPicture").style.backgroundImage = "url(images/MapB.gif)";
		setTimeout("document.getElementById('SpanMapCaption').innerHTML = 'Street Level'", 1000);
		CurrentMapPic = "B";
	} else {
		alert("The street level map is shown");
	}
}
function ShowMapC()
{
	if(CurrentMapPic != "C") {
		document.getElementById("TdMapPicture").style.backgroundImage = "url(images/MapC.gif)";
		setTimeout("document.getElementById('SpanMapCaption').innerHTML = 'Overview'", 1000);
		CurrentMapPic = "C";
	} else {
		alert("The overview map is shown");
	}
}

// Laser Pictures Rotation

var CurrentLaserPic = 1;
function StartLaserRotation()
{
	PreloadLaserPictures();
	setTimeout("PerformLaserRotation()", 5000);
}
function PreloadLaserPictures()
{
	PicLaser1a     = new Image();
	PicLaser1a.src = "images/LaserExample1a.jpg";
	PicLaser1b     = new Image();
	PicLaser1b.src = "images/LaserExample1b.jpg";
	PicLaser2a     = new Image();
	PicLaser2a.src = "images/LaserExample2a.jpg";
	PicLaser2b     = new Image();
	PicLaser2b.src = "images/LaserExample2b.jpg";
	PicLaser3a     = new Image();
	PicLaser3a.src = "images/LaserExample3a.jpg";
	PicLaser3b     = new Image();
	PicLaser3b.src = "images/LaserExample3b.jpg";
	PicLaser4a     = new Image();
	PicLaser4a.src = "images/LaserExample4a.jpg";
	PicLaser4b     = new Image();
	PicLaser4b.src = "images/LaserExample4b.jpg";
	PicLaser5a     = new Image();
	PicLaser5a.src = "images/LaserExample5a.jpg";
	PicLaser5b     = new Image();
	PicLaser5b.src = "images/LaserExample5b.jpg";
}
function PerformLaserRotation()
{
	var c;
	CurrentLaserPic = CurrentLaserPic + 1;
	if(CurrentLaserPic > 5)
		CurrentLaserPic = 1;
	switch(CurrentLaserPic){
		case 1:	c = "Leg: Before and after…";
			break;
		case 2:	c = "Chin: Before and after…";
			break;
		case 3:	c = "Underarm: Before and after…";
			break;
		case 4:	c = "Back: Before and after…";
			break;
		case 5:	c = "Bikini: Before and after…";
			break;
	}
	if(document.getElementById("ImgLaserPicA").filters) {
		document.getElementById("ImgLaserPicA").filters[0].apply()
		document.getElementById("ImgLaserPicB").filters[0].apply()
	}
	if(document.getElementById("ImgLaserPicA").filters)
		setTimeout("document.getElementById('TdLaserCaption').innerHTML = '" + c + "'", 300);
	else
		document.getElementById("TdLaserCaption").innerHTML = c;
	document.getElementById("ImgLaserPicA").src = "images/LaserExample" + CurrentLaserPic + "a.jpg";
	document.getElementById("ImgLaserPicB").src = "images/LaserExample" + CurrentLaserPic + "b.jpg";
	if(document.getElementById("ImgLaserPicA").filters) {
		document.getElementById("ImgLaserPicA").filters[0].play()
		document.getElementById("ImgLaserPicB").filters[0].play()
	}
	setTimeout("PerformLaserRotation()", 5000);
}

// Microdermabrasion Pictures Rotation

var CurrentMicrodermabrasionPic = 1;
function StartMicrodermabrasionRotation()
{
	PreloadMicrodermabrasionPictures();
	setTimeout("PerformMicrodermabrasionRotation()", 6000);
}
function PreloadMicrodermabrasionPictures()
{
	PicMicrodermabrasion1a     = new Image();
	PicMicrodermabrasion1a.src = "images/MicrodermabrasionExample1a.jpg";
	PicMicrodermabrasion1b     = new Image();
	PicMicrodermabrasion1b.src = "images/MicrodermabrasionExample1b.jpg";
	PicMicrodermabrasion2a     = new Image();
	PicMicrodermabrasion2a.src = "images/MicrodermabrasionExample2a.jpg";
	PicMicrodermabrasion2b     = new Image();
	PicMicrodermabrasion2b.src = "images/MicrodermabrasionExample2b.jpg";
	PicMicrodermabrasion3a     = new Image();
	PicMicrodermabrasion3a.src = "images/MicrodermabrasionExample3a.jpg";
	PicMicrodermabrasion3b     = new Image();
	PicMicrodermabrasion3b.src = "images/MicrodermabrasionExample3b.jpg";
	PicMicrodermabrasion4a     = new Image();
	PicMicrodermabrasion4a.src = "images/MicrodermabrasionExample4a.jpg";
	PicMicrodermabrasion4b     = new Image();
	PicMicrodermabrasion4b.src = "images/MicrodermabrasionExample4b.jpg";
}
function PerformMicrodermabrasionRotation()
{
	var c;
	CurrentMicrodermabrasionPic = CurrentMicrodermabrasionPic + 1;
	if(CurrentMicrodermabrasionPic > 3)
		CurrentMicrodermabrasionPic = 1;
	switch(CurrentMicrodermabrasionPic){
		case 1:	c = "Pigmentation problems<br>Before and after…";
			break;
		case 2:	c = "Fine lines and Wrinkles<br>Before and after…";
			break;
		case 3:	c = "Acne scarring<br>Before and after…";
			break;
		case 4:	c = "Minor stretch marks<br>Before and after…";
			break;
	}
	if(document.getElementById("ImgMicrodermabrasionPicA").filters) {
		document.getElementById("ImgMicrodermabrasionPicA").filters[0].apply()
		document.getElementById("ImgMicrodermabrasionPicB").filters[0].apply()
	}
	if(document.getElementById("ImgMicrodermabrasionPicA").filters)
		setTimeout("document.getElementById('TdMicrodermabrasionCaption').innerHTML = '" + c + "'", 300);
	else
		document.getElementById("TdMicrodermabrasionCaption").innerHTML = c;
	document.getElementById("ImgMicrodermabrasionPicA").src = "images/MicrodermabrasionExample" + CurrentMicrodermabrasionPic + "a.jpg";
	document.getElementById("ImgMicrodermabrasionPicB").src = "images/MicrodermabrasionExample" + CurrentMicrodermabrasionPic + "b.jpg";
	if(document.getElementById("ImgMicrodermabrasionPicA").filters) {
		document.getElementById("ImgMicrodermabrasionPicA").filters[0].play()
		document.getElementById("ImgMicrodermabrasionPicB").filters[0].play()
	}
	setTimeout("PerformMicrodermabrasionRotation()", 6000);
}

// Cellulite Pictures Rotation

var CurrentCellulitePic = 1;
function StartCelluliteRotation()
{
	PreloadCellulitePictures();
	setTimeout("PerformCelluliteRotation()", 5000);
}
function PreloadCellulitePictures()
{
	PicCellulite1a     = new Image();
	PicCellulite1a.src = "images/CellulitePicture1a.jpg";
	PicCellulite2a     = new Image();
	PicCellulite2a.src = "images/CellulitePicture2a.jpg";
}
function PerformCelluliteRotation()
{
	var c;
	CurrentCellulitePic = CurrentCellulitePic + 1;
	if(CurrentCellulitePic > 2)
		CurrentCellulitePic = 1;
	if(document.getElementById("ImgCellulitePicA").filters) {
		document.getElementById("ImgCellulitePicA").filters[0].apply()
	}
	document.getElementById("ImgCellulitePicA").src = "images/CellulitePicture" + CurrentCellulitePic + "a.jpg";
	if(document.getElementById("ImgCellulitePicA").filters) {
		document.getElementById("ImgCellulitePicA").filters[0].play()
	}
	setTimeout("PerformCelluliteRotation()", 5000);
}

// Massage Pictures Rotation

var CurrentMassagePic = 1;
function StartMassageRotation()
{
	PreloadMassagePictures();
	setTimeout("PerformMassageRotation()", 5000);
}
function PreloadMassagePictures()
{
	PicMassage1a     = new Image();
	PicMassage1a.src = "images/MassagePicture1a.jpg";
	PicMassage2a     = new Image();
	PicMassage2a.src = "images/MassagePicture2a.jpg";
	PicMassage3a     = new Image();
	PicMassage3a.src = "images/MassagePicture3a.jpg";
	PicMassage4a     = new Image();
	PicMassage4a.src = "images/MassagePicture4a.jpg";
}
function PerformMassageRotation()
{
	var c;
	CurrentMassagePic = CurrentMassagePic + 1;
	if(CurrentMassagePic > 4)
		CurrentMassagePic = 1;
	if(document.getElementById("ImgMassagePicA").filters) {
		document.getElementById("ImgMassagePicA").filters[0].apply()
	}
	document.getElementById("ImgMassagePicA").src = "images/MassagePicture" + CurrentMassagePic + "a.jpg";
	if(document.getElementById("ImgMassagePicA").filters) {
		document.getElementById("ImgMassagePicA").filters[0].play()
	}
	setTimeout("PerformMassageRotation()", 5000);
}

// EuroFacial Pictures Rotation

var CurrentEuroFacialPic = 1;
function StartEuroFacialRotation()
{
	PreloadEuroFacialPictures();
	setTimeout("PerformEuroFacialRotation()", 5000);
}
function PreloadEuroFacialPictures()
{
	PicEuroFacial1a     = new Image();
	PicEuroFacial1a.src = "images/EuroFacialPicture1a.jpg";
	PicEuroFacial2a     = new Image();
	PicEuroFacial2a.src = "images/EuroFacialPicture2a.jpg";
}
function PerformEuroFacialRotation()
{
	var c;
	CurrentEuroFacialPic = CurrentEuroFacialPic + 1;
	if(CurrentEuroFacialPic > 2)
		CurrentEuroFacialPic = 1;
	if(document.getElementById("ImgEuroFacialPicA").filters) {
		document.getElementById("ImgEuroFacialPicA").filters[0].apply()
	}
	document.getElementById("ImgEuroFacialPicA").src = "images/EuroFacialPicture" + CurrentEuroFacialPic + "a.jpg";
	if(document.getElementById("ImgEuroFacialPicA").filters) {
		document.getElementById("ImgEuroFacialPicA").filters[0].play()
	}
	setTimeout("PerformEuroFacialRotation()", 5000);
}

// XtremeLashes Pictures Rotation

var CurrentXtremeLashesPic = 1;
function StartXtremeLashesRotation()
{
	PreloadXtremeLashesPictures();
	setTimeout("PerformXtremeLashesRotation()", 5000);
}
function PreloadXtremeLashesPictures()
{
	PicXtremeLashes1a     = new Image();
	PicXtremeLashes1a.src = "images/XtremeLashesExample1a.jpg";
	PicXtremeLashes1b     = new Image();
	PicXtremeLashes1b.src = "images/XtremeLashesExample1b.jpg";
	PicXtremeLashes2a     = new Image();
	PicXtremeLashes2a.src = "images/XtremeLashesExample2a.jpg";
	PicXtremeLashes2b     = new Image();
	PicXtremeLashes2b.src = "images/XtremeLashesExample2b.jpg";
	PicXtremeLashes3a     = new Image();
	PicXtremeLashes3a.src = "images/XtremeLashesExample3a.jpg";
	PicXtremeLashes3b     = new Image();
	PicXtremeLashes3b.src = "images/XtremeLashesExample3b.jpg";
	PicXtremeLashes4a     = new Image();
	PicXtremeLashes4a.src = "images/XtremeLashesExample4a.jpg";
	PicXtremeLashes4b     = new Image();
	PicXtremeLashes4b.src = "images/XtremeLashesExample4b.jpg";
	PicXtremeLashes5a     = new Image();
	PicXtremeLashes5a.src = "images/XtremeLashesExample5a.jpg";
	PicXtremeLashes5b     = new Image();
	PicXtremeLashes5b.src = "images/XtremeLashesExample5b.jpg";
	PicXtremeLashes6a     = new Image();
	PicXtremeLashes6a.src = "images/XtremeLashesExample6a.jpg";
	PicXtremeLashes6b     = new Image();
	PicXtremeLashes6b.src = "images/XtremeLashesExample6b.jpg";
	PicXtremeLashes7a     = new Image();
	PicXtremeLashes7a.src = "images/XtremeLashesExample7a.jpg";
	PicXtremeLashes7b     = new Image();
	PicXtremeLashes7b.src = "images/XtremeLashesExample7b.jpg";
	PicXtremeLashes8a     = new Image();
	PicXtremeLashes8a.src = "images/XtremeLashesExample8a.jpg";
	PicXtremeLashes8b     = new Image();
	PicXtremeLashes8b.src = "images/XtremeLashesExample8b.jpg";
}
function PerformXtremeLashesRotation()
{
	var c;
	CurrentXtremeLashesPic = CurrentXtremeLashesPic + 1;
	if(CurrentXtremeLashesPic > 8)
		CurrentXtremeLashesPic = 1;
	if(document.getElementById("ImgXtremeLashesPicA").filters) {
		document.getElementById("ImgXtremeLashesPicA").filters[0].apply()
		document.getElementById("ImgXtremeLashesPicB").filters[0].apply()
	}
	document.getElementById("ImgXtremeLashesPicA").src = "images/XtremeLashesExample" + CurrentXtremeLashesPic + "a.jpg";
	document.getElementById("ImgXtremeLashesPicB").src = "images/XtremeLashesExample" + CurrentXtremeLashesPic + "b.jpg";
	if(document.getElementById("ImgXtremeLashesPicA").filters) {
		document.getElementById("ImgXtremeLashesPicA").filters[0].play()
		document.getElementById("ImgXtremeLashesPicB").filters[0].play()
	}
	setTimeout("PerformXtremeLashesRotation()", 5000);
}

// Admin Page

function AdminPasswordValidate()
{
	if(TrimString(document.FormAdminPassword.TextLoginPassword.value) == "") {
		alert("Please enter the admin password!");
		document.FormAdminPassword.TextLoginPassword.focus();
		return false;
	}
	return true;
}

// Email Blast Mode Change (Text or HTML)

function EmailBlastTextHTML()
{
	if(document.FormEmailBlast.OptionEmailBlastFormat.value == "Text") {
		document.getElementById("TdEmailText").style.display = "inline";
		document.getElementById("TdEmailHTML").style.display = "none";
	} else {
		document.getElementById("TdEmailText").style.display = "none";
		document.getElementById("TdEmailHTML").style.display = "inline";
	}
}

// Email Blast validate and submit

function EmailBlastSubmitForm()
{
	var oFCKeditor = FCKeditorAPI.GetInstance('TextEmailBlastMessageHTML');
	
	if(TrimString(document.FormEmailBlast.TextEmailBlastFromName.value) == "") {
		alert("Please complete the field 'From (Name)'!");
		return;
	}	
	if(TrimString(document.FormEmailBlast.TextEmailBlastFromEmail.value) == "") {
		alert("Please complete the field 'From (Email Address)'!");
		return;
	}	
	if(TrimString(document.FormEmailBlast.TextEmailBlastTo.value) == "") {
		alert("Please complete the field 'To'!");
		return;
	}	
	if(TrimString(document.FormEmailBlast.TextEmailBlastSubject.value) == "") {
		alert("Please complete the field 'Subject'!");
		return;
	}	
	if(document.FormEmailBlast.OptionEmailBlastFormat.value == "Text") {
		if(TrimString(document.FormEmailBlast.TextEmailBlastMessageText.value) == "") {
			alert("Please complete the field 'Message'!");
			return;
		}	
	} else {
		if(TrimString(oFCKeditor.GetXHTML()) == "") {
			alert("Please complete the field 'Message'!");
			return;
		}
	}
	if(TrimString(document.FormEmailBlast.TextEmailBlastReplyTo.value) == "") {
		alert("Please complete the field 'Reply To)'!");
		return;
	}	
	document.FormEmailBlast.submit();
}

// ---------------------------------------------------------------------------------

// String Library

function TrimString(x)
{
	while(x.slice(0, 1) == " " || x.slice(0, 1) == String.fromCharCode(13) || x.slice(0, 1) == String.fromCharCode(10))
		x = x.slice(1, x.length);
	while(x.slice(x.length - 1, x.length) == " " || x.slice(x.length - 1, x.length) == String.fromCharCode(13) || x.slice(x.length - 1, x.length) == String.fromCharCode(10))
		x = x.slice(0, x.length - 1);
	return x;
}

// Email Library

function CheckEmailSyntax(a)
{
	var i
	var j
	var p
	var x
	for(i = 0; i < a.length; i++)
		if(a.slice(i, i + 1) < "a" || a.slice(i, i + 1) > "z")
			if(a.slice(i, i + 1) < "A" || a.slice(i, i + 1) > "Z")
				if(a.slice(i, i + 1) < "0" || a.slice(i, i + 1) > "9")
					if(a.slice(i, i + 1) != "_")
						if(a.slice(i, i + 1) != "-")
							if(a.slice(i, i + 1) != ".")
								if(a.slice(i, i + 1) != "@")
									return false
	if(a.indexOf("@") < 0)
		return false
	if(a.indexOf("@") != a.lastIndexOf("@"))
		return false
	for(i = 0; i <= 1; i++) {
		if(i == 0) {
			x = a.slice(0, a.indexOf("@"))
			if(x.length < 2)
				return false
		} else {
			x = a.slice(a.indexOf("@") + 1, a.length)
			if(x.length < 5)
				return false
			if(x.indexOf(".") < 0)
				return false
			if(x.lastIndexOf(".") > x.length - 3)
				return false
			if(x.lastIndexOf(".") < x.length - 4)
				return false
			for(j = x.lastIndexOf(".") + 1; j < x.length; j++)
				if(x.slice(j, j + 1) < "a" || x.slice(j, j + 1) > "z")
					if(x.slice(j, j + 1) < "A" || x.slice(j, j + 1) > "Z")
						return false
		}
		if(x.slice(0, 1) == ".")
			return false
		if(x.slice(x.length - 1, x.length) == ".")
			return false
		p = -1
		while((p = x.indexOf(".", p + 1)) >= 0) {
			if(x.slice(p - 1, p) < "a" || x.slice(p - 1, p) > "z")
				if(x.slice(p - 1, p) < "A" || x.slice(p - 1, p) > "Z")
					if(x.slice(p - 1, p) < "0" || x.slice(p - 1, p) > "9")
						return false
			if(x.slice(p + 1, p + 2) < "a" || x.slice(p + 1, p + 2) > "z")
				if(x.slice(p + 1, p + 2) < "A" || x.slice(p + 1, p + 2) > "Z")
					if(x.slice(p + 1, p + 2) < "0" || x.slice(p + 1, p + 2) > "9")
						return false
		}
	}
	if(a.toUpperCase().indexOf("FUCK") >= 0)
		return false
	return true
}

// Popup Library

var WindowPointers = new Array(64)
var WindowPointersCount = 0
function OpenPopupPageSimple(PageURL, WindowWidth, WindowHeight, ShowScrollbars)
{
	CloseAllPopups()
	OpenPopupGeneric("P", PageURL, WindowWidth, WindowHeight, ShowScrollbars, false, false)
}
function OpenPopupPageResizable(PageURL, WindowWidth, WindowHeight, ShowScrollbars)
{
	CloseAllPopups()
	OpenPopupGeneric("P", PageURL, WindowWidth, WindowHeight, ShowScrollbars, true, false)
}
function OpenPopupGeneric(Mode, URLorHTML, WindowWidth, WindowHeight, ShowScrollbars, Resizable, BottomStatusBar)
{
	var i
	var OperaFlag, SupportBodyClientSizeFlag
	var HorizontalSafeSpace, VerticalSafeSpace
	var VerticalScrollBarWidth, HorizontalScrollBarHeight
	var ScreenWidth, ScreenHeight
	var HorizontalScrollBarNeeded, VerticalScrollBarNeeded
	var WindowWidth0, WindowHeight0
	var WindowWidth1, WindowHeight1
	var TotalWidth, TotalHeight
	var WindowTop, WindowLeft
	var WindowURL, WindowScrollbars, WindowResizable
	var WindowPointer
	if(BottomStatusBar == true || BottomStatusBar == "yes" || BottomStatusBar == "Yes" || BottomStatusBar == "YES")
		Resizable = true
	if(navigator.userAgent.indexOf("Opera") > 0)
		OperaFlag = true
	else
		OperaFlag = false
	SupportBodyClientSizeFlag = false
	if(document.body)
		if(document.body.clientWidth)
			if(document.body.clientHeight)
				SupportBodyClientSizeFlag = true
	HorizontalSafeSpace = 30
	VerticalSafeSpace = 60
	if(BottomStatusBar == true || BottomStatusBar == "yes" || BottomStatusBar == "Yes" || BottomStatusBar == "YES")
		VerticalSafeSpace = VerticalSafeSpace + 30
	VerticalScrollBarWidth = 16
	HorizontalScrollBarHeight = 16
	WindowWidth0 = WindowWidth
	WindowHeight0 = WindowHeight
	WindowWidth1 = WindowWidth
	WindowHeight1 = WindowHeight
	if(OperaFlag == true) {
		ScreenWidth = self.innerWidth
		ScreenHeight = self.innerHeight
	} else {
		ScreenWidth = screen.availWidth
		ScreenHeight = screen.availHeight
	}
	ScreenWidth -= HorizontalSafeSpace * 2
	ScreenHeight -= VerticalSafeSpace * 2
	HorizontalScrollBarNeeded = false
	VerticalScrollBarNeeded = false
	if(WindowWidth1 > ScreenWidth) {
		HorizontalScrollBarNeeded = true
		WindowWidth0 = ScreenWidth
		WindowWidth1 = ScreenWidth
		WindowHeight1 += HorizontalScrollBarHeight
	}
	if(WindowHeight1 > ScreenHeight) {
		VerticalScrollBarNeeded = true
		WindowHeight0 = ScreenHeight
		WindowHeight1 = ScreenHeight
		WindowWidth1 += VerticalScrollBarWidth
		if(HorizontalScrollBarNeeded == true)
			WindowHeight1 += HorizontalScrollBarHeight
	}
	if(navigator.appName == "Microsoft Internet Explorer")
		if(HorizontalScrollBarNeeded == true && VerticalScrollBarNeeded == false)
			WindowWidth1 += VerticalScrollBarWidth
	if(ShowScrollbars == true || ShowScrollbars == "yes" || ShowScrollbars == "Yes" || ShowScrollbars == "YES")
		if(VerticalScrollBarNeeded == false) {
			VerticalScrollBarNeeded = true
			WindowWidth1 += VerticalScrollBarWidth
		}
	TotalWidth = WindowWidth1
	TotalHeight = WindowHeight1
	if(navigator.appName == "Microsoft Internet Explorer") {
		if(Resizable == false || Resizable == "no" || Resizable == "No" || Resizable == "NO") {
			TotalWidth += 10
			TotalHeight += 29
		} else {
			TotalWidth += 12
			TotalHeight += 31
		}
	} else {
		if(Resizable == false || Resizable == "no" || Resizable == "No" || Resizable == "NO") {
			TotalWidth += 6
			TotalHeight += 27
		} else {
			TotalWidth += 8
			TotalHeight += 29
		}
	}
	if(OperaFlag == true) {
		WindowTop = (self.innerHeight - TotalHeight) / 2
		WindowLeft = (self.innerWidth - TotalWidth) / 2
	} else {
		WindowTop = (screen.availHeight - TotalHeight) / 2
		WindowLeft = (screen.availWidth - TotalWidth) / 2
	}
	if(Mode == "P")
		WindowURL = URLorHTML
	else
		WindowURL = ""
	if(HorizontalScrollBarNeeded || VerticalScrollBarNeeded)
		WindowScrollbars = "yes"
	else
		WindowScrollbars = "no"
	if(Resizable == true || Resizable == "yes" || Resizable == "Yes" || Resizable == "YES")
		WindowResizable = "yes"
	else
		WindowResizable = "no"
	if(BottomStatusBar == true || BottomStatusBar == "yes" || BottomStatusBar == "Yes" || BottomStatusBar == "YES")
		BottomStatusBar = "yes"
	else
		BottomStatusBar = "no"
	WindowPointer = window.open(WindowURL, "_blank", "width=" + WindowWidth1 + ",height=" + WindowHeight1 + ",resizable=" + WindowResizable + ",status=" + BottomStatusBar + ",scrollbars=" + WindowScrollbars + ",top=" + WindowTop + ",left=" + WindowLeft)
	if(Mode == "H") {
		WindowPointer.document.open()
		WindowPointer.document.write(URLorHTML)
		WindowPointer.document.close()
	}
	if(Mode == "H" && SupportBodyClientSizeFlag == true) {
		if((HorizontalScrollBarNeeded == false) && (VerticalScrollBarNeeded == true))
			if(WindowPointer.document.body.clientWidth != WindowWidth0)
				WindowPointer.resizeBy(WindowWidth0 - WindowPointer.document.body.clientWidth, 0)
		if((HorizontalScrollBarNeeded == true) && (VerticalScrollBarNeeded == false)) {
			if(WindowPointer.document.body.clientHeight != WindowHeight0)
				WindowPointer.resizeBy(0, WindowHeight0 - WindowPointer.document.body.clientHeight)
			if(WindowPointer.document.body.clientWidth != WindowWidth0)
				WindowPointer.resizeBy(WindowWidth0 - WindowPointer.document.body.clientWidth, 0)
		}
		if((HorizontalScrollBarNeeded == true) && (VerticalScrollBarNeeded == true))
			if((WindowPointer.document.body.clientWidth != WindowWidth0) || (WindowPointer.document.body.clientHeight != WindowHeight0))
				WindowPointer.resizeBy(WindowWidth0 - WindowPointer.document.body.clientWidth, WindowHeight0 - WindowPointer.document.body.clientHeight)
	}
	if(WindowPointersCount < WindowPointers.length) {
		WindowPointers[WindowPointersCount] = WindowPointer
		WindowPointersCount = WindowPointersCount + 1
	}
	return WindowPointer
}
function CloseAllPopups()
{
	var i
	for(i = 0; i < WindowPointersCount; i++)
		if(!WindowPointers[i].closed)
			WindowPointers[i].close()
	WindowPointersCount = 0
}

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

// This function is used to retrive the html of a page using the Ajax technology.
// It will return the html inside the body tag.
// Additionally, if the startTag and endTag are specified, will return the html inside those tags.
// The pageURL argument is mandatory. The startTag and endTag are optional - use them if needed, otherwise don't supply them.

function ajax(pageURL, startTag, endTag)
{
	var now = new Date;
	var randomNumber;
	var cacheOverride;
	var html = null;
	var xmlHttp = null;
	var p;

	randomNumber = escape(now.toUTCString() + " " + now.getUTCMilliseconds() + " " + Math.floor(Math.random()*100000));

	if(pageURL.indexOf("?") == -1)
		cacheOverride = "?CacheOverride=" + randomNumber;
	else
		cacheOverride = "&CacheOverride=" + randomNumber;

	try {
		xmlHttp = new XMLHttpRequest();
	} catch (e) {
		try {
			xmlHttp=new ActiveXObject("Msxml2.xmlHttp");
		} catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.xmlHttp");
		}
	}

	xmlHttp.open("get", pageURL + cacheOverride, false);
	xmlHttp.send(null);
	
	if(xmlHttp.readyState == 4) {
		try {
			if(xmlHttp.status == 200) {
				html = xmlHttp.responseText;
			}
		} catch (e) {
			html = null;
		}
	} else {
		html = null;
	}
	
	if(html == "")
		html = null;
		
	if(!html)
		return null;

	if((p = html.toUpperCase().indexOf("<BODY")) > -1)
		if((p = html.indexOf(">")) > -1)
			html = html.slice(p + 1);
	
	if((p = html.toUpperCase().indexOf("</BODY>")) > -1)
		html = html.slice(0, p);

	if(startTag)
		if((p = html.toUpperCase().indexOf(startTag.toUpperCase())) > -1)
			html = html.slice(p + startTag.length);

	if(endTag)
		if((p = html.toUpperCase().indexOf(endTag.toUpperCase())) > -1)
			html = html.slice(0, p);

	return html;
}

// ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
