function popup(mylink, windowname, title)
{
	return popup2(mylink, windowname, title, 400, 275, true);
}
function popupb(mylink, windowname, title)
{
	return popup2(mylink, windowname, title, 400, 275, false);
}
var id = 1;
var win;
function getNewId() { id++; return id; }

function popup2(mylink, windowname, wintitle, w, h, top)
{
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
win = new Window({className: "alphacube", showEffectOptions: {duration:1.5}, resizable: false, destroyOnClose: true});
win.setTitle(wintitle);
win.setURL(href);
win.setSize(w, h);
if (top) {
	win.setLocation(100, 100);
}
else {
	win.setLocation(WindowUtilities.getPageSize().pageHeight-screen.height+100+h, 100);
}
win.show();
win.setZIndex(99999);
return false;
}

function popup3(mylink, windowname, wintitle, w, h)
{
var href;
if (typeof(mylink) == 'string')
   href=mylink;
else
   href=mylink.href;
win = new Window({className: "alphacube", showEffectOptions: {duration:1.5}, resizable: false, destroyOnClose: true});
win.setTitle(wintitle);
win.setURL(href);
win.setSize(w, h);
win.showCenter();
return false;
}

function pralert(str) {
	str.replace(/\n/, '<br/>');
	w = 400;
	h = 275;
	leftPad = (WindowUtilities.getPageSize().pageWidth-w)/2;
	topPad = (screen.height-h)/2-50;
	Dialog.alert(str, {top:topPad, left:leftPad, windowParameters: {className: 'alphacube', width:400}, okLabel: 'ok'});
}

function check_form() {
	var form = document.forms[0];
	var msg = "Fill out the form below and receive immediate access.";
	
	var name = form['name'].value;
	name = name.strip();
	var phone = form['custom Phone Number'].value;
	phone = phone.strip();
	var email = form['from'].value;
	email = email.strip();
	window.location = "#form";
	if (name == "" || phone == "" ||  email == "") {
//		window.location = "#form";
		//alert(msg);
		w = 400;
		h = 275;
		leftPad = (screen.width-w)/2;
		topPad = (screen.height-h)/2-50;
		pralert(msg);
		return false;
	}
	phone = phone.gsub("[^0-9]","");
	if (phone.length < 10) {
		//alert(msg);
		w = 400;
		h = 275;
		leftPad = (screen.width-w)/2;
		topPad = (screen.height-h)/2-50;
		pralert("Please fill-in a valid phone number.");
		return false;
	}
}
var timeout;
function prinfo(str, delay) {
	str.replace(/\n/, '<br/>');
	w = 400;
	h = 275;
	leftPad = (WindowUtilities.getPageSize().pageWidth-w)/2;
	topPad = (screen.height-h)/2-50;
	Dialog.info(str, {top:topPad, left:leftPad, windowParameters: {className: 'alphacube', width:400}, okLabel: 'ok'});
	
	timeout = delay;
	
	setTimeout(infoTO, 1000);
}

function infoTO() {
	timeout--;
	if (timeout > 0) {
		setTimeout(infoTO, 1000);
	}
	else {
		Dialog.closeInfo();
	}
}
