// BEGIN: PINT_AnchorPopupWindows ================================================================================
// TargetLink, WindowName, Attributes
function popupWindow() { 
	if (popupWindow.arguments.length < 1) return false;

    var popupWin = null; 
    popupWin = window.open(popupWindow.arguments[0],popupWindow.arguments[1],popupWindow.arguments[2]);  
}

function PINT_GetWindowSize(style) {
	var size = 400;
	if (style == "width")
		{
		//Non-IE
		if( typeof( window.innerWidth ) == 'number' ) 
			size = window.innerWidth;
		//IE 6+ in 'standards compliant mode'			
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
			size = document.documentElement.clientWidth;
		//IE 4 compatible			
		else if( document.body && document.body.clientWidth ) 
			size = document.body.clientWidth;
		}
	else if (style == "height")
		{
		//Non-IE
		if( typeof( window.innerWidth ) == 'number' )
			size = window.innerHeight;
		//IE 6+ in 'standards compliant mode'						
		else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) 
			size = document.documentElement.clientHeight;
		//IE 4 compatible
		else if( document.body && document.body.clientHeight ) 
			size = document.body.clientHeight;
		}
			
	return size;
}

function PINT_AnchorPopupWindows() 
	{ 
    if(!document.getElementsByTagName) return; 
	
	var anchors = PINT_Global.HTML.anchors;
	var currentAnchor;

	for (var anchorIndex = 0; anchorIndex < anchors.length; anchorIndex++)
		{
		var targetLink, relArray, relInformation, windowAttributes, javascriptTargetLink, windowName;
		var location, menubar, resizable, scrollbars, status, toolbar
		var width, height, windowType, windowName;
		currentAnchor = anchors[anchorIndex];
		targetLink = currentAnchor.getAttribute("href"); 
        relInformation = currentAnchor.getAttribute("rel"); 
        
		if (relInformation && targetLink)	
			{
			relArray = relInformation.split("|");
			// Make sure there are at least 4 parameters
			if (relArray[0] == "popup" && relArray.length >= 4)
				{
				if (relArray[1] != "null")
					width = parseInt(relArray[1]) ? parseInt(relArray[1]) : 400;
				else
					width = PINT_GetWindowSize("width");
					
				if (relArray[2] != "null")
					height = parseInt(relArray[2]) ? parseInt(relArray[2]) : 400;
				else
					height = PINT_GetWindowSize("height");

				windowType = relArray[3];

				windowAttributes = "width=" + width + ",height=" + height; 
				if (windowType == "custom")
					{
					// IF custom window type
					if (relArray.length < 10) return false;
					location = parseInt(relArray[4]) ? parseInt(relArray[4]): 0;
					menubar = parseInt(relArray[5]) ? parseInt(relArray[5]): 0;
					resizable = parseInt(relArray[6]) ? parseInt(relArray[6]): 0;
					scrollbars = parseInt(relArray[7]) ? parseInt(relArray[7]): 0;
					status = parseInt(relArray[8]) ? parseInt(relArray[8]): 0;
					toolbar = parseInt(relArray[9]) ? parseInt(relArray[9]): 0;
					
					// Determine Window name
					if (relArray.length == 11) windowName = relArray[10];
					else windowName = "popupWindow";								

					// Set attributes						
					windowAttributes += ",location="+ location +",menubar=" + menubar +",resizable=" + resizable + ",scrollbars=" + scrollbars + ",status=" + status + ",toolbar="+ toolbar;
					}
				else 
					{
					// Defined Window Type

					// Determine Window name
					if (relArray.length == 5) windowName = relArray[4];
					else windowName = "popupWindow";				

					// Determine attributes
					if (windowType == "standard") windowAttributes += ",location=0,menubar=0,resizable=0,scrollbars=0,status=0,toolbar=0";
					else if (windowType == "resize") windowAttributes += ",location=0,menubar=0,resizable=1,scrollbars=0,status=0,toolbar=0";
					else if (windowType == "scrollbar") windowAttributes += ",location=0,menubar=0,resizable=0,scrollbars=1,status=0,toolbar=0";
					else if (windowType == "blank") windowAttributes = "";					
					else return false; 
					}

				javascriptTargetLink = "javascript:popupWindow('" + targetLink + "','" + windowName + "','" + windowAttributes + "');"; 
				currentAnchor.setAttribute("href", javascriptTargetLink); 
				}
			}
		}
    }
// END: PINT_AnchorPopupWindows ================================================================================
