﻿// JScript File
var isIE = false;
if (navigator.appName.indexOf("MSIE")!= -1)
	isIE = true;

function ShowHelp(element, helpNumber, targetElement) {
	var location = Sys.UI.DomElement.getLocation(element);
	var targetElement = Sys.UI.DomElement.getElementById(targetElement);
	targetElement.style.position = 'absolute';
	targetElement.style.zIndex = '300';
	targetElement.style.top = (location.y+10) + "px";
	targetElement.style.left = (location.x-220) + "px";
	targetElement.style.display = "block";

	helpContent.innerHTML = GetHelpText(helpNumber);
}

function HideHelp(targetElement) {
	var targetElement = Sys.UI.DomElement.getElementById(targetElement);
	targetElement.style.display = "none";
	helpContent.innerHTML = "";
}

function GetHelpText(helpNumber) {
	var text = "";
	try {
		text = helpTextArr[helpNumber];
	}catch(ex){}
	
	return text;
}

function ExpandDescription(anchor, i)
{
	CollapseDescriptions();
	var descriptionId = "description"+i;
	var targetElement = Sys.UI.DomElement.getElementById(descriptionId);
	targetElement.style.display = isIE ? 'block' : 'table-row';
	anchor.className = 'DescriptionAnchorSelected';
}

