﻿clock = function() {
	if (document.getElementById) {
		var digital = new Date();
		var MESZ = digital.getTime();// - (-digital.getTimezoneOffset() * 60 * 1000) + 1 * (60 * 60 * 1000);
		digital = new Date();
		digital.setTime(MESZ);
		
		var hours = digital.getHours();
		var minutes = digital.getMinutes();
		var seconds = digital.getSeconds();
		if (minutes <= 9) minutes = "0" + minutes;
		if (seconds <= 9) seconds = "0" + seconds;
		var timeSeparator = Sys.CultureInfo.CurrentCulture.dateTimeFormat.TimeSeparator;
		dispTime = hours + timeSeparator + minutes + timeSeparator + seconds;
		var myClock = document.getElementById('liveClock');
		myClock.innerHTML = dispTime;
		setTimeout("clock()", 1000);
	}
}
ieMenu = function(list) {
	if (document.all && document.getElementById) {
		var navRoot = document.getElementById(list);

		navRoot.onmouseover = function() {
			ieSelectBug(true);
		}
		navRoot.onmouseout = function() {
			ieSelectBug(false);
		}

		for (i=0; i < navRoot.childNodes.length; i++) {
			var node = navRoot.childNodes[i];

			if (node.tagName == "LI") {

				node.onmouseover = function() {
					this.className += " hover";
					
					var node = this;
					var subBlock = node.getElementsByTagName('ul')[0];
					var li_nodes = subBlock.getElementsByTagName('li');
					
					if(subBlock.offsetWidth < 99) subBlock.style.width = '99px';

					var longestBlock = 0;
					
					for(var j = 0; j < li_nodes.length; j++){
						longestBlock = (li_nodes[j].offsetWidth > longestBlock) ? li_nodes[j].offsetWidth : longestBlock;
					}
			
					for(var j = 0; j < li_nodes.length; j++){
						//-20 gleicht padding aus
						li_nodes[j].getElementsByTagName('a')[0].style.width = longestBlock - 20 + 'px';
					}
				}

				node.onmouseout = function() {
					this.className = this.className.replace(" hover", "");
				}
			}
		}
	}
}

ieSelectBug = function(active) {
	var selectBugOuterDiv = document.getElementById("selectBugOuterDiv");
	var selectBugInnerDiv = document.getElementById("selectBugInnerDiv");

	if (!selectBugOuterDiv || !selectBugInnerDiv)
		return;

	if (active) {
		selectBugOuterDiv.style.height = selectBugOuterDiv.offsetHeight;
		selectBugOuterDiv.filters["revealTrans"].apply();
		selectBugInnerDiv.style.display = "none";
	}
	else {
		selectBugInnerDiv.style.display = "block";
		selectBugOuterDiv.filters["revealTrans"].play();
	}
}

function EndRequestHandler(sender, args) {
	if (args.get_error() != undefined)
		args.set_errorHandled(true);
}


var globalAjaxInvertvalPostBackID;
function disableAjaxPostBackInterval()
{
	if (typeof globalAjaxInvertvalPostBackID == 'number')
		window.clearInterval(globalAjaxInvertvalPostBackID);
}

/* --- RAD Edtior Scripts - START ---- */

var globalRADEditArray = new Array();

function ClientInitRADEdtior(editor, commandName, oTool)
{	
	var s = '"' + editor.ContentHiddenTextarea.id + '"';
	globalRADEditArray[ s ] = editor;
}

function insertRADEditor_SelectLink( radEditorID, textBoxID, listID )
{
	var listElement = document.getElementById( listID );
	var link = listElement.options[ listElement.selectedIndex ].value;
	var text = document.getElementById( textBoxID ).value;
	if( text.length > 1 )
		insertRADEditor( radEditorID, '<a class="inlineTextLink" href="' + link + '">' + text + '</a>' );
	else
		alert( "Please enter a text" );
}

function insertRADEditor( radEditorID, htmlContent )
{
	var s = '"' + radEditorID + '"';

	editor = globalRADEditArray[ '"' + radEditorID + '"'  ];
	editor.PasteHtml( htmlContent );
}
	
/* --- RAD Edtior Scripts - END ---- */


var pushChartFunctions = new Array();

// function for lightstreamer to get the correct timestamp to update push chart
function getCurrentTimestamp()
{
		var current = new Date();
		var year = current.getFullYear();
		var month = current.getMonth() + 1;
		var day = current.getDate();
		var hours = current.getHours();
		var minutes = current.getMinutes();
		var seconds = current.getSeconds();

		if (month < 10) month = "0" + month;
		if (day < 10) day = "0" + day;
		if (hours < 10) hours = "0" + hours;
		if (minutes < 10) minutes = "0" + minutes;
		if (seconds < 10) seconds = "0" + seconds;

		return '' + year + month + day + hours + minutes + seconds;
}
