/////////////// browser detection //////////////////////

var agt=navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_ie     = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3    = (is_ie && (is_major < 4));
var is_ie4    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")==-1) );
var is_ie5    = (is_ie && (is_major == 4) && (agt.indexOf("msie 5")!=-1) );

var MAC = navigator.platform.indexOf("Mac") != -1;

/////////////// init //////////////////////
var initOk = false; // main variable to enable functions

function init() {

	// initialize main functions
	initOk = true;
	
}


//////////////////////////// common functions ////////////////////////////////////


// open a window with a specific size
function openWin(url,winName,wW,wH,opts) {

	if(!opts) opts = "toolbar=1,location=1,directories=0,status=1,menuBar=1,resizable=1,scrollBars=1";
			
	if (wW && wH) {
		sW = screen.availWidth;
		sH = screen.availHeight;
		wW = parseInt(wW) + 20; // add marginright
		wH = parseInt(wH) + 30; // add marginbottom
		
		// compare the req. window size with screen size (minus margin of 20 px).
		sbW=0;
		sbH=0;
	
		if (sW < wW-60) { // screen-width is smaller than requested window-width
			wW = sW - 60; // set window-width to screen-width minus a small tolerance-margin
			sbH = 40; // window is smaller than requested, so most likely a  vertical scrollbar will appear, add space for it to height
		}
	
		if (sH < wH-60) { // screen-height is smaller than requested window-height
			wH = sH - 60; // set window-height to screen-height minus a small tolerance-margin
			sbW = 40; // window is smaller than requested, so most likely a  vertical scrollbar will appear, add space for it to width;
		}
		
		// if window is smaller than requested show scrollbars
		// if (sbW || sbH) opts = opts + ",scrollBars=1";
		// else opts = opts + ",scrollBars=0";
		
		// add scrollbars to width and height if they appear
		wW = wW+sbW;
		wH = wH+sbH;
		wleft = ((screen.width-wW)/2)-15;
		wtop = ((screen.height-wH)/2)-15;
		opts = "width="+wW+",height="+wH+",left="+wleft+",top="+wtop+opts;
	}

	var win = window.open(url,"_blank",opts); // use this if you want a special window look
	if (parseInt(navigator.appVersion) >= 4) win.window.focus();
	
}	


//// form functions ////

function seaFieldClear(aField) {
	if(aField.value == "Suche") {
		aField.value = "";
	}
}
	

function seaFormCheck(aForm) {
	
	/* temporary 
	alert('Diese Funktion steht in Kürze zur Verfügung!');
	return false;
	/* temporary */
	
	
	var seaWord = aForm.seaWord.value;
	if (aForm) {
		if (seaWord.length == 0) {
			alert(seaNoChars);
			return false;
		}	else if (seaWord.length < 3) {
			alert(seaFewChars);
			return false;
		}
	} else {
		alert("Es ist ein Problem beim Überprüfen des Formulars aufgetreten.\nBitte informieren Sie ar@aspekt1.net.\n\nAn error occured while checking the form.\nPlease inform ar@aspekt1.net.");
		return false;
	}
	aForm.submit();
	return true;
}

//                                                                              
// horizontal banner functions                                                     
//                                                                              

// what document model does the browser use?
if (document.getElementById) var dById = true;
else if (document.all) var dAll = true;
function getObj(name) {
	if (dById && document.getElementById(name)) el = document.getElementById(name);
	else if (dAll && document.all[name]) el = document.all[name];
	else el = false;
	return el;
}

// get the viewport width and height
function xy() {
	var x,y;
	// all except Explorer
	if (self.innerHeight)
	{
		x = self.innerWidth;
		y = self.innerHeight;
	}
	// Explorer 6 Strict Mode
	else if (document.documentElement && document.documentElement.clientHeight)
	{
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	// other Explorers
	else if (document.body)
	{
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
	var vals = new Array();
	vals[0] = x;
	vals[1] = y;
	return vals;
}

function drawBanner() {
	var bd = getObj('bannerDiv');
	var bf = getObj('bannerIFrame');
	if (bf) {
		var vals = xy();
		// position the banner
		bd.style.width = '100%';
		if (self.innerHeight)	{	bd.style.top = vals[1]-113+'px'; } // all except Explorer have scrollbars inside the window
		else bd.style.top = vals[1]-100+'px'; // explorer has scrollbars outside
		bd.style.left = 0;
		// detect scroll
		if (window.innerHeight)
		{
			  pos = window.pageYOffset;
		}
		else if (document.documentElement && document.documentElement.scrollTop)
		{
			pos = document.documentElement.scrollTop
		}
		else if (document.body)
		{
			  pos = document.body.scrollTop
		}
		if (pos < 1) {
			bd.style.display = '';
			bd.style.visibility = 'visible';
		}
		else {
			bd.style.display = "none";
			bd.style.visibility = "hidden";
		}
		temp = setTimeout('drawBanner()', 333);
	}
}