/* UPDATES
09.02.02	acf	created
11.03.02	acf	added comments field to friend form
12.02.02	acf	added certEnlarge function
01.05.03	acf	added goHowTo function
01.12.03	acf	added checkEmail function
01.20.03	acf	finalized the size of the how to buy popup window
01.20.03	acf	added winVS
01.21.03	acf	changed preloadImages to include images for the how to and vs popups
					acf	added goIntro
					acf	added preloadFlag check before displaying the HowTo and Vs windows
01.28.03	acf	added setCartTimeout and timeoutRedirect for timeing out a shopping cart
02.19.03	acf	added checkPrivateMineForm function
02.22.03	acf	update rollover images
					acf	added code to check bid is higher than reserve bid
					acf added checkMemberSignup function
					acf	added checkAskAGemologist function
					acf	added checkPAsswordChange function
					acf	updated the email this page routine to not email secure pages (ie member and gold leaf pages)
					acf	changed setCartTimeout to redirect to cart.asp?act=empty to empty cart
02.24.03	acf	added confirmLogout function
					acf added winCertExp and certExplained function
02.26.03	acf	added escape command to the sendEmail routine
					acf	fixed issue with historybystock number check incorrect field name
					acf	adjusted checkEmail routine to include the possibility of a period in the first part
*/
<!--

var curX, curY;
var preloadFlag = false;

if (document.layers)
	document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = Move;

preloadImages();

function goIntro () {
	window.moveTo(0,0);
	if (navigator.appName == "Netscape") {
		window.resizeTo((screen.availWidth - (window.outerWidth - window.innerWidth)), (screen.availHeight - (window.outerHeight - window.innerHeight)));
	} else {
		window.resizeTo(screen.availWidth,screen.availHeight);
	}
}

function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;
		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
		}
	}
}

function preloadImages() {
	if (document.images) {
		home_over = newImage("images/rollgemstones.jpg");
		collectorsgallery_over = newImage("images/rollcollectorsgallery.jpg");
		companyprofile_over = newImage("images/rolltimeline.jpg");
		jewelry_over = newImage("images/rolljewelry.jpg");
		//privatemines_over = newImage("images/rollprivatemines.jpg");
		agents_over = newImage("images/rollagents.jpg");
		customerservice_over = newImage("images/rollcustomerservice.jpg");
		rollmembers_over = newImage("images/rollmembers.jpg");
		goldleafclub_over = newImage("images/rollgoldleafclub.jpg");
		history_over = newImage("images/rollhistory.jpg");
		preloadFlag = true;
	}
}

var mouseX, mouseY;
function Move(e) {
	mouseX=(e||event).clientX;
	mouseY=(e||event).clientY;
	
	if (document.body.scrollTop > 0) {
		mouseY = mouseY + document.body.scrollTop;
	}
}

function goGemstoneType (formObj) {
	if (formObj.options[formObj.selectedIndex].value != 0) {
		var url = formObj.options[formObj.selectedIndex].value + '.asp'
		document.location = url;
	}
}

function goJewelryType (formObj) {
	if (formObj.options[formObj.selectedIndex].value != 0) {
		var url = formObj.options[formObj.selectedIndex].value + '.aspx'
		document.location = url;
	}
}

