// function for popup ---------------------------
var $popups	= new Array();

function closeAllPopups() {
	var $win	= false;
	while ($win = $popups.pop()) {
		$win.close();
	}
}

function advOpen(openUrl, openWidth, openHeight, openSwitch) {
	var srw = screen ? (screen.width-50)    : 750;
    var srh = screen ? (screen.height-36)   : 564;
    var openScroll  	= "0";
	var documentWrite	= "";
	var	openParameters	= "";
    if ((openWidth>srw) || (openHeight>srh)) {
        openScroll  = "1";
        if (openHeight>srh) { openWidth  = openWidth+16; openHeight = srh-50; }
        if (openWidth>srw)  { openHeight = openHeight+16; openWidth = srw-50; }
    }
    
    srw     = (srw - openWidth)/2;
    srh     = (srh - openHeight)/5;
    
  	var UTCstring;
  	Today = new Date();
  	UTCstring = Today.getUTCHours()+Today.getUTCMinutes()+Today.getUTCSeconds()+Today.getTime();
	
	var openName;
	openName        = "openPopup"+UTCstring;
    openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars="+openScroll+",titlebar=1,resizable=0";
    switch(openSwitch) {
        case "print":   openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars=1,titlebar=1,resizable=0,menubar=1"; break;
        case "scroll":  openParameters  = "left="+srw+",top="+srh+",outerHeight=0,innerWidth,width="+openWidth+",innerHeight,height="+openHeight+",scrollbars=1,titlebar=1,resizable=0"; break;
    }
	$popups.push(open(openUrl, openName, openParameters));
    return false;
}

function trimString($sString) {
	while ($sString.substring(0,1) == ' ') {
		$sString = $sString.substring(1, $sString.length);
	}
	while ($sString.substring($sString.length-1, $sString.length) == ' ') {
		$sString = $sString.substring(0,$sString.length-1);
	}
	return $sString;
}

function clearField($this) {
	if ($this.value == $this.title) {
		$this.value = '';
	}
}

function restoreField($this) {
	$this.value	= trimString($this.value);
	if (!$this.value) {
		$this.value = $this.title;
	}
}

function doSubmit($this) {
	if ($this.sEmail.value == $this.sEmail.title) {
		$this.sEmail.value = '';
	}
}
function init() {
	if (window.initErrors) { initErrors(); }
	if (window.initPlan) { initPlan(); }
	if (window.placeInit) { window.placeInit(); }
	if (window.initPayment) { initPayment(); }
	if (window.formError) { formError(); }
}

function printPage() {
	var pr = (window.print) ? 1 : 0;
	if (pr) // NS4, IE5
		window.print()
	else if (da && !mac) // IE4 (Windows)
		vbPrintPage()
	return false;
}
