﻿/* popup */
function popup(sUrl, sName, iWidth, iHeight, iLeft, iTop)
{
	window.open(sUrl, sName, "width=" + iWidth + ", height=" + iHeight + ", top=" + iTop + ", left=" + iLeft + ", screenY=" + iTop + ", screenX=" + iLeft);
}

/* trim */
String.prototype.trim = function () {
  return this.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1");
};

/* add bookmark */
function addBookmark(title,url){
if (window.sidebar) // firefox
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

// MouseOver
function MouseOver(ID)
{
	if (document.getElementById(ID).src.indexOf('_over') <= -1)
	{
		document.getElementById(ID).src = document.getElementById(ID).src.replace('.gif','_over.gif');
	}
}

// MouseOut
function MouseOut(ID)
{
	if (document.getElementById(ID).src.indexOf('_over') >= -1)
	{
		document.getElementById(ID).src = document.getElementById(ID).src.replace('_over.gif','.gif');
	}
}

// Quote script
function QuoteThread(ThreadID, TextareaControlUniqueID)
{
	document.getElementById(TextareaControlUniqueID).value = document.getElementById(TextareaControlUniqueID).value + '#' + ThreadID + ' > ';
	document.getElementById(TextareaControlUniqueID).focus();
}

// StartChat
function StartChat()
{
	if (document.getElementById('txtChatNick').value=='')
	{
		alert('Du skal skrive et navn i feltet!');
		document.getElementById('txtChatNick').focus();
		return false;
	}
	else
	{
		window.open('/Chat/PopupIRC.aspx?nick=' + document.getElementById('txtChatNick').value,'TestMaxWebIRC','width=800,height=450');
	}
}

function QuickSearch(inputID)
{
	window.location.href='/Forum/Search/?Search='+document.getElementById(inputID).value;
}

/* preload images */
PasterOver = new Image();
PasterOver.src = '/images/switch/paster_over.gif';

TestmaxOver = new Image();
TestmaxOver.src = '/images/switch/testmax_over.gif';

FileCommentOver = new Image();
FileCommentOver.src = '/images/switch/filecomment_over.gif';