function CollapseDescriptions()
{
	for(var i = 0 ; i < 20; i++)
	{
		var descriptionId = "description"+i;
		var anchorId = "anchor"+i;
		var targetDescription = Sys.UI.DomElement.getElementById(descriptionId);
		var targetAnchor = Sys.UI.DomElement.getElementById(anchorId);
		try
		{
			targetDescription.style.display = 'none';
			targetAnchor.className = 'DescriptionAnchor';
		}
		catch(e)
		{
			//alert(e);
		}
	}
}


	var offImage = new Image();
	var onImage = new Image();
	
	offImage.src = "/_layouts/1030/FitnessDk/gfx/CenterTabOff.gif";
	onImage.src = "/_layouts/1030/FitnessDk/gfx/CenterTabOn.gif";

	function SwapTab(tabId)
	{
		document.getElementById("CenterContent1").style.display='none';
		document.getElementById("CenterContent2").style.display='none';
		document.getElementById("CenterContent3").style.display='none';

		document.getElementById("CenterTab1").style.backgroundImage = 'url(' + offImage.src + ')';
		document.getElementById("CenterTab2").style.backgroundImage = 'url(' + offImage.src + ')';
		document.getElementById("CenterTab3").style.backgroundImage = 'url(' + offImage.src + ')';
		
		document.getElementById("CenterTab1").style.color = 'Black';
		document.getElementById("CenterTab2").style.color = 'Black';
		document.getElementById("CenterTab3").style.color = 'Black';
		
		switch(tabId)
		{
			case "CenterTab1":
				document.getElementById("CenterContent1").style.display='block';
				document.getElementById("CenterTab1").style.backgroundImage = 'url(' + onImage.src + ')';
				document.getElementById("CenterTab1").style.color = "White";
				break;
			case "CenterTab2":
				document.getElementById("CenterContent2").style.display='block';
				document.getElementById("CenterTab2").style.backgroundImage = 'url(' + onImage.src + ')';
				document.getElementById("CenterTab2").style.color = "White";
				break;
			case "CenterTab3":
				document.getElementById("CenterContent3").style.display='block';
				document.getElementById("CenterTab3").style.backgroundImage = 'url(' + onImage.src + ')';
				document.getElementById("CenterTab3").style.color = "White";
				break;
		}
	}

	function getKeyPressedCode(e) {
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		else if (e.which) code = e.which;

		return code;
	}

	function showCenterButtonClick(dropDownListId) {

		var dropDown = document.getElementById(dropDownListId);
		if (dropDown != null) {
			if (dropDown.selectedIndex <= 0) // Defaults to 'Vælg center' or None selected
			{
				alert('Du skal vælge et center!');
				return false;
			}

			return true;
		}

		return false;
	}

	function OpenPopUp(aElement, width, height) {
		var url = aElement.href;
		var popup = window.open(url, 'popup', "width=" + width + ",height=" + height + ",location=0,status=0,scrollbars=1");
		if (popup == null)
			alert("Slå popup block fra, for at se popup");
		else
			popup.focus();
	}

	function SetOverlayBox(idUser, idPass) {
		document.getElementById(idUser).value = "Medlemsnummer";
		document.getElementById("accessCode_Hidden").style.display = "";
		document.getElementById(idPass).style.display = "none";
		//$("#accessCode_Hidden").attr({ display: '' });

	}

	function SetOverlayBoxPass(idPass) {
		document.getElementById("accessCode_Hidden").style.display = "";
		document.getElementById(idPass).style.display = "none";
		//$("#accessCode_Hidden").attr({ display: '' });

	}

	function RemoveOverlayBox(id) {
		document.getElementById("accessCode_Hidden").style.display = "none";
		document.getElementById(id).style.display = "";
		document.getElementById(id).focus();
//		$("#accessCode_Hidden").attr({ display: 'none' });
//		$("#" + id).blur();
	}


	var gAutoPrint = true; 	// Flag for whether or not to automatically call the print function

	function printSpecial() {
		if (document.getElementById != null) {
			var html = '<HTML>\n<HEAD>\n';

			/*if (document.getElementsByTagName != null)
			{
			var headTags = document.getElementsByTagName("head");
			if (headTags.length > 0)
			{
			html += headTags[0].innerHTML;
			}
			}*/

			html += '<link rel="StyleSheet" href="/_layouts/1030/fitnessdk/styles/print.css?timestamp=' + (new Date().getTime()) + '" type="text/css">\n';

			html += '\n</HEAD>\n<BODY style="background-image: none; background-color:white;">\n';
			var printReadyElem = document.getElementById("printReady");

			if (printReadyElem != null) {
				html += '<!-- ********************** PRINT-START *********************-->\n';
				html += '<table style="width:100%;">\n<tr>\n<td>\n' + printReadyElem.innerHTML + '\n</td>\n</tr>\n</table>\n';
				html += '<!-- ********************** PRINT-SLUT **********************-->\n';
			}
			else {
				alert("Could not find the printReady section in the HTML");
				return;
			}

			html += '\n</BODY>\n</HTML>';

			var printWin = window.open("", "printSpecial", "width=506,height=600,resizable=no,top=50,left=50");
			if (printWin != null) {
				printWin.document.open();
				printWin.document.write(html);
				printWin.document.close();
				if (gAutoPrint) {
					printWin.print();
					printWin.close();
				}
			}
		}
		else {
			alert("Sorry, the print ready feature is only available in modern browsers.");
		}
	}

	function printSpecial2() {
		if (document.getElementById != null) {
			var html = '<HTML>\n<HEAD>\n';

			if (document.getElementsByTagName != null) {
				var headTags = document.getElementsByTagName("head");
				if (headTags.length > 0) {
					//html += headTags[0].innerHTML;
				}
			}

			html += '<link rel="StyleSheet" href="/_layouts/1030/fitnessdk/styles/print.css?timestamp=' + (new Date().getTime()) + '" type="text/css">\n';
			//html += '<link rel="StyleSheet" href="/_layouts/1030/fdb/styles/additionalLayout.css" type="text/css">\n';
			//html += '<link rel="StyleSheet" href="/_layouts/1030/fdb/styles/print.css" type="text/css">\n';
			html += '\n</HEAD>\n<BODY>\n';
			var printReadyElem = document.getElementById("printReady");
			if (printReadyElem != null) {
				html += '<!-- ********************** PRINT-START *********************-->\n';
				html += '<table>\n<tr>\n<td>\n' + printReadyElem.innerHTML + '\n</td>\n</tr>\n</table>\n';
				html += '<!-- ********************** PRINT-SLUT **********************-->\n';
			}
			else {
				alert("Could not find the printReady section in the HTML");
				return;
			}

			html += '\n</BODY>\n</HTML>';

			var printWin = window.open("", "printSpecial", "width=960,height=600,resizable=no,top=50,left=50");
			printWin.document.open();
			printWin.document.write(html);
			printWin.document.close();
			//		if (gAutoPrint)
			//			printWin.print();
			//			printWin.close();
		}
		else {
			alert("Sorry, the print ready feature is only available in modern browsers.");
		}
	}

