// -----------------------------------------------------------------------
// FORCED ACTIONS - ALWAYS OCCUR ON CACHE
// -----------------------------------------------------------------------
da_image = new Image();
da_image.src = "img/sacred.ico";

// -----------------------------------------------------------------------
// Rollover image functions
// -----------------------------------------------------------------------
function ssSwapImgRestore() {
  var i,x,a=document.SS_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function ssPreloadImages() {
  var d=document; if(d.images){ if(!d.SS_p) d.SS_p=new Array();
    var i,j=d.SS_p.length,a=ssPreloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.SS_p[j]=new Image; d.SS_p[j++].src=a[i];}}
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function ssFindObj(n, d) {
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=ssFindObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function ssSwapImage() {
  var i,j=0,x,a=ssSwapImage.arguments; document.SS_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=ssFindObj(a[i]))!=null){document.SS_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

// -----------------------------------------------------------------------
//reloads the window if Nav4 resized
// -----------------------------------------------------------------------
function ss_reloadPage(init) {
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.ss_pgW=innerWidth; document.ss_pgH=innerHeight; onresize=ss_reloadPage; }}
  else if (innerWidth!=document.ss_pgW || innerHeight!=document.ss_pgH) location.reload();
}
ss_reloadPage(true);

// -----------------------------------------------------------------------
// Create a pop-open window
// -----------------------------------------------------------------------
function popopen(mylink, sx, sy)
{	var nref;
	nref=mylink.href;
	NFW=window.open(nref, 'SacredPopup','width='+sx+',height='+sy+',scrollbars=no,location=no,directories=no,status=no,menubar=no,resizable=no,toolbar=no');
	NFW.moveTo((screen.width/2)-(sx/2),(screen.height/2)-(sy/2));
	return false;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function popuserinfo(ssuid)
{	var nref;
	NFW=window.open('pop_userinfo.php?uid=' + ssuid, 'SacredPopup','width=500,height=340,scrollbars=no,location=no,directories=no,status=no,menubar=no,resizable=no,toolbar=no');
	NFW.moveTo((screen.width/2)-(sx/2),(screen.height/2)-(sy/2));
	return false;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function popchathelp()
{	var nref;
	NFW=window.open('pop_chathelp.php', 'SacredPopup','width=500,height=340,scrollbars=yes,location=no,directories=no,status=no,menubar=no,resizable=no,toolbar=no');
	NFW.moveTo((screen.width/2)-(sx/2),(screen.height/2)-(sy/2));
	return false;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function popchatinfo(roomid)
{	var nref;
	NFW=window.open('pop_chatinfo.php?uid=' + roomid, 'SacredPopup','width=500,height=340,scrollbars=yes,location=no,directories=no,status=no,menubar=no,resizable=no,toolbar=no');
	NFW.moveTo((screen.width/2)-(sx/2),(screen.height/2)-(sy/2));
	return false;
}

// -----------------------------------------------------------------------
// Disable right click - UNCOMMENT THE 2 TRAILING LINES TO ENABLE
// -----------------------------------------------------------------------
function right(e)
{	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
	{	return false;
	}
	else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3))
	{	alert('Sorry - right-click is disabled');
		return false;
	}
	return true;
}
//document.onmousedown=right;
//if (document.layers) {window.captureEvents(Event.MOUSEDOWN);}window.onmousedown=right;

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function popWindow(url,width,height)
{
	//default pos
	xposition = 0;
	yposition = 0;
	
	//center it
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	
	args = "width=" + (width) + "," 
	+ "height=" + (height) + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=auto,"
	+ "status=1," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "left=" + xposition + ","
	+ "top=" + yposition;
	window.open(url,'sgPop' + Math.floor(Math.random()*1000000000),args);
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function popWindowScroll(url,width,height)
{
	//default pos
	xposition = 0;
	yposition = 0;
	
	//center it
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
		xposition = (screen.width - width) / 2;
		yposition = (screen.height - height) / 2;
	}
	
	args = "width=" + (width) + "," 
	+ "height=" + (height) + "," 
	+ "location=0," 
	+ "menubar=0,"
	+ "resizable=1,"
	+ "scrollbars=1,"
	+ "status=1," 
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "left=" + xposition + ","
	+ "top=" + yposition;
	window.open(url,'sgPop' + Math.floor(Math.random()*1000000000),args);
}

// -----------------------------------------------------------------------
// opens link in parent window for popups
// -----------------------------------------------------------------------
function main(url)
{	opener.location.href=url;
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function ssAddTag(tag, target)
{	var insert = '';
	switch(tag)
	{	case 'url':
			var url = prompt("Enter the address of the web page you are linking - do not include the http:// part of the address", "");
			insert = "[URL]"+url+"[/URL]";
		break;

		case 'eml':
			var email = prompt("Enter the complete email address (someone@somewhere.com) that you wish to add.", "");
			insert = "[EML]"+email+"[/EML]";
		break;
			
		case 'img':
			var image = prompt("Enter the complete URL for the image you wish to display - do not include the http:// part of the address", "");
			insert = "[IMG]"+image+"[/IMG]";	
		break;
	}
	document.getElementById(target).value += insert;
	document.getElementById(target).focus();			
}

// -----------------------------------------------------------------------
// -----------------------------------------------------------------------
function ssAddFormat(bbopen, bbclose, myField)
{	var myTextArea = document.getElementById(myField);
	myTextArea.focus();

	if (document.selection)
	{	if (document.selection.createRange().text)
		{	document.selection.createRange().text = bbopen + document.selection.createRange().text + bbclose;
		}
		else
		{	myTextArea.value += bbopen + ' ' + bbclose;
		}
	}
	else if (window.getSelection)
	{	txt = window.getSelection() + '';
		myTextArea.value += bbopen + txt + bbclose;
	}
	else if (document.getSelection)
	{	txt = document.getSelection();
		myTextArea.value += bbopen + txt + bbclose;
	}
	else
	{	myTextArea.value += bbopen + ' ' + bbclose;
	}
	myTextArea.focus();
}
