// SHQ.js
//
// Javascript functions for www.SoloHQ.com
// Copywrite (c) 2003 by Jeff Landauer

// Break out of someone else's frame
if (top.location != location)
{
	top.location.href = document.location.href;
}


//BrowCheck = navigator.appName == "Microsoft Internet Explorer";
var agt=navigator.userAgent.toLowerCase();
var BrowCheck = (agt.indexOf("msie") != -1);


function WriteFooter()
{

}
function WriteStyle()
{



}
function WriteSiteMeterCode()
{

//	document.write('<table align=right border=7><tr><td>');
	document.write(''
	+ '<!--WEBBOT bot="HTMLMarkup" startspan ALT="Site Meter" -->'
	+ '<script type="text/javascript" language="JavaScript">var site="sm2importanceofphilosophy"</script>'
	+ '<script type="text/javascript" language="JavaScript1.2" src="http://sm2.sitemeter.com/js/counter.js?site=sm2importanceofphilosophy">'
	+ '</script>'
	+ '<noscript>'
	+ '<a href="http://sm2.sitemeter.com/stats.asp?site=sm2importanceofphilosophy" target="_top">'
	+ '<img src="http://sm2.sitemeter.com/meter.asp?site=sm2importanceofphilosophy" alt="Site Meter" border=0 align=right></a>'
	+ '</noscript>'
	+ '<!-- Copyright (c)2000 Site Meter -->'
	+ '<!--WEBBOT bot="HTMLMarkup" Endspan -->'
	);
//	document.write('</td></tr></table>');

}


function SwapImage(strTargetName, imgNewSource)
{
//	if (BrowCheck && document.images)	// Nutscrape is buggy with the div's, so don't do rollovers with Nutscrape
//	{
		document[strTargetName].src = imgNewSource.src;
//	}
}

function Highlight(name)
{
	document[name + 'Gif'].src = ButtonArray[name]['Hover'].src;
}

function Normal(name)
{
	document[name + 'Gif'].src = ButtonArray[name]['Normal'].src;
}

var ButtonArray = new Array();

var height = 35;

function CreateButton(name, width)
{
	ButtonArray[name] = new Array();
	ButtonArray[name]['Normal'] = new Image(width, height);
	ButtonArray[name]['Hover'] = new Image(width, height);
	ButtonArray[name]['Normal'].src = "/img/EmptyPixel.gif";
	ButtonArray[name]['Hover'].src = "/img/EmptyPixel.gif";
}

function LoadNormalButton(name)
{
	ButtonArray[name]['Normal'].src = "/img/" + name + ".gif";
	ButtonArray[name]['Hover'].src = "/img/" + name + ".gif";
}

function LoadHighlightButton(name)
{
	ButtonArray[name]['Hover'].src = "/img/" + name + "HL.gif";
}

function SetNormalButton(name)
{
//	document.all.item(name + 'Gif').src = ButtonArray[name]['Normal'].src;
	document[name + 'Gif'].src = ButtonArray[name]['Normal'].src;
}

var Names = new Array("Credo", "War", "Spirit", "People", "Store", "Archives", "Forum", "Objectivism");
//var Names = new Array("Credo", "War");

CreateButton('Credo', 91);
CreateButton('War', 62);
CreateButton('Spirit', 79);
CreateButton('People', 78);
CreateButton('Store', 75);
CreateButton('Archives', 89);
CreateButton('Forum', 77);
CreateButton('Objectivism', 109);

// Create the footer buttons
ButtonArray['Home'] = new Array();
ButtonArray['Home']['Normal'] = new Image(70, 45);
ButtonArray['Home']['Hover'] = new Image(70, 45);
ButtonArray['Home']['Normal'].src = "/img/FooterLButton2.gif";
ButtonArray['Home']['Hover'].src = "/img/FooterLButton2.gif";
ButtonArray['About'] = new Array();
ButtonArray['About']['Normal'] = new Image(70, 45);
ButtonArray['About']['Hover'] = new Image(70, 45);
ButtonArray['About']['Normal'].src = "/img/FooterRButton2.gif";
ButtonArray['About']['Hover'].src = "/img/FooterRButton2.gif";


function BodyOnLoad()
{
//	LoadMainTopButtons();
	// Load the highlights
	for (var i=0; i<Names.length; ++i)
	{
		LoadHighlightButton(Names[i]);
	}
	ButtonArray['Home']['Hover'].src = "/img/FooterLButtonHL.gif";
	ButtonArray['About']['Hover'].src = "/img/FooterRButtonHL.gif";

}

function LoadMainTopButtons()
{
	// Load the normal buttons and set them
	for (var i=0; i<Names.length; ++i)
	{
		LoadNormalButton(Names[i]);
		SetNormalButton(Names[i]);
	}
}

