/*	-----------------------------------
	function to add events
	-----------------------------------*/
function addEvent(obj, evType, fn)
{ 
	if (obj.addEventListener)
	{ 
		obj.addEventListener(evType, fn, false); 
		return true; 
	}
	else if (obj.attachEvent)
	{ 
		var r = obj.attachEvent("on"+evType, fn); 
		return r; 
	}
}

/*	-----------------------------------
	link functions
	-----------------------------------*/
function initLinkFunctions()
{
	if (document.getElementById && document.getElementsByTagName)
	{
		var links = document.getElementsByTagName('a');
		
		for (var a = 0; a < links.length; a++)
		{
			// open external links in new window
			if (links[a].className == 'external')
			{
				links[a].onclick = function()
				{
					window.open(this.href);
					return false;
				}
			}
			
			// set email links
			if (links[a].className == 'emailLink')
			{
				links[a].onmouseover = function()
				{
					var pattern = /@/;
					if (this.id.match(pattern) != null)
					{
						this.href='mail' + 'to:' + this.id;
					}
					else
					{
						this.href='mail' + 'to:' + this.id + '@brandspeoplelove.com';
					}
					return false;
				}
			}
		}
	}
}
addEvent(window, 'load', initLinkFunctions);


/*	-----------------------------------
	standard functions
	-----------------------------------*/

/*  popup windows	*/

function newWindow(mypage,myname,w,h,scroll,pos)
{
	if (pos == "random")
	{
		LeftPosition = (screen.width)?Math.floor(Math.random()*(screen.width-w)) :100;
		TopPosition = (screen.height)?Math.floor(Math.random()*((screen.height-h)-75)):100;
	}
	
	if (pos == "center")
	{
		LeftPosition = (screen.width)?(screen.width-w)/2:100;
		TopPosition=(screen.height)?(screen.height-h)/2:100;
	}
	
	else if ((pos != "center" && pos != "random") || pos == null)
	{
		LeftPosition = 25; TopPosition = 25;
	}

	settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',location=no,directories=no,status=yes,menubar=yes,toolbar=no,resizable=yes';

	win = window.open(mypage,myname,settings);
	if (win.focus)
	{
		win.focus();
	}
}