var winFriend = null;
function emailFriend () {
	var windowWidth = 400;
	var windowHeight = 500;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	var page = location.pathname.replace(/\/lapigems\//, '')
	page = page.replace(/\//, '')
	var showWinFriend = true;

	var securePages = new Array('membersindex.asp','goldleafclubindex.asp','cart.asp','auction.asp','auctionbid.asp','passwordchangeform.asp','goldleafclubaccounthistory.asp','goldleafclubprivatemines.asp','privatemine.asp','orderdetails.asp','goldleafclubdetails.asp','goldleafclubsafari.asp','goldleafclubshippingpackage.asp','membersaccounthistory.asp','membersdetails.asp','membersprivatemines.asp','memberssafari.asp','membersshippingpackage.asp')
	for (var i=0; i < securePages.length; i++) {
		if (page == securePages[i] || (page.indexOf('agent')!=-1)) {
			if (!confirm ('We are sorry, but this page cannot be sent because it is specific to your account\n\nClick \'OK\' to email our homepage.')) {
				showWinFriend = false;
			} else
				referrer = 'http://www.lapigems.com/';
			break;
		}
	}
	
	if (showWinFriend) {
		if ((winFriend != null) && !winFriend.closed) {
			winFriend.close();
		};
		
		winFriend = open('winfriend.asp?referrer=' + referrer, 'winFriend', windowFeatures);
		winFriend.focus();
	}
}

function sendFriendEmail () {
	var sendername = winFriend.emailfriend.sendername.value;
	var senderemail = winFriend.emailfriend.senderemail.value;
	var friendname = winFriend.emailfriend.friendname.value;
	var friendemail = winFriend.emailfriend.friendemail.value;
	var link = winFriend.emailfriend.link.value;
	var message = winFriend.emailfriend.message.value;

	winFriend.close();
	document.location.href = 'emailfriend.asp?sendername='+escape(sendername)+'&senderemail='+escape(senderemail)+'&friendname='+escape(friendname)+'&friendemail='+escape(friendemail)+'&link='+escape(link)+'&message='+escape(message);
}


var winCert = null;
function certEnlarge (certImage) {
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winCert != null) && !winCert.closed) {
		winCert.close();
	};
	
	winCert = open('wincertificate.asp?certImage=' + certImage, 'winCert', windowFeatures);
	winCert.focus();
}

var winCurrencies = null;
function goCurrencies() {
	var windowWidth = 435;
	var windowHeight = 132;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winCurrencies != null) && !winCurrencies.closed) {
		winCurrencies.close();
	};
	
	winCurrencies = open('winCurrencies.htm', 'winCurrencies', windowFeatures);
	winCurrencies.focus();
}

var winGuarantee = null;
function goGuarantee() {
	var windowWidth = 370;
	var windowHeight = 290;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winGuarantee != null) && !winGuarantee.closed) {
		winGuarantee.close();
	};
	
	winGuarantee = open('winGuarantee.htm', 'winGuarantee', windowFeatures);
	winGuarantee.focus();
}

function certView (gemID, showNew) {
	var fileName;
	var windowWidth;
	var windowHeight;

	if (showNew) {
		windowWidth = 475;
		windowHeight = 665;
		fileName = "wincertificate_new.asp"
	}
	else {
		windowWidth = 427;
		windowHeight = 485;
		fileName = "wincertificate.asp"
	}
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winCert != null) && !winCert.closed) {
		winCert.close();
	};
	
	if (showNew) {
		winCert = open(fileName + '?id=' + gemID, 'winCert', windowFeatures);
	}
	else {
		winCert = open(fileName + '?id=' + gemID, 'winCert', windowFeatures);
	}
	
	winCert.focus();
}

var winCert = null;
function certJewelryView (JewelryID) {
	var windowWidth;
	var windowHeight;
	
	windowWidth = 525;
	windowHeight = 750;

	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winCert != null) && !winCert.closed) {
		winCert.close();
	};
	winCert = open('jewelry-certification.aspx?id=' + JewelryID, 'winCert', windowFeatures);

	winCert.focus();
}

var winAppr = null;
function apprView (gemID) 
{
	var fileName;
	var windowWidth;
	var windowHeight;
	
	windowWidth = 720;
	windowHeight = 900;
	fileName = "winappraisal.asp"
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable,scrollbars'
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winAppr != null) && !winAppr.closed) {
		winAppr.close();
	};
	winAppr = open(fileName + '?id=' + gemID, 'winAppr', windowFeatures);
		
	winAppr.focus();
}

var windAppr = null;
function jewelapprView (JewelryID) 
{
	var windowWidth;
	var windowHeight;
	
	windowWidth = 720;
	windowHeight = 900;
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable,scrollbars'
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((windAppr != null) && !windAppr.closed) {
		windAppr.close();
	};
	windAppr = open('jewelry-appraisal-report.aspx?id=' + JewelryID, 'windAppr', windowFeatures);
		
	windAppr.focus();
}

function reSizeToImage(img) {
	width=620-(document.body.clientWidth-img.width);
	height=440-(document.body.clientHeight-img.height);
	window.resizeTo(width,height);
}

