/*
Programmer: Darryl Ballard
Created: 2008-01-08
Last Modified: 2008-01-08
Version: 1.0

Version History:
*/

function activatePopupLinks()
{
	var tags;
	var k, m;
	var classes;
	var str;
	var popup_width, popup_height;
	var params;
	
	tags = document.getElementsByTagName('a');
	
	if( tags )
	{
		for(k = 0; k < tags.length; k++)
		{
			// Look for the gst_popup class in the classes on the link
			classes = tags[k].className.split(' ');
			for(m = 0; m < classes.length; m++)
			{
				if( classes[m].substr(0, 9) == "gst_popup" )
				{
					// Check for provided dimensions
					popup_width = -1;
					popup_height = -1;
					if( classes[m].length > 9 )
					{
						params = classes[m].split('_');
						
						popup_width = params[2];
						popup_height = params[3];
					}
					
					// Build the onclick function
					str = "window.open('" + tags[k].href + "', 'popupWindow', 'scrollbars=yes";
					if( popup_width > -1 && popup_height > -1 )
					{
						str += ", width=" + popup_width + ", height=" + popup_height;
					}
					str += "');";
					str += "return false;";
					
					// Assign the onclick function
					tags[k].onclick = new Function(str);
					
					break;
				}
			}
		}
	}
}

addLoadEvent(activatePopupLinks);
