function generatePDFURL()
{
	var url = location.href;
	
	if(url.indexOf("#") > 0)
	{
		url = url.substr(0,url.indexOf("#"));
	}
	
	if(url.indexOf("?") == -1)
	{
		url += "?pdf";
	}
	else
	{
		url += "&pdf";
	}
	console.log(url);
	return url;
}

/* 
* @author oliverh@qualtrics.com
*
* this is the global dashboard class 
* there should be no javascript variables, classes, or functions outside of this. 
*/

var Dashboard = {
	/**
	* Dashboard.imageMapHighlighter
	* @{node} map - the area map node that contains the areas you want highlighted
	* @{String} opt_target - (optional) an iframe that you want to use to present the result of the click. 
	*/
	imageMapHighlighter:function(map, opt_target)
	{
		Event.observe(map, 'mouseover', Dashboard.getHighlightMouseOverClosure(opt_target))
	},
	getHighlightMouseOverClosure:function(opt_target)
	{
		return function(evt)
		{
			Dashboard.highlightImageMapArea(evt, opt_target)
		}
	},
	/**
	* Dashboard.highlightArea
	* @{event} evt - the area map node that contains the areas you want highlighted
	*/
	highlightImageMapArea:function(evt, opt_target)
	{
		if(!evt) evt = window.event;
		var clicked = Event.element(evt);
		if(clicked.nodeName == 'AREA')
		{
			var coords = clicked.getAttribute('coords');
			coords = coords && coords.split(',');
			if(coords)
			{
				var height = coords[3]-coords[1];
				var width = coords[2]-coords[0];
				Dashboard.removeHighlight();
				Dashboard.createHighlight(coords[0], coords[1], height, width, clicked, opt_target)
			}
		}
	},
	/**
	* Dashboard.areaHighlightNode
	* this keeps track of whats highlighted so we can remove it
	*/
	areaHighlightNode:null,
	/**
	* Dashboard.createHighlight
	* creates the highlight and puts it on the page. 
	* @param {Number} x -left
	* @param {Number} y - top
	* @param {Number} height - the height
	* @param {Number} width - the width
	* @param {Node} opt_areaNode - the area node that triggered the. this is used to recreate the areas action. 
	*/
	createHighlight:function(x, y, height, width, opt_areaNode, opt_target)
	{
		var h = QBuilder('div', {className:'AreaOverHighlight'});
		$(h).setStyle({
			position:'absolute',
			left:x+'px',
			top:y+'px',
			height:height+'px',
			width:width+'px'
		});
		h.title = opt_areaNode.title;
		
		h.onclick = Dashboard.getHighlightClickClosure(opt_areaNode, opt_target);
		Dashboard.areaHighlightNode = h;
		document.body.appendChild(h);
		
	},
	/**
	* Dashboard.removeHighlight
	* removes the highlight if it exists
	*/
	removeHighlight:function()
	{
		if(Dashboard.areaHighlightNode)
		{
			removeElement(Dashboard.areaHighlightNode);
		}
	},
	/**
	* Dashboard.getHighlightClickClosure
	* returns the function that runs when you click the highlight
	* @param {Node} areaNode - the area node represented by highlight. this is used to recreate the areas action. 
	* @return {function} the click function for the highlight. 
	*/
	getHighlightClickClosure:function(areaNode, opt_target)
	{
		return function(evt)
		{
			Dashboard.highlightClick(areaNode, opt_target);
		}
	},
	/**
	* Dashboard.highlightClick
	* the function that runs when you click the highlight
	* @param {Node} areaNode - the area node represented by highlight. this is used to recreate the areas action. 
	*/
	highlightClick:function(areaNode, opt_target)
	{
		if(opt_target && parent.frames[opt_target])
		{
			//make sure there is room to scroll before its loaded
			parent.frames[opt_target].height = 600;
			parent.frames[opt_target].location.href = areaNode.href;
			
			var anchor = (parent.$(opt_target))
			new parent.Effect.ScrollTo(anchor, parent, {duration:0.5, offset:-50});
		}
		else
		{
			//cant resolve the target so just reload the self. 
			window.location.href = areaNode.href;
		}
	},
	autoSizeIframe:function()
	{
		window.frameElement.height = window.document.height;
		window.frameElement.width = window.document.width;
	}
}	

Effect.ScrollTo = function(element, scope) {
  var options = arguments[2] || { },
    scrollOffsets = document.viewport.getScrollOffsets(),
    elementOffsets = $(element).cumulativeOffset(),
    max = (scope.window.outerHeight || scope.document.body.scrollHeight) - scope.document.viewport.getHeight();  
	
	max = scope.document.viewport.getHeight();//added this line to make it work with iframes
  if (options.offset) elementOffsets[1] += options.offset;	
  return new Effect.Tween(null, scrollOffsets.top, elementOffsets[1] > max ? max : elementOffsets[1], options,
    function(p){ 
    	scrollTo(scrollOffsets.left, p.round()) 
    }
  );
};