var winPortfolioImage = null;
function goPortfolioImage(imageURL) {
	var windowWidth = 500;
	var windowHeight = 500;
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable=0'
										 + ',scrollbars=1'
										 + ',top=' + locY;

	if ((winPortfolioImage != null) && !winPortfolioImage.closed) {
		winPortfolioImage.close();
	};
	winPortfolioImage = open('winportfolioenlarge.asp?img=' + imageURL, 'winPortfolioImage', windowFeatures);
		
	winPortfolioImage.focus();
}

var winQualigying = null;
function showQualifier()
{
	var fileName = "appraisal-qualifying-text.asp";
	var windowWidth = 600;
	var windowHeight =400;
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable,scrollbars'
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winQualigying != null) && !winQualigying.closed) {
		winQualigying.close();
	};
	winQualigying = open(fileName, 'winQualigying', windowFeatures);
		
	winQualigying.focus();
}

var winHist = null;
function histView (gemID) 
{
	var fileName;
	var windowWidth;
	var windowHeight;
	
	windowWidth = 850;
	windowHeight = 900;
	fileName = "winhistory.asp"
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable,scrollbars'
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((winHist != null) && !winHist.closed) {
		winHist.close();
	};
	winHist = open(fileName + '?id=' + gemID, 'winAppr', windowFeatures);
		
	winHist.focus();
}

var winHelp = null;
function goHelp (helpitem){
	var windowWidth = 100;
	var windowHeight = 100;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winHelp != null) && !winHelp.closed) {
		winHelp.close();
	};
	switch (helpitem) {
		case 'privatemine' :
			alert (helpitem)
			break;
	}
}

var winHowTo = null;
function goHowTo (name) {
	// howto 430 x 380
	var windowWidth = 563;
	var windowHeight = 418;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winHowTo != null) && !winHowTo.closed) {
		winHowTo.close();
	};

	if (!preloadFlag)
		preloadImages();

	winHowTo = open('winhowto.asp','winHowTo', windowFeatures);
	winHowTo.focus();
}

var winVS = null;
function goVS (name) {
	// vs 450 x 375
	var windowWidth = 583;
	var windowHeight = 413;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winVS != null) && !winVS.closed) {
		winVS.close();
	};

	if (!preloadFlag)
		preloadImages();

	winVS = open('winvs.asp','winVS', windowFeatures);
	winVS.focus();
}

var winEAGTerms = null;
function goEAGTerms()
{
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';
	if ((winEAGTerms != null) && !winEAGTerms.closed)
	{
		winEAGTerms.close();
	}
	
	winEAGTerms = open('/content/earnagemagreement.htm', 'winEAGTerms', windowFeatures);
	winEAGTerms.focus();
}

var winCertExp = null;
function certExplainedOld () {
	var windowWidth = 520;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable=yes'
										 + ',top=' + locY;

	if ((winCertExp != null) && !winCertExp.closed) {
		winCertExp.close();
	};
	
	winCertExp = open('/wincertificateexplained.asp', 'winCertExp', windowFeatures);
	winCertExp.focus();
}

function certExplained (showNew) {
	var fileName;
	var windowWidth;
	var windowHeight;

	if (showNew) {
		windowWidth = 775;
		windowHeight = 580;
		fileName = "wincertificateexplained_new.asp"
	}
	else {
		windowWidth = 520;
		windowHeight = 452;
		fileName = "wincertificateexplained.asp"
	}
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable=yes'
										 + ',top=' + locY;

	if ((winCertExp != null) && !winCertExp.closed) {
		winCertExp.close();
	};
	
	winCertExp = open('/' + fileName, 'winCertExp', windowFeatures);
	winCertExp.focus();
}

function jewelryCertExplained () {
	var fileName;
	var windowWidth;
	var windowHeight;

	windowWidth = 775;
	windowHeight = 580;
	fileName = "wincertificateexplained_new.asp?product=jewelry"

	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;

	if ((winCertExp != null) && !winCertExp.closed) {
		winCertExp.close();
	};
	
	winCertExp = open('/' + fileName, 'winCertExp', windowFeatures);
	winCertExp.focus();
}

var winRewards = null;
function goRewards () {
	// vs 450 x 375
	var windowWidth = 680;
	var windowHeight = 420;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winRewards != null) && !winRewards.closed) {
		winRewards.close();
	};

	if (!preloadFlag)
		preloadImages();

	winRewards = open('winrewards.asp','winRewards', windowFeatures);
	winRewards.focus();
}

