/*
	===============================================================
	Thanks for your interest in the JavaScript source code

	Project: Dallmayr Microsite On Pack Promotion PopUp
	Author: Patrick Ording, p.ording@freakworks.de
	Agency: Freakworks Munich - http://www.freakworks.de/
	License: Copyright 2009, Freakworks, All Rights Reserved.
	Created: 26.01.2009
	Edited: 27.01.2009

	Feel free to read and learn from this, but please don't steal.
	===============================================================

	addPopUpLink
	opens all links with a certain class (launchpopupwin, launchpopupimpressum) in a pop-up window

	It�s always worth remembering that a visitor to the site might be using a browser that
	doesn�t have JavaScript support. Or maybe the browser supports JavaScript but it has been
	disabled.

	This JavaScript code was written in a proper way which means that the site will
	still be navigable by users who don�t have JavaScript. The site (popup functionality) degrades
	gracefully, meaning that the functionality may be reduced but it doesn�t fail completely.

	The problem lies with inline event handlers. Using an attribute like onclick in the markup is
	just as inefficient as using the style attribute. It's much better to use a hook, like class or id,
	to tether the behavior to the markup without intermingling it.

	This is what this Script does.

*/

function addPopUpLink()
{
	if(!document.getElementById || !document.createTextNode){return;}

	// Assets of the link - the class to find out which link should get the functionality
	var popupClass1='launchpopupwin';
	var popupClass2='launchpopupimpressum';

	var pop,t;
	var atags = document.getElementsByTagName('a');

	for(var i=0;i<atags.length;i++)
	{
		t=atags[i].className;
		if(t && t.toString().indexOf(popupClass1)!=-1)
		{
			atags[i].onclick=function()
			{
				pop=window.open(this.href,'popupwin','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=600,height=325,left=10,top=200');
				return false;
			}
		} else if (t && t.toString().indexOf(popupClass2)!=-1)
		{
			atags[i].onclick=function()
			{
				pop=window.open(this.href,'popupimpressum','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,width=490,height=470,left=10,top=200');
				return false;
			}
		}
	}
}

window.onload=addPopUpLink;
