// 2004 (c) Jegor Tsihnjajev
// All rights reserved
// jegor.tsihnjajev@gmx.net

var thisPage = '01';
var searchKeyword = '';

// Browser Detection
var browserVersion;
var browserType;
var ns6 = !document.all&&document.getElementById&&navigator.userAgent.toLowerCase().indexOf('netscape')>0?1:0;
var opera = document.all&&navigator.userAgent.toLowerCase().indexOf('opera')>0?1:0;
var ie = document.all?1:0;
var ns4 = document.layers?1:0;
var dom = document.getElementById&&navigator.userAgent.toLowerCase().indexOf('netscape')<0?1:0;
if (ns6) {
	var ns6Skip = navigator.userAgent.toLowerCase().indexOf('netscape');
	browserVersion = navigator.userAgent.toLowerCase().substring(ns6Skip + 9);
	browserType = 'ns6';
} else if (opera) {
	var operaSkip = navigator.userAgent.toLowerCase().indexOf('opera');
	var versSkip = navigator.userAgent.toLowerCase().indexOf(' ', operaSkip + 6);
	browserVersion = navigator.userAgent.toLowerCase().substring(operaSkip + 6, versSkip);
	browserType = 'opera';
} else if (ie) {
	var ieSkip = navigator.userAgent.toLowerCase().indexOf('msie');
	var versSkip = navigator.userAgent.toLowerCase().indexOf(';', ieSkip + 5);
	browserVersion = navigator.userAgent.toLowerCase().substring(ieSkip + 5, versSkip);
	browserType = 'ie';
} else if (ns4) {
	browserVersion = parseFloat(navigator.appVersion);
	browserType = 'ns4';
} else if (dom) browserType = 'dom';

// popup
function openPopup (path) {
	if (path) {
		window.open (path, 'popup', 'width=542, height=718');
	}
}

// print
function printContent() {
	frames.content.focus();
	frames.content.print();
}

// search
function searchItem() {
	if (searchKeyword = prompt('Bitte geben Sie den Suchbegriff an!')) {
		if (searchKeyword != '') frames['content'].location.href = 'search.html';
		else alert('Bitte geben Sie den Suchbegriff an!');
	}
}

// roll over effect
function doRollOver (imgOrd, actName) {
	if (!ns4) document.getElementById('menu_element_' + imgOrd).src = 'img/menu_element_' + imgOrd + '_' + actName + '.jpg'
}

// loads content page and switches button color
function switchPage (pageNumber) {
	thisPage = pageNumber;
	if (!ns4 && pageNumber) {
		frames['content'].location.href = pageNumber + '.html';
		for (var i = 1; i <= 6; i++) document.getElementById('menu_element_0' + i).src = 'img/menu_element_0' + i + '_off.jpg';
	}
}

// clocky
function getClock() {
	if (!ns4) {
		var digital = new Date();
		var hours = digital.getHours();
		var minutes = digital.getMinutes();
		var date = digital.getDate();
		var month = digital.getMonth() + 1;
		var year = digital.getYear();

		if (hours == 0) hours = 12;
		if (hours <= 9) hours = '0' + hours;
		if (minutes <= 9) minutes = '0' + minutes;
		if (date <= 9) date = '0' + date;
		if (month <= 9) month = '0' + month;
	
		dispTime = date + '/' + month + '/' + year + ' ' + hours + ':' + minutes;
		document.getElementById('clock').innerHTML = dispTime;
		setTimeout('getClock()', 10000);
	}
}

// locks status bar for ie and updates button color
function loopingFunctions () {
	if (!ns4) {
		if (document.getElementById('menu_element_' + thisPage).src != 'img/menu_element_' + thisPage + '_on.jpg') {
			document.getElementById('menu_element_' + thisPage).src = 'img/menu_element_' + thisPage + '_on.jpg';
		}
	}
	if (ie) window.status = 'Prüwer Ingenieurbüro';
	setTimeout('loopingFunctions()', 0);
}