var winStatement = null;
function goPrintStatement (pre) {
	// vs 450 x 375
	var windowWidth = 680;
	var windowHeight = 420;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winStatement != null) && !winStatement.closed) {
		winStatement.close();
	};

	if (!preloadFlag)
		preloadImages();

	winStatement = open('agentcommissionstatement.asp?print=y&pre='+pre,'winStatement', windowFeatures);
	winStatement.focus();
}

var winMoreInfo = null;
function goMoreInfo (anchorName) {
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winMoreInfo != null) && !winMoreInfo.closed) {
		winMoreInfo.close();
	};
	
	winMoreInfo = open('/winmoreinfo.asp#' + anchorName, 'winMoreInfo', windowFeatures);
	winMoreInfo.focus();
}

var winQualityReport = null;
function goQualityReport (anchorName) {
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winQualityReport != null) && !winQualityReport.closed) {
		winQualityReport.close();
	};
	
	winQualityReport = open('/winqualityreport.asp#' + anchorName, 'winQualityReport', windowFeatures);
	winQualityReport.focus();
}

var winPMine = null;
function goPMine (helpitem){
	var windowWidth = 500;
	var windowHeight = 400;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	if ((winPMine != null) && !winPMine.closed) {
		winPMine.close();
	};
	
	winPMine = open('winprivatemine.asp', 'winPMine', windowFeatures);
	winPMine.focus();
}

var winConference = null;
function goConference () {
	var windowWidth = 427;
	var windowHeight = 472;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;

	if ((winConference != null) && !winConference.closed) {
		winConference.close();
	};
	
	winConference = open('winconference.asp', 'winConference', windowFeatures);
	winConference.focus();
}

var winOnlineCheck = null;
function goOnlineCheck() {
	var windowWidth = 500;
	var windowHeight = 400;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width=' + windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
 										 + ',scrollbars=1';

if ((winOnlineCheck != null) && !winOnlineCheck.closed) {
		winOnlineCheck.close();
	};
	
	winOnlineCheck = open('winonlinecheck.asp', 'winOnlineCheck', windowFeatures);
	winOnlineCheck.focus();
}

var winToneChart = null;
function goToneChart (gemstoneType) {
	var windowWidth = 750;
	var windowHeight = 575;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY;
	
	if ((winToneChart != null) && !winToneChart.closed) {
		winToneChart.close();
	};
	
	winToneChart = open('/wintonechart.asp?t=' + gemstoneType, 'winToneChart', windowFeatures);
	winToneChart.focus();
}

// flash requirements
var requiredMajorVersion = 7;
var requiredMinorVersion = 0;
var requiredRevision = 0;

var winGemstoneFlash = null;
function goGemstoneFlash (flashFile, stockNumber, shape, weight) {
	var windowWidth = 360;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=0';

	if ((winGemstoneFlash != null) && !winGemstoneFlash.closed) {
		winGemstoneFlash.close();
	};
	
	winGemstoneFlash = open('wingemstoneflash.asp?f='+flashFile+'&s='+stockNumber+'&sh='+shape+'&w='+weight, 'winGemstoneFlash', windowFeatures);
	winGemstoneFlash.focus();
}

var winJewelryFlash = null;
function goJewelryFlash (flashFile, stockNumber, title) {
	var windowWidth = 370;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=0';

	if ((winJewelryFlash != null) && !winJewelryFlash.closed) {
		winJewelryFlash.close();
	};
	
	winJewelryFlash = open('winjewelryflash.asp?f='+flashFile+'&s='+stockNumber+'&t='+title, 'winJewelryFlash', windowFeatures);
	winJewelryFlash.focus();
}

var winEAGStatus = null;
function goEAGStatus() {
	var windowWidth = 360;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=0';

	if ((winEAGStatus != null) && !winEAGStatus.closed) {
		winEAGStatus.close();
	};
	
	winEAGStatus = open('wineagstatus.asp', 'winEAGStatus', windowFeatures);
	winEAGStatus.focus();
}

