var imagepath = '/i';

function MM_openBrWindow(theURL,winName,features) { //v2.0
	window.open(theURL,winName,features);
}

function refreshclose() {
	topener.location.reload();
	window.top.close();
}

function removereaction() {
	if (confirm("Are you sure you want to delete this reaction?\n\nNote: only delete it when it contains:\n-Links to illegal or pornographic material\n-A flame (insults to another person)\n-Spamming (promoting a off-topic site)\n\nPs: try to edit posts as much as possible,\ninstead of deleting.")) {
		return true;
	} else {
		return false;
	}
}

function confirm_newpm() {
	input_box = confirm("You have a new private message. Click OK to view it, or cancel to hide this prompt.");
	if (input_box == true) {
		second_box = confirm("Open in new window?\n\n(Press cancel to open your Inbox in the current window.)");
		if (second_box == true) {
			window.open('/talk/private.php','pmnew','width=600,height=500,menubar=yes,scrollbars=yes,toolbar=yes,location=yes,directories=yes,resizable=yes,top=50,left=50'); 
		} else {
			window.location="/talk/private.php";
		}
	}
}

function ChangeSearchAction() {
	if (document.searchForm.searchtype.value == 'talk') {
		document.searchForm.action = "/talk/search.php";
	} else if (document.searchForm.searchtype.value == 'google') {
		document.searchForm.action = "http://www.google.com/search?affiliateid=4543";
	} else {
		document.searchForm.action = "/search/"+ document.searchForm.searchtype.value;
	}

	if (document.searchForm.searchtype.value == 'google') {
		document.searchForm.searchterm.name = "q";
		document.searchForm.target = "_blank";
	} else {
		document.searchForm.searchterm.name = "searchterm";
		document.searchForm.target = "_top";
	}
}

function imgFlip(imageName,imageSrc) {
	if (document.images)
		document.images[imageName].src = eval(imageSrc + ".src");
}

if (document.images) {
	moreBLUE = new Image();
	moreBLUE.src = imagepath + "/g/musicsquare-more_blue.gif";

	moreYLW = new Image();
	moreYLW.src = imagepath + "/g/musicsquare-more_yellow.gif";

	menuMID = new Image();
	menuMID.src = imagepath + "/g/m/menu-mid.gif";

	menuBOT = new Image();
	menuBOT.src = imagepath + "/g/m/menu-bot.gif";
}

function showimage(ImgID) {
	window.open( imagepath + "/h/showimage.html?"+ImgID, "", "resizable=0,width=10,height=10");
}

function loginfocus() {
	document.login.username.focus();
}

function aimwindow(aimid) {
	window.open("member.php?s=$session[sessionhash]&action=aimmessage&aim="+aimid,"_blank","toolbar=no,location=no,menubar=no,scrollbars=no,width=175,height=275,resizeable=yes,status=no")
}

function who(threadid) {
	window.open("misc.php?s=$session[sessionhash]&action=whoposted&threadid="+threadid, "whoposted", "toolbar=no,scrollbars=yes,resizable=yes,width=230,height=300");
}

function opensmiliewindow(x, y, form, field) {
	window.open("/pages/getsmilies?form="+ form +"&field="+field, "smilies", "toolbar=no,scrollbars=yes,resizable=yes,width="+x+",height="+y);

}

var maxWidth = 400;

function ScaleImage(im) {
	if (typeof im.naturalWidth == 'undefined') im.naturalWidth = im.width;

	if (im.naturalWidth > maxWidth) {
		im.width = maxWidth;
		im.style.maxWidth = im.naturalWidth + 'px';
		im.className = 'resized';
		im.title = 'Click for original size';
		im.onclick = UnscaleImage;
	}
}

function UnscaleImage() {
	if (this.width == maxWidth) {
		this.width = this.naturalWidth;
		this.title = 'Click for small size';
	} else {
		this.width = maxWidth;
		this.title = 'Click for original size';
	}
}

function submit_vote (vote) {
	document.poll.option.value = vote;
	document.poll.submit();
}

function checkBox (e)
{
	var theBox = (e.target) ? e.target : e.srcElement;

	if (theBox.name == "compare[]")
	{
		var c = 0;
		var aBox = theBox.form["compare[]"];

		for (var i = 0; i < aBox.length; i++)
		{
			if (aBox[i].checked)
			{
				c++;
			}
		}

		var cDis = false;

		if (c > 3)
		{
			cDis = true;
		}

		for(var i = 0; i < aBox.length; i++)
		{
			if (!aBox[i].checked)
			{
				aBox[i].disabled = cDis;
			}
		}
	}
}


function IE6error()
{
	var IEversion = parseFloat (navigator.appVersion.split("MSIE")[1]);

	if (IEversion < 7)
	{
		document.write ('<div style="position: relative; background: white url(/i/g/ie-back.gif) repeat-x fixed top; padding: 0; margin: 0 auto; border: 0; height: 36px; width: 100%; "><a href="/pages/ie6"><img src="/i/g/ie-note.gif" border="0" /></a></div>');
	}
}

function SearchSite ()
{
	var keyword = document.SiteSearch.Keyword.value.replace(/ /g, "_");

	document.SiteSearch.action = "http://acharts.us/search/"+ keyword.toLowerCase();
}