/**
 *	Password Reminder Tools
 *  ~~~~~~~~~~~~~~~~~~~~~~~
 *	Copyright : Isotope Communications Ltd
 */

var pwdTools = new Class.create();

pwdTools.prototype = {
	
	initialize : function () {
		
	},
	
	magic : function () {
		var guess = '';
		if ( $('email') && $('email').value ) {
			guess = $('email').value;
		} else if ( $('_email') && $('_email').value ) {
			guess = $('_email').value;
		} else if ( $('username') && $('username').value ) {
			guess = $('username').value;
		}
		
		this.pop = window.open('/r/x/tools/pwd.php?guess=' + guess , 'pwd', this.get_params(), 0 );
		
	},
	
	
	send : function ( login, key ) {
		if ( login ) {
			qStr = '?r=' + Math.random() + '&l=' + escape(login) + '&k=' + key;
			fetch_versions = new Ajax.Updater(
								$('messageBlock'),
								'/r/x/tools/pwd.php',
								{
									method : 'get',
									parameters : qStr,
									evalScripts: true
								}
							);
		}
	},
	
	
	resize : function (){
		if ( b = document.body ) {
			chromeHeight = ((b.offsetHeight - b.clientHeight)*2)+24;
			if ( (navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('NT 5.1') != -1) ){
				chromeHeight += 32;
			} else {
				chromeHeight = 32;
			}
			chromeWidth = (b.offsetWidth - b.clientWidth)*2;
			window.resizeTo(500,500); // hacked by Dave (12/12/2008) on instructions of Jim Morrison :)
		}
		window.focus();
	},
	
	get_params : function () {
		return 	'width='+this.width+
				',height='+this.height+
				',status='+this.status+
				',toolbar='+this.toolbar+
				',location='+this.location+
				',menubar='+this.menubar+
				',resizable='+this.resizable+
				',scrollbars='+this.scrollbars
	},
		
	width 		: 	380,
	height		:	10,
	status		:	0,
	toolbar		:	0,
	location	:	0,
	menubar		:	0,
	resizable	:	1,
	scrollbars	:	0,
	
	show_link : function ( linkContent, domEle ){
		linkPrecede = ( linkContent ) ? '' : '&#187; ';
		linkContent = ( linkContent ) ? linkContent : 'Forgotten your password?';
		html = linkPrecede + '<a href="#" onclick="pwd.magic();">' + linkContent + '</a>';
		document.write( html );
	},
	
	end : null
	
	
};

var pwd = new pwdTools();