var winEAGWalkthrough = null;
function goEAGWalkthrough () {
	var windowWidth = 737;
	var windowHeight = 600;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable=yes'
										 + ',top=' + locY;

	if ((winEAGWalkthrough != null) && !winEAGWalkthrough.closed) {
		winEAGWalkthrough.close();
	};
	
	winEAGWalkthrough = open('/wineagwalkthrough.asp', 'winEAGWalkthrough', windowFeatures);
	winEAGWalkthrough.focus();
}

var winOwnerReport = null;
function goOwnerReport(stocknumber) {
	var windowWidth = 800;
	var windowHeight = 500;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winOwnerReport != null) && !winOwnerReport.closed) {
		winOwnerReport.close();
	};
	
	winOwnerReport = open('winownerregistration.asp?id='+stocknumber, 'winOwnerReport', windowFeatures);
	winOwnerReport.focus();
}

function checkWinConference (form) {
	var msg = '';
	var name = form.name.value;
	var email = form.email.value;
	var phone = form.telephone.value;
	var time = form.time.value;
	var message= form.message.value;
	var firstField = '';
	
	if (name == '') {
		msg = 'Invalid Name\n';
		if (firstField == '') firstField = form.name;
	}
	if (!checkEmail(email)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (phone == '') {
		msg = msg + 'Invalid Phone Number\n';
		if (firstField == '') firstField = form.phone;
	}

	if (checkMsg(msg, firstField)) {
		winConference.close();
		document.location.href = 'telephoneconference.asp?name='+escape(name)+'&email='+escape(email)+'&phone='+escape(phone)+'&time='+escape(time)+'&message='+escape(message);
	}

}

function checkHistoryByStock (form) {
	var msg = '';
	if (form.id.value == '') {	
		msg = 'Invalid Id #';
	}
	return checkMsg(msg, form.id);
}

function checkGemstoneHistoryByStock (form) {
	var msg = '';
	if (form.id.value == '') {	
		msg = 'Invalid Gemstone Id #';
	}
	return checkMsg(msg, form.id);
}

function checkJewelryHistoryByStock (form) {
	var msg = '';
	if (form.id.value == '') {	
		msg = 'Invalid Jewelry Id #';
	}
	return checkMsg(msg, form.id);
}

function checkEmail (address) {
	var msg = '';
	var emailPattern = /^\w+\.*\-?\w*\@(\w+\-?\w*\.{1}){1,3}\D{2,4}$/;
	if (address.match(emailPattern) == null)
		return false;
	else
		return true;
}

var cartTimeoutSet = false;
var sessionTimeoutSet = false;
var counter;
var handle;
var handle2;
function setCartTimeout () {
	var counter;
	if (!cartTimeoutSet) {
		counter=600;
		handle=setTimeout("timeoutRedirect('sessiontimeout.asp')",counter*1000);
		cartTimeoutSet = true;
	} else {
		counter=300;
		handle=setTimeout("timeoutRedirect('cart.asp?act=empty')",counter*1000);
	}
}
function timeoutRedirect (loc) {
	location.href=loc;
}

function checkAgree(form)
{	
	var msg = '';
	var firstField;
	if (form.agree.checked == false)
	{
		msg = 'You Musst Agree to the Terms and Conditions\n';
		firstField = form.agree;
	}
	return checkMsg(msg, firstField);
}

function checkMsg (msg, focusField) {
	if (msg == '')
		return true;
	else {
		msg = 'There Has Been An Error Processing Your Request.\nPlease Try Again!\n\n' + msg;
		alert (msg);
		focusField.focus();
		return false;
	}
}

function checkPrivateMineForm (form) {
	var msg = '';
	var firstField = '';
	var st;
	st = 'Please indicate other here';

	if (form.firstname.value == '') {
		msg = msg + 'Invalid First Name\n';
		if (firstField == '') firstField = form.firstname;
	}
	if (form.lastname.value == '') {
		msg = msg + 'Invalid Last Name\n';
		if (firstField == '') firstField = form.lastname;
	}
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.gemstonetypeid.selectedIndex == 0) {
		msg = msg + 'Invalid Gemstone Type\n';
		if (firstField == '') firstField = form.gemstonetypeid;
	}
	if (form.gemstoneweight.selectedIndex == 0) {
		msg = msg + 'Invalid Gemstone Weight\n';
		if (firstField == '') firstField = form.gemstoneweight;
	}
	if (form.gemstonecut.selectedIndex == 0) {
		msg = msg + 'Invalid Gemstone Cut\n';
		if (firstField == '') firstField = form.gemstonecut;
	} else if (form.gemstonecut.value == 'other') {
		if (form.othercut.value == st) {
			msg = msg + 'Invalid Other Cut\n';
			if (firstField == '') firstField = form.othercut;
		}
	}
	return checkMsg(msg, firstField);
}

