//Site-wide File

var bookmarkurl="http://chsa.net"
var bookmarktitle="Compro Online Virtual Home of Compronians"
var winCompronian = null;
var winGenSW = null;

function addbookmark(){
	if ( document.all ) {
		window.external.AddFavorite(bookmarkurl,bookmarktitle)
	}
	else
		if ( window.sidebar&&window.sidebar.addPanel ) {
			window.sidebar.addPanel( bookmarktitle, bookmarkurl, "" )
		}
		else		
			OpenWindowGenSW( "Error", "Site_content/Error.asp?tag=music", 250, 250, false )		
}

function popDialog(page, Input) {
	if ( document.all )
		return showModalDialog( page + '?Input=' + Input, "",
		  'dialogHeight:350px; dialogWidth:350px; resizable:no; status:no');
	else
		return OpenWindowGenSW( "Error", page + '?Input=' + Input, 350, 350, false );
}

function LogOut() {
	document.location.href = "Site_Content/ProcLogin.asp?act=logout"
}

function OpenWindowGenSW( Name, Url, Width, Height, StatusBar ) {
	if ( winGenSW != null )
	{
		winGenSW.setURL( Url );
		winGenSW.setSize(Width, Height);
	}
	else
	{
		winGenSW = new Window({className: "alphacube", top:70, left:100, width:Width, height:Height, url: Url, hideEffect: Effect.Fade, showEffectOptions: {duration:1.5}});			 
	}
	winGenSW.showCenter();
	//winGenSW.setDestroyOnClose();
}

function PromptChat( Width, Height ) {
	var leftPos, topPos, htmlCode;
		
	leftPos = (screen.width) ? (screen.width-Width)/2 : 0;
	topPos = (screen.height) ? (screen.height-Height)/2 : 0;
	
	Dialog.confirm(
		"<P align='left' class='red9'>Do you want to <Strong>launch the chat window</Strong> to be able to chat with other Compronians currently logged in?</P><P align='left'><em>This feature requires opening a new window; ensure 'pop-up' blockers are disabled for this site.</em></P>",
		{
			className: "alphacube", top:topPos, left:leftPos, title:"Compro Online Chat",
			width:Width, height:Height, hideEffect:Effect.Fade, buttonClass: "myButtonClass",
			showEffectOptions:{duration:1.5}, destroyOnClose:true,
			okLabel:"Launch",
			onOk: OpenWindowChat
		}
	);
	
	function OpenWindowChat() {
		OpenWindowGenEM( "ChatWindow", "Chat/chatWindow.asp", 640, 505, false );
		Dialog.closeInfo();
	}
}

function OpenWindowGenEM( Name, Url, Width, Height, StatusBar ) {
	var x;
	x = "width=" + Width + ",height=" + Height + ",resizable=yes" + ",scrollbars=yes" // + ",menubar=yes"
	
	if ( !StatusBar )
		x = x + ",status=no";
	else
		x = x + ",status=yes";
	
	popupWin = window.open(Url, Name, x, true );
	popupWin.resizeTo( Width, Height );
	popupWin.focus();
}

function OpenWindowGenSWW( Name, Url, Width, Height, StatusBar )
{	
	if ( winCompronian != null )
	{
		winCompronian.setTitle( "Great Compronian - " + Name );
		winCompronian.setURL( Url );
	}
	else
	{
		winCompronian = new Window({className: "alphacube", title: "Great Compronian - " + Name, top:70, left:100, width:550, height:500, url: Url, hideEffect: Effect.Fade, showEffectOptions: {duration:1.5}});			 
	}
	winCompronian.showCenter();
	//winCompronian.setDestroyOnClose();
}

function openFull( Url, Name ) {
	var x, screenWidth, screenHeight;
	
	screenWidth = window.screen.width - ( window.screen.width / 100 );
	screenHeight = window.screen.height - ( window.screen.height / 100 );
	
	x = 'resizable=yes,scrollbars=yes,status=yes,menubar=yes,top=0,left=0,titlebar=yes,width=' + screenWidth + ',height=' + screenHeight + ',screenX=0,screenY=0'
	
	popupWin = window.open(Url, Name, x, true );
	popupWin.moveTo(2, 2);
	popupWin.focus();
}

/*
==================================================================
LTrim(string) : Returns a copy of a string without leading spaces.
==================================================================
*/
function LTrim(value)
/*
   PURPOSE: Remove leading blanks from our string.
   IN: str - the string we want to LTrim
*/
{
	var re = /\s*((\S+\s*)*)/;
	return value.replace(re, "$1");
}

/*
==================================================================
RTrim(string) : Returns a copy of a string without trailing spaces.
==================================================================
*/
function RTrim(value)
/*
   PURPOSE: Remove trailing blanks from our string.
   IN: str - the string we want to RTrim

*/
{
	var re = /((\s*\S+)*)\s*/;
	return value.replace(re, "$1");
}

/*
=============================================================
Trim(string) : Returns a copy of a string without leading or trailing spaces
=============================================================
*/
function Trim(value)
/*
   PURPOSE: Remove trailing and leading blanks from our string.
   IN: str - the string we want to Trim

   RETVAL: A Trimmed string!
*/
{
   return LTrim(RTrim(value));
}