function LoadHighlights()
{
	if (BrowCheck)
	{
		CredoHover.src = "/img/CredoHighlight.gif";
		SpiritHover.src = "/img/Spirit-H.gif";
		ObjectivismHover.src = "/img/Objectivism-H.gif";
		DailyHover.src = "/img/Daily-H.gif";
		WarRoomHover.src = "/img/War-Room-H.gif";
		ForumHover.src = "/img/Forum-H.gif";
		BookStoreHover.src = "/img/Book-Store-H.gif";
		}
}

var ThisSiteToSearch = 'SoloHQ.com';	// Do this for now because SHQ hasn't been crawled

function GoogleSearch()
{
	var v = document.myform.entry.value;
	var collection = document.forms.myform.sel1;

//	if (document.myform.s1.checked)
	if (collection[0].checked)
	{
		v += ' site:importanceofphilosophy.com';
		v += ' OR site:freeradical.co.nz';
		v += ' OR site:objectivistcenter.org';
		v += ' OR site:aynrand.org';
		v += ' OR site:capitalismmagazine.com';
		v += ' OR site:objectivism.addr.com';
		v += ' OR site:objectivismtoday.com';
		v += ' OR site:fullcontext.org';
		if (BrowCheck)
		{
			top.location.href = 'http://www.Google.com/search?q=' + v;
		}
		else	// Nutscrape
		{
			document.myform.q.value = v;
		}
	}
	else if (collection[1].checked)
	{
		if (BrowCheck)
		{
			top.location.href = 'http://www.Google.com/custom?q=' + v + '&sitesearch=' + ThisSiteToSearch;
		}
		else	// Nutscrape
		{
			document.myform.q.value = v;
			document.myform.sitesearch.value = ThisSiteToSearch;
		}
	}
	else
	{
		if (BrowCheck)
		{
			top.location.href = 'http://www.Google.com/search?q=' + v;
		}
		else	// Nutscrape
		{
			document.myform.q.value = v;
		}
	}
}

function IEPostFunction(sCN1, sCN2, sCN3)
{
//	var mycontent = EditArea.innerHTML;
//	document.all("form1").PostContent.value=mycontent;

	if (sCN1)
	{
		var sContentID = sCN1 + "ID";
		var sContentEA = sCN1 + "EditArea";
		var mycontent = document.all(sContentEA).innerHTML;
		document.all(sContentID).value=mycontent;
	}

	if (sCN2)
	{
		var sContentID = sCN2 + "ID";
		var sContentEA = sCN2 + "EditArea";
		var mycontent = document.all(sContentEA).innerHTML;
		document.all(sContentID).value=mycontent;
	}

	if (sCN3)
	{
		var sContentID = sCN3 + "ID";
		var sContentEA = sCN3 + "EditArea";
		var mycontent = document.all(sContentEA).innerHTML;
		document.all(sContentID).value=mycontent;
	}
}

function docCommand(sContentEditArea, sEvent,sValue)
{
//	EditArea.focus();
	document.all(sContentEditArea).focus();
	document.execCommand(sEvent,false,sValue);
}

function docTest(sContent)
{
//	EditArea.focus();
	document.all(sContent + 'EditArea').focus();
	alert(document.all(sContent + 'EditArea').innerHTML);
}

function docBlockQuote(sContentEditArea)
{
//	EditArea.focus();
	document.all(sContentEditArea).focus();
	var oSelection = document.selection.createRange();
	var tThingToQuote = oSelection.htmlText;
	if (tThingToQuote == '' || tThingToQuote == '<P>&nbsp;</P>')
		tThingToQuote = 'quote';
	oSelection.pasteHTML("<blockquote>" + tThingToQuote + "</blockquote>");
}

function docCreateLink(sContentEditArea)
{
//	EditArea.focus();
	document.all(sContentEditArea).focus();
	document.execCommand('CreateLink',true,'');
}

function AuthorSelectFunc(iIndex)
{
	if (iIndex == 0)	// Create New Author, undisable the text boxes
	{
//		alert(AuthorVarCount);
		for(var i=0; i<AuthorVarCount; ++i)
		{
//			alert(AuthorVars[i]);
			document.all(AuthorVars[i] + 'ID').disabled=0;
			document.all(AuthorVars[i] + 'ID').removeAttribute('className', 'false');
		}
	}
	else	// Some existing auther, disable the text boxes
	{
		for(var i=0; i<AuthorVarCount; ++i)
		{
			document.all(AuthorVars[i] + 'ID').disabled=1;
			document.all(AuthorVars[i] + 'ID').setAttribute('className', 'DisabledInput', 'false');
		}
//		alert(document.all('AuthorSelect').item(iIndex).value);
	}
}