function checkCut() {
	var st;
	st = 'Please indicate other here';
	if (document.privateminerequest.gemstonecut.value == 'other') {
		if (document.privateminerequest.othercut.value == '') {
			document.privateminerequest.othercut.value = st;
		}
	} else if (document.privateminerequest.othercut.value == st) {
		document.privateminerequest.othercut.value = '';
	}
}

function checkAuction (form) {
	var msg = '';
	if (form.bid.value == '') {
		msg = msg + 'Invalid Bid\n';
	} else {
		if (form.bid.value <= form.highbid.value) {
			msg = msg + 'Bid Must Be Higher Than Existing High Bid\n';
		} else {
			if (form.bid.value <= form.minimumbid.value) {
				msg = msg + 'Bid Musb Be Higher Than The Reserve Price\n';
			}
		}
	}
	return checkMsg(msg, form.bid);
}

function checkAuctionBid (form) {
	var msg = '';
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n'
	}
	if (! form.disclaimer.checked) {
		msg = msg + 'You have not agreed to the Bidding Contract\n';
	}
	return checkMsg(msg, form.password);
}

function checkMemberSignIn (form) {
	var msg = '';
	var firstField = '';
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n';
		if (firstField == '') firstField = form.password;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	return checkMsg(msg, firstField);
}

function checkAgentSignIn (form) {
	var msg = '';
	var firstField = '';
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n';
		if (firstField == '') firstField = form.password;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	return checkMsg(msg, firstField);
}

function checkGoldLeafSignIn (form) {
	var msg = '';
	var firstField = '';
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n';
		if (firstField == '') firstField = form.password;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	return checkMsg(msg, firstField);
}

function checkMemberSignup (form) {
	var msg = '';
	var firstField = '';
	if (form.firstname.value == '') {
		msg = msg + 'Invalid First Name\n';
		if (firstField == '') firstField = form.firstname;
	}
	if (form.lastname.value == '') {
		msg = msg + 'Invalid Last Name\n';
		if (firstField == '') firstField = form.lastname;
	}
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n';
		if (firstField == '') firstField = form.password;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	return checkMsg(msg, firstField);
}

function checkAskAGemologist (form) {
	var msg = '';
	var firstField = '';
	if (form.firstname.value == '') {
		msg = msg + 'Invalid First Name\n';
		if (firstField == '') firstField = form.firstname;
	}
	if (form.lastname.value == '') {
		msg = msg + 'Invalid Last Name\n';
		if (firstField == '') firstField = form.lastname;
	}
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.description.value == '') {
		msg = msg + 'Invalid Question\n';
		if (firstField == '') firstField = form.description;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	if (form.terms.checked == false) {
		msg = msg + 'Have you read and understood the Terms?\n';
	}
	return checkMsg(msg, firstField);
}

function checkPasswordRequest (form) {
	var msg = '';
	var firstField = '';
	if (form.email.value == '') {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.captcha.value == '') {
		msg = msg + 'Invalid Code\n';
		if (firstField == '') firstField = form.captcha;
	}
	return checkMsg(msg, firstField);
}

function checkAgentAskLapigems (form) {
	var msg = '';
	var firstField = '';
	if (form.description.value == '') {
		msg = msg + 'Invalid Question\n';
		if (firstField == '') firstField = form.description;
	}
	return checkMsg(msg, firstField);
}

function checkAgentBookAppointment (form) {
	var msg = '';
	var firstField = '';
	if (form.clientsnames.value == '') {
		msg = msg + 'Invalid Client(s) Name(s)\n';
		if (firstField == '') firstField = form.clientsnames;
	}
	if (form.pax.value == '') {
		msg = msg + 'Invalid Pax\n';
		if (firstField == '') firstField = form.pax;
	}
	if (form.datetime.value == '') {
		msg = msg + 'Invalid Date and Time\n';
		if (firstField == '') firstField = form.datetime;
	}
	if (form.place.value == '') {
		msg = msg + 'Invalid Place\n';
		if (firstField == '') firstField = form.place;
	}
	return checkMsg(msg, firstField)
}

