function openExternal(url) {
	left = (screen.width - 800) / 2;
	top = (screen.height - 600) / 2 - 40;

	var win = window.open(url,'externalWin','width=800, height=600, left=' + left + ', top=' + top + ', dependent=yes');
	win.focus();
}

function toggleForms(catId) {
	group = document.getElementById('formGroup' + catId);
	files = document.getElementById('fileList' + catId);
	
	if (files.style.display == 'none') {
		group.className = 'show';
		files.style.display = '';
	}
	else {
		group.className = 'hide';
		files.style.display = 'none';
	}
}

function remoteSiteAccess(url,string) {
	if(!string)
		string = '';
	window.open('login_ExternalWTPSystem.cfm?target=' + url + '&redirectstring=' + string);
}

function form_login(frm){
	if(!frm.email.value.length) { alert('Please enter your email address.'); return false; }
	if(!frm.password.value.length) { alert('Please enter your password.'); return false }
	return true;
}

function form_feedback(frm) {
	
	if(!ValidateField(frm.travellerEmail,"email","Please enter a traveller email.") || !ValidateField(frm.travellerEmail,"text","Please enter a traveller email.")) return false;
	if(!ValidateField(frm.travellerFirstname,"text","Please enter a traveller email and click Retrieve traveller details.")) return false;

	return true;
	
}

function form_feedback_retrieveTravellerDetails(frm) {
	frm.action.value = "";
	frm.submit();
	
}

function displayOverlay(href,title){
	myLightWindow.activateWindow({
		href:href, 
		title:title,
		width:730,
		height:490
	});
}

function doExternalLogin(success,msg) {
	
	// Hide the loader and display the update message
	$('Loader').hide();		
	$('Message').show().addClassName('Highlight').update(msg);
	
	// If success is true then submit the external login process
	if (success) {
		// Wait 1.5 seconds before submitting form so the DOM has a chance to change the message
		new PeriodicalExecuter(function(pe) {
			$('LoginForm').submit();
			pe.stop();	
		}, 1.5);	
	}
	
}

// Redirect
function redirect(Url){

	document.location = Url;
	
}