/**
 * Actions
 *
 * @category   Module (image-set)
 * @author     Nico Wenig <nico.wenig@yellowgreen.de>
 * @version	   2010-06-15
 */



	// Create XML request
	var createXMLHttpRequest = function() {
	    var ua;
	    if(window.XMLHttpRequest) {
	    	try { ua = new XMLHttpRequest(); } catch(e) { ua = false; }
	    } else if(window.ActiveXObject) {
	    	try { ua = new ActiveXObject('Microsoft.XMLHTTP'); } catch(e) { ua = false; }
	    }
	    return ua;
	};
	
	// No cache for AJAX
	var noCache = function(uri) {
		return uri.concat(/\?/.test(uri) ? "&" : "?", "noCache=", (new Date).getTime(), ".", Math.random() * 1234567);
	};

	// Get resized dimensions
	var proportionalResize = function(width, height, maxWidth, maxHeight) {
		if(maxWidth > width) maxWidth = width;
		if(maxHeight > height) maxHeight = height;
		var ratio = Math.min(maxWidth / width, maxHeight / height);
		return [Math.round(ratio * width), Math.round(ratio * height)];
	};

	// Popup
    var imagesPopup = function(imageSRC) {
    	var imageFilename = imageSRC.substr(imageSRC.lastIndexOf('/') + 1);
    
    	if(typeof pagemapImages[imageFilename] != 'undefined') {
    		var popupHREF = popupPath + '?image=' + imageSRC;
    		var popupID = Math.round(1 + 1000 * (Math.random()));
    		var imageWidth = pagemapImages[imageFilename]['width'];
    		var imageHeight = pagemapImages[imageFilename]['height'];
    		
    		if(showImageProperties == 0) {
    			var dimensions = proportionalResize(imageWidth, imageHeight, screen.availWidth, screen.availHeight);
    			popupWidth = dimensions[0];
    			popupHeight = dimensions[1];
    		}
    	
    		var popupLeft = (screen.availWidth - popupWidth) / 2;
    		var popupTop = (screen.availHeight - popupHeight) / 2;
    	
    		var popupWindow = window.open(popupHREF, popupID, 'left=' + popupLeft + ', top=' + popupTop + ', width=' + popupWidth + ', height=' + popupHeight + ', resizable=no, scrollbars=yes');
    	}
    };