
// CLIENT LOGIN SUBMIT
function login(fObj){
	var uname = $('#textinput').val();
	var pass = $('#passwordinput').val();
	var url = 'ftp://' + uname + ':' + pass + '@ftp.precadd.com/';
	
	window.location.href = url;
}

// FORGOTTEN PASSWORD
function forgottenPassword(){
	// GET THE FORM CONTENT VIA AJAX
	$.ajax({
		url: 'ajax.services/service.display-forgotten-password-form.php',
		type: 'POST',
		timeout: 1000,
		dataType: 'html',
		data: {},
		success: function(response){
			loadDialog(response);
		}
	});
}

function loadDialog(content){
	var objOverlay = $('<div id="overlay"></div>');
	var objDialog = $('<div id="display-box"></div>');
	var arrayPageDimensions = getPageSize();
	
	// SET THE OVERLAY CSS
	objOverlay.css({
		backgroundColor: '#000',
		width: arrayPageDimensions[0] + 'px',
		height: arrayPageDimensions[1] + 'px',
		filter: 'alpha(opacity=60)',
		'-moz-opacity': '0.6',
		opacity: '0.6',
		position:'absolute',
		top: '0',
		left: '0',
		display:'inline'
	});
	
	// SET THE DIALOG-BOX CSS
	objDialog.css({
		position: 'absolute',
		width: '400px',
		height: '180px',
		left: parseInt((arrayPageDimensions[0]/2)-200) + 'px',
		top: '50px',
		display: 'none',
		backgroundColor: '#FFF',
		border: '10px solid #333'
	});
	
	$('body').append(objOverlay);
	objDialog.append(content);
	$('body').append(objDialog);
	objDialog.slideDown('slow');
	
	// BINDINGS
	objOverlay.bind('click', function(){ closeDialog(); });
}

function closeDialog(){
	$('#display-box').slideUp('slow',function(){
		$('#overlay').fadeOut('slow', function(){
			$('#overlay').remove();
			$('#display-box').remove();
		});
	});
}

// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
	
	var xScroll, yScroll;
	
	if (window.innerHeight && window.scrollMaxY) {	
		xScroll = window.innerWidth + window.scrollMaxX;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	
	var windowWidth, windowHeight;
	
	if (self.innerHeight) {	// all except Explorer
		if(document.documentElement.clientWidth){
			windowWidth = document.documentElement.clientWidth; 
		} else {
			windowWidth = self.innerWidth;
		}
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) { // other Explorers
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}	
	
	// for small pages with total height less then height of the viewport
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else { 
		pageHeight = yScroll;
	}

	// for small pages with total width less then width of the viewport
	if(xScroll < windowWidth){	
		pageWidth = xScroll;		
	} else {
		pageWidth = windowWidth;
	}

	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
	return arrayPageSize;
}