function checkPasswordChange (form) {
	var msg = '';
	var firstField = '';
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	if (form.oldpassword.value == '') {
		msg = msg + 'Invalid Old Password\n';
		if (firstField == '') firstField = form.oldpassword;
	}
	if (form.newpassword.value == '') {
		msg = msg + 'Invalid New Password\n';
		if (firstField == '') firstField = form.newpassword;
	}
	if (form.verifypassword.value == '') {
		msg = msg + 'Invalid Verify Password\n';
		if (firstField == '') firstField = form.verifypassword;
	}
	if (form.newpassword.value != form.verifypassword.value) {
		msg = msg + 'New Passwords Do Not Match\n';
		if (firstField == '') firstField = form.newpassword
	}
	return checkMsg(msg, firstField);
}

function checkAgentUploadNewsletter (form) {
	var msg = '';
	var firstField = '';
	if (form.newsletter.value == '') {
		msg = msg + 'Invalid Newsletter\n';
		if (firstField == '') firstField = form.newsletter;
	}
	var ext = form.newsletter.value.substr((form.newsletter.value.length)-3,3).toLowerCase();
	if (ext!='doc' && ext!='pdf') {
		msg = msg + 'Invalid Filename\nPlease Select A Word Or PDF Document';
		if (firstField == '') firstField = form.newsletter;
	}
	return checkMsg(msg, firstField);
}

function checkAgentClaimMissingCommissions (form) {
	var msg = '';
	var firstField = '';
	if (form.clientsnames.value == '') {
		msg = msg + 'Invalid Client(s) Name(s)\n';
		if (firstField == '') firstField = form.clientsnames;
	}
	if (form.purchasedate.value == '') {
		msg = msg + 'Invalid Purchase Date\n';
		if (firstField == '') firstField = form.purchasedate;
	}
	return checkMsg(msg, firstField);
}

function checkAgentCashCommissions (form) {
	var msg = '';
	var firstField = '';
	var bIsChecked = false;

	for (var i = 0; i<form.checkcurrency.length; i++) {
		if (form.checkcurrency[i].checked) {
			bIsChecked = true;
			break;
		}
	}
	if (!bIsChecked)  {
		msg = msg + 'Invalid Currency\n';
		if (firstField == '') firstField = form.checkcurrency[1];
	}
	
	if (form.password.value == '') {
		msg = msg + 'Invalid Password\n';
		if (firstField == '') firstField = form.password;
	}

	return checkMsg(msg, firstField)
}

function checkMemberDetails (form) {
	var msg = '';
	var firstField = '';
	
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n'
		if (firstField == '') firstField = form.email;
	}
	if (form.address1.value == '') {
		msg = msg + 'Invalid Address\n';
		if (firstField == '') firstField = form.address1;
	}
	if (form.city.value == '') {
		msg = msg + 'Invalid City\n';
		if (firstField == '') firstField = form.city;
	}
	if (form.postalcode.value == '') {
		msg = msg + 'Invalid Postal Code\n';
		if (firstField == '') firstField = form.postalcode;
	}
	if (form.country.value == '') {
		msg = msg + 'Invalid Country\n';
		if (firstField == '') firstField = form.country;
	}
//	if (form.oldpassword.value == '') {
//		msg = msg + 'Invalud Old Password\n';
//		if (firstField == '') firstField = form.oldpassword;
//	}
//	if (form.newpassword.value == '') {
//		msg = msg + 'Invalid New Password\n';
//		if (firstField == '') firstField = form.newpassword;
//	}
//	if (form.verifypassword.value == '') {
//		msg = msg + 'Invalid Verify Password\n';
//		if (firstField == '') firstField = form.verifypassword;
//	}
//	if (form.newpassword.value != form.verifypassword.value) {
//		msg = msg + 'New Password Doesn\'t Match Verify Password\n';
//		if (firstField == '') firstField = form.newpassword;
//	}

	return checkMsg(msg, firstField)
}

function checkSpecialOffer (form) {
	var msg = '';
	var firstField = '';
	
	if (form.specialoffercode.value == '') {
		msg = msg + 'Invalid Special Offer Code\n';
		if (firstField == '') firstField = form.specialoffercode;
	}

	return checkMsg(msg, firstField)
}

