﻿function showFullscreen(url) {
	height = screen.availHeight;
	width = screen.availWidth;

	// Windows 2k fix
	if (navigator.userAgent.indexOf('Windows NT 5.0') != -1) {
		height = height - 20;
		width = width - 10;
	}

	try {
		tmp = window.open(url, 'tmp', "height=" + height + "px,width=" + width + "px,top=0,left=0,location=0,menubar=0,resizable=0,scrollbars=0,toolbar=0");
		tmp.resizeTo(width, height);
	}
	catch (e) { ; }
}

function showNormal(url) {
	try {
		tmp = window.open(url, '', "height=" + screen.availHeight + "px,width=" + screen.availWidth + "px,top=0,left=0,location=1,menubar=1,resizable=1,scrollbars=1,toolbar=1");
		tmp.resizeTo(screen.availWidth, screen.availHeight);
	}
	catch (e) { ; }
}

function maximizeCurrentWindow() {
	try {
		top.window.moveTo(0, 0);

		if (document.all) {
			var newWidth = screen.availWidth;
			var newHeight = screen.availHeight;

			top.window.resizeTo(newWidth, newHeight);

			shouldRemove = false;
			if (window.screenTop < 0) {
				newHeight = screen.availHeight - window.screenTop;
				shouldRemove = true;
			}

			if (window.screenLeft < 0) {
				newWidth = screen.availWidth - window.screenLeft;
				shouldRemove = true;
			}

			if (shouldRemove) {
				top.window.resizeTo(newWidth, newHeight);
				top.window.moveTo(0, 0)
			}
		}
		else if (document.layers || document.getElementById) {
			if (top.window.outerHeight < screen.availHeight || top.window.outerWidth < screen.availWidth) {
				top.window.outerHeight = screen.availHeight;
				top.window.outerWidth = screen.availWidth;
			}
		}
	}
	catch (e) { }
}

function ipaperClose() {
	if (parent)
		parent.close();
	else
		window.close();
}

function getFlashVersion() {
	var flashversion = 0;

	try {
		if (navigator.plugins && navigator.mimeTypes.length) {
			var x = navigator.plugins["Shockwave Flash"];

			if (x && x.description)
				flashversion = x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".");
		}
		else if (window.ActiveXObject) {
			try {
				var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
				flashversion = axo.GetVariable("$version").split(" ")[1].split(",");
			}
			catch (e) { }
		}
	}
	catch (e) { }

	return flashversion;
}

// Get value from clientside key value pairs
function getHashValue(key) {
	if (!window.location.hash)
		return undefined;

	var dictionary = getHashKeyValuePairs();
	return dictionary[key];
}

// Set value for clientside key value pairs
function setHashValue(key, value) {
	var dictionary = getHashKeyValuePairs();
	dictionary[key] = value;

	var hash = new Array();
	for (var dkey in dictionary)
		hash.push(dkey + "=" + dictionary[dkey]);

	window.location.hash = hash.join('&');
}

// Get collection of clientside key value pairs
function getHashKeyValuePairs() {
	var dictinary = new Object();

	var pairs = window.location.hash.substring(1).split('&');
	for (var pair in pairs) {
		if (pairs[pair] != '') {
			var keyvalue = pairs[pair].split('=');
			dictinary[keyvalue[0]] = keyvalue[1];
		}
	}

	return dictinary;
}

//
function getQueryValue(key) {
	return $.jqURL.get(key);
}
