function KeyUpCheck() {
	// Run only in IE
	if ((document.all) && (76==event.keyCode) && (event.ctrlKey) && (event.altKey)) {
		window.status = "Opening login dialog...";
		ShowLogin();
		window.status = "";
		return false;
	}
}

function galleryPopUp(resourceId, galleryId) {
	window.open("/PictureViewer.aspx?imageid=" + resourceId + "&gid=" + galleryId, "", "width=500,height=500,scrollbars=no,resizable=no,status=no");
}

function printNewsPopUp(newsId) {
	window.open("NewsPrint.aspx?newsid=" + newsId, "", "width=500,height=500,scrollbars=yes,resizable=no,status=no");
}

//specify speed of scroll (greater=faster)
var speed=2
var crossobj; 
var contentheight;


function FaqShowItem(moduleId, item)
{
	var i = 1;
	var currentDispay = document.getElementById('faqItem_' + moduleId + "_" + item).style.display;
	
	while(eval("document.getElementById('faqItem_" + moduleId + "_" + i + "')"))
	{
		eval("document.getElementById('faqItem_" + moduleId + "_" + i + "').style.display = 'none'");
		eval("document.getElementById('bullit_" + moduleId + "_" + i + "').src = 'gfx/siteSpecific/faq_arrow_green_right.gif'");
		eval("document.getElementById('header_" + moduleId + "_" + i + "').style.color = '#636467'");
		i++;
	}
	if(currentDispay == "none")
	{
		eval("document.getElementById('faqItem_" + moduleId + "_" + item + "').style.display = 'block'");
		eval("document.getElementById('bullit_" + moduleId + "_" + item + "').src = 'gfx/siteSpecific/faq_arrow_green_down.gif'");
		eval("document.getElementById('header_" + moduleId + "_" + item + "').style.color = '#D41F23'");
	}
	else
	{

		eval("document.getElementById('faqItem_" + moduleId + "_" + item + "').style.display = 'none'");
		eval("document.getElementById('bullit_" + moduleId + "_" + item + "').src = 'gfx/siteSpecific/faq_arrow_green_right.gif'");
		eval("document.getElementById('header_" + moduleId + "_" + item + "').style.color = '#636467'");
	}
}

function email()
{
	location.href = "mailto:larslinde@gmail.com?subject=Maersk EDU&body=" + document.URL;
	return false;
}

function popup(width, height, closeLink, imageLink)
{
	
	var doc = window.open("resources/popup.htm", 'doc', "width=" + width + ", height=" + height + ", scrollbars=no");
	doc.document.write("<html><head><title></title><link rel='stylesheet' href='" + baseAppPath + "resources/styles.css'></head><body><img src='" + imageLink + "' border='0'><br>" + (closeLink == true ? "<div align='center'><a href='javascript: window.close();'>Close window</a></div>" : "") + "</body></html>");
}

function URLEncode( decoded )
{
	// The Javascript escape and unescape functions do not correspond
	// with what browsers actually do...
	var SAFECHARS = "0123456789" +					// Numeric
					"ABCDEFGHIJKLMNOPQRSTUVWXYZ" +	// Alphabetic
					"abcdefghijklmnopqrstuvwxyz" +
					"-_.!~*'()/";					// RFC2396 Mark characters
	var HEX = "0123456789ABCDEF";

	var plaintext = decoded;
	var encoded = "";
	for (var i = 0; i < plaintext.length; i++ ) {
		var ch = plaintext.charAt(i);
	    if (ch == " ") {
		    encoded += "+";				// x-www-urlencoded, rather than %20
		} else if (SAFECHARS.indexOf(ch) != -1) {
		    encoded += ch;
		} else {
		    var charCode = ch.charCodeAt(0);
			if (charCode > 255) {
			    alert( "Unicode Character '" 
                        + ch 
                        + "' cannot be encoded using standard URL encoding.\n" +
				          "(URL encoding only supports 8-bit characters.)\n" +
						  "A space (+) will be substituted." );
				encoded += "+";
			} else {
				encoded += "%";
				encoded += HEX.charAt((charCode >> 4) & 0xF);
				encoded += HEX.charAt(charCode & 0xF);
			}
		}
	} // for
	return encoded;
};

function URLDecode( encoded)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
	   var ch = encoded.charAt(i);
	   if (ch == "+") {
		   plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   return plaintext;
};

function getRealTop(el) {
	var count = 0;
	var yPos = el.offsetTop;
	var tempEl = el.offsetParent;
	while (tempEl != null) {
		yPos += tempEl.offsetTop;
		tempEl = tempEl.offsetParent;
		if (!document.all && count == 0)
			yPos = 43;
		count ++;
	}
	return yPos;
}

function getRealLeft(el) {
	xPos = el.offsetLeft;
	tempEl = el.offsetParent;
	while (tempEl != null) {
		xPos += tempEl.offsetLeft;
		tempEl = tempEl.offsetParent;
	}
	return xPos;
}
	
function ShowLogin() {
	var o = new Object();
	o.retval = false;
	window.showModalDialog("/modals/modal_login.aspx",o,"dialogHeight: 220px; dialogWidth: 300px; edge: Raised; center: Yes; help: no; resizable: No; status: No;");
	if (o.retval) {
	    var rediretTo = location.href + '?redirectAtLogin=true';
	    setTimeout('location.href =\'' + rediretTo + '\'', 50);
	}
	
}