function emptyCart () {
	if (confirm('Are you sure you want to empty your cart?'))
		return true;
	else
		return false;
}

function confirmLogout (orderid) {
	if (orderid != 0) {
		if (confirm('Are you sure you want to log out?\n\nYou have a cart open and it will be emptied.'))
			return true;
		else
			return false;
	} else {
		if (confirm('Are you sure you want to log out?'))
			return true;
		else
			return false;
	}
}

function goPrintScreen() 
{
	debugger;
	var agt = navigator.userAgent.toLowerCase();
	if (window.print) 
	{
		window.print();
	}
	else if (agt.indexOf("mac") != -1) 
	{
		alert("Press 'Cmd+p' on your keyboard to print.");
	}
	else 
	{
		alert("Press 'Ctrl+p' on your keyboard to print.")
	}
}

function checkOptOut (form) {
	var msg = '';
	var firstField = '';
	
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
	return checkMsg(msg, firstField);
}

function deleteWarning (name) {
	return confirm ("Are you sure you want to delete '" + unescape(name) + "'?");
}

function checkEarnAGemReferral (form) {
	var msg = '';
	var firstField = '';
	
	if (form.firstname.value == '') {
		msg = msg + 'Invalid First Name\n';
		if (firstField == '') firstField = form.firstname;
	}
	if (form.lastname.value == '') {
		msg = msg + 'Invalid Last Name\n';
		if (firstField == '') firstField = form.lastname;
	}
	if (!checkEmail(form.email.value)) {
		msg = msg + 'Invalid Email\n';
		if (firstField == '') firstField = form.email;
	}
}

function popDivOver(text, offsetX, offsetY)
{
	var myX, myY;
	var popDiv = document.getElementById('moveOverPopUp');

	myX = mouseX + offsetX;
	myY = mouseY + offsetY;

	popDiv.innerHTML = text;
	popDiv.style.top = myY + "px";
	popDiv.style.left = myX + "px";
	popDiv.style.visibility = "visible";
}

function popDivOut()
{
	document.getElementById('moveOverPopUp').style.visibility = "hidden";
}

function RefreshCaptchaImage(valImageId) {
	var objImage = document.images[valImageId];
	if (objImage == undefined) {
		return;
	}
	var now = new Date();
	objImage.src = objImage.src.split('?')[0] + '?x=' + now.toUTCString();
}

var windDesigner = null;
function aboutDesigner() {
	var windowWidth;
	var windowHeight;
	
	windowWidth = 427;
	windowHeight = 452;
	
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',resizable,scrollbars'
										 + ',top=' + locY;
	var referrer = document.location.href;
	
	if ((windDesigner != null) && !windDesigner.closed) {
		windDesigner.close();
	};
	windDesigner = open('more-about-the-designer.aspx', 'windDesigner', windowFeatures);
		
	windDesigner.focus();
}

var winTerms = null;
function goTerms() {
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winTerms != null) && !winTerms.closed) {
		winTerms.close();
	};
	
	winTerms = open('ask-a-gemologist-terms.aspx', 'winTerms', windowFeatures);
	winTerms.focus();
}

var winRingSize = null;
function goRingSizeChart() {
	var windowWidth = 427;
	var windowHeight = 452;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winRingSize != null) && !winRingSize.closed) {
		winRingSize.close();
	};
	
	winRingSize = open('ring-size-chart.aspx', 'winRingSize', windowFeatures);
	winRingSize.focus();
}

var winMap = null;
function viewMap(ID, sat, ter){
	var windowWidth = 940;
	var windowHeight = 540;
	var locX = (screen.width - windowWidth) / 2;
	var locY = (screen.height - windowHeight) / 2;
	var windowFeatures = 'width='+ windowWidth
										 + ',height=' + windowHeight
										 + ',screenX=' + locX
										 + ',screenY=' + locY
										 + ',left=' + locX
										 + ',top=' + locY
										 + ',scrollbars=1';

	if ((winMap != null) && !winMap.closed) {
		winMap.close();
	};
	
	winMap = open('view-map.aspx?id='+ID+'&sat='+sat+'&ter='+ter, 'winMap', windowFeatures);
	winMap.focus();
}
//-->
