// -----------------------------------------------------------------------
// This file is part of AROUNDMe
// 
// Copyright (C) 2003, 2006 Barnraiser
// http://www.barnraiser.org/
// info@barnraiser.org
// 
// This program is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by the
// Free Software Foundation; either version 2, or (at your option) any
// later version.
// 
// This program is distributed in the hope that it will be useful, but
// WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with program; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
// 02111-1307, USA.
// -----------------------------------------------------------------------


// Puts browser window at top (out of frames) - stops bug with registering 
// from inside hotmail frame.
if (self != top){
   if (document.images) top.location.replace(document.location.href);
   else top.location.href = document.location.href;
}


// Shows or hides an object
function objShowHide(id, state) {
	
	if (document.getElementById) {
		if (!state) {
			state = document.getElementById(id).style.display;
			
			if (state == 'none') {
				state = 'block';
			}
			else {
				state = 'none';
			}
		}
		
		document.getElementById(id).style.display = state;
	}
	else {
		if (document.layers) {
			document.id.visibility = state;
		}
		else { // IE 4
			document.all.id.style.display = state;
		}
	}
}


function checkLength(id, length, display) {
	var field = document.getElementById(id);
	if (field.value.length > length) {
		field.value = field.value.substr(0, length);
	}
	var chars_left = length-field.value.length;
	document.getElementById(display).innerHTML = "(" + chars_left + ")";
}


var myWindow;

function launchPopupWindow(page, name) {
	if(myWindow && !myWindow.closed) {
			myWindow.close();
	}
	
	var winMargin = 100;
	var winWidth = 350;
	var winHeight = 250;
	
	customise = "scrollbars,width="+winWidth+",height="+winHeight;
	
	var rightwidth = (parseInt(screen.availWidth)-winWidth)-winMargin;
	
	customise = customise + ',left='+rightwidth;
	customise = customise + ',top='+winMargin;
	
	myWindow = window.open(page,name,customise);
	
	myWindow.focus();
}
