/*

Author: Mark McDonnell [ mark [at] storm-media [dot] co [dot] uk ]

Application Date: 2006.05.15 / Monday.

Issues: N/A

*/

// Global Variables

	var d = document;
	
// DOM Functions

	function fnCreateObj(obj)
	{
		return d.createElement(obj);
	}
	// eDIV = fnCreateObj('div');
	
	function fnCreateStr(str)
	{
		return d.createTextNode(str);
	}
	// eTxtNode = fnCreateStr('Hello World!');
	
	function fnAppendChild(pNode,cNode)
	{
		pNode.appendChild(cNode);
	}
	// fnAppendChild(eUL,eLI);
	
	function fnSetAttribute(obj,attr,val)
	{
		obj.setAttribute(attr,val);
	}
	// fnSetAttribute(eDIV,'id','myDiv');
	
	function fnGetElement(objID)
	{
		return d.getElementById(objID);
	}
	// fnGetElement('id');	

	function fnInsertAfter(newElement, targetElement)
	{
		var parent = targetElement.parentNode;
		if(parent.lastChild == targetElement)
		{
			parent.appendChild(newElement);
		}
		else
		{
			parent.insertBefore(newElement, targetElement.nextSibling);
		}
	}
	
// Popup Window Function

	var Popup = {
		open: function(domain, w, h, toggle)
		{
			this.options = {
			url: domain,
			width: w,
			height: h,
			scrollbars: toggle,
			left: screen.width / 2 - (w / 2),
			top: screen.height / 2 - (h / 2)
			}
			
			window.open(this.options.url, '', 'resizable=yes, width=' + this.options.width + ',height=' + this.options.height + ',scrollbars=' + this.options.scrollbars + ',left=' + this.options.left + ',top=' + this.options.top);
		}
	}	
	// document.onclick = function() { Popup.open('http://www.storm-media.co.uk/', 780, 440, 'yes'); }

// Event Function

function fnAddEvent(obj, evType, fn, useCapture)
{
	
	if (obj.addEventListener)
	// Gecko browsers (Mozilla / Firefox)
	{
		obj.addEventListener(evType, fn, useCapture);
		return true;
	}
	else if (obj.attachEvent)
	// Internet Explorer 5+
	{
		var r = obj.attachEvent('on' + evType, fn);
		return r;
	}
	else
	{
		// This sets the event handler for NS4 & IE5/Mac.
		elm['on' + evType] = fn;
	}

}

// Event Triggers

	fnAddEvent(window, 'load', fnSetMagazineEvent);
	fnAddEvent(window, 'load', fnSetShopEvent);

// Triggered Functions

	function fnSetMagazineEvent()
	{
		if(fnGetElement('id-YouMagazine') == null || fnGetElement('id-YouMagazine') == 'undefined')
		{
			return false;
		}
		else
		{
			fnAddEvent(fnGetElement('id-YouMagazine'), 'click', fnSetMagazineLink);
		}
	}
	
	function fnSetShopEvent()
	{
		if(fnGetElement('id-Shop') == null || fnGetElement('id-Shop') == 'undefined')
		{
			return false;
		}
		else
		{
			fnAddEvent(fnGetElement('id-Shop'), 'click', fnSetShopLink);
		}
	}
	
// Called Functions
	
	function fnSetMagazineLink()
	{
		document.location.href = '/YouMagazine.html';
	}
	
	function fnSetShopLink()
	{
		document.location.href = '/Shop.html';
	}

