function getTop() {
	var agt=navigator.userAgent.toLowerCase();
	var is_opera  = (agt.indexOf('opera')!=-1);
	var top = 125;
	if ( is_opera ) {
		top = 25;
	}
	return top;
}

function customPopup(url_location, popupName, width, height, left, topAdjustment, customVariables) {
	var top = getTop() + topAdjustment;
	var variables = "alwaysRaised=yes,directories=no,width="+width+",height="+height+",left="+left+",top="+top+","+customVariables;
 	var popupWindow = window.open (url_location, popupName, variables);
 	popupWindow.focus();
}

function hPopup(url_location, popupName, width, height) {
	var variables = "location=no,scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no,titlebar=no";
	customPopup(url_location, popupName, width, height, 350, 15, variables);
}

function cPopup(url_location, popupName, width, height) {
	sa_onclick(url_location);
	var variables = "location=yes,scrollbars=yes,menubar=no,resizable=yes,status=yes,toolbar=no,titlebar=yes";
	customPopup(url_location, popupName, width, height, 100, 0, variables);
}

function popup(url_location, popupName) {
	var top = getTop();
	var variables = "alwaysRaised=yes,directories=no,width=448,height=500,left=100,top="+top+",location=no,scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no,titlebar=no";
 	var popupWindow = window.open (url_location, popupName, variables);
 	popupWindow.focus();
}

function addHostPopup(url_location, popupName, width, height) {
	var host = window.location.host;
	if ( host.indexOf("127.0.0.1:9080") > -1 ) {
		host = "127.0.0.1:9443";
	} else if ( host.indexOf("127.0.0.1") > -1 ) {
		host = "127.0.0.1";
	} else if ( host.indexOf("wcgdev.net") > -1 ) {
		host = "secure.wcgdev.net";
	} else if (	host == 'worldgrid.chicago.ibm.com' )  {
		host = 'worldgrid.chicago.ibm.com';
	} else if (	host == 'member.chicago.ibm.com' )  {
		host = 'member.chicago.ibm.com';
	} else if (	host == 'beta.worldcommunitygrid.org' )  {
		host = 'beta.worldcommunitygrid.org';
	} else {
		host = 'secure.worldcommunitygrid.org';
	}
	var url = "https://" + host + url_location;
	
	var top = getTop();
	var variables = "alwaysRaised=yes,directories=no,width="+width+",height="+height+",left=100,top="+top+",location=no,scrollbars=yes,menubar=no,resizable=yes,status=no,toolbar=no,titlebar=no";
 	var popupWindow = window.open (url, popupName, variables);
 	popupWindow.focus();
}

function getHost(url_location) {
	var host = window.location.host;
	if ( host.indexOf("127.0.0.1:9080") > -1 ) {
		host = "127.0.0.1:9443";
	} else if ( host.indexOf("127.0.0.1") > -1 ) {
		host = "127.0.0.1";
	} else if ( host.indexOf("wcgdev.net") > -1 ) {
		host = "secure.wcgdev.net";
	} else if (	host == 'worldgrid.chicago.ibm.com' )  {
		host = 'worldgrid.chicago.ibm.com';
	} else if (	host == 'member.chicago.ibm.com' )  {
		host = 'member.chicago.ibm.com';
	} else if (	host == 'beta.worldcommunitygrid.org' )  {
		host = 'beta.worldcommunitygrid.org';
	} else {
		host = 'secure.worldcommunitygrid.org';
	}
	var url = "https://" + host + url_location;
	return url;
}