/*
 * gcchsa_scripts.js
 *
 * --------------------------------------------------------------------
 *
 */


function popupWindows(in_address, in_windowName, in_parameters) {
	if(!window.focus)
		return true;
	try {
		//windowName = in_windowName;
		windowName = window.location.hostname.replace(/\./g,"_")+"_"+in_windowName;
		var win=window.open(in_address, windowName, in_parameters);
		win.focus();
	}
	catch(e) {}
	return false;
}


var g_address;
var g_win;


function popupAfterDelay() {
	//alert("oldaddress="+g_win.location+" setting address="+g_address);
	g_win.location = g_address;
	//alert("done");
}

function delayPopup(in_address, in_windowName, in_parameters) {
	windowName = window.location.hostname.replace(/\./g,"_")+"_"+in_windowName;
	//alert("in_windowName="+in_windowName+" windowName="+windowName);
	try {
		// Put this back in 08/12/2005 - previous error due to security settings?  (need to allow scripts or put this site in trusted list)
		var win=window.open('blank.html', windowName, in_parameters);
		// The above failing on home pc when opening second window ?? 05/28/2005 pvd
		//var win=window.open('', '', in_parameters);
		win.focus();
		with(win.document) {
			open(); 
			write('<body style="background: #112277;color: white">');
			write('Please wait while downloading file: <em>');
			write(in_address);
			write('</em>');
			write('</body>');
			close();
		}
		g_address = in_address;
		g_win = win;
		window.setTimeout("popupAfterDelay();", 1200);
	}
	catch(e) {
		alert("exception "+e.name+" "+e.message);
	}
	return false;
}

function sendmail(domain,user) { 
	document.location.href = "mailto:" + user + "@" + domain;
}

// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

function submitAfterDelay() {
	g_form.submit();
	g_form.target = g_oldTarget;
}

var g_form;
var g_oldTarget;

function submitFormPopup(in_form, in_action, in_windowName, in_parameters)	{
	in_form.action = in_action;
	//windowName = in_windowName;
	windowName = window.location.hostname.replace(/\./g,"_")+"_"+in_windowName;
	try {
		var win=window.open("blank.html", windowName, in_parameters);
		win.focus();
		var oldTarget = in_form.target;
		in_form.target = win.name;
		g_form = in_form;
		g_oldTarget = oldTarget;
		window.setTimeout("submitAfterDelay();", 200);
	}
	catch(e) {
		//alert("exception "+e.name+" "+e.message);
	}
	return false;
}
