var isIE = document.compatMode && document.all;
var isIE5 = isIE && /msie 5\.0/i.test(navigator.userAgent);
var isOpera = /opera/i.test(navigator.userAgent);
var isKHtml = /Konqueror|Safari|KHTML/i.test(navigator.userAgent);

var disable = false;
var init = false;
String.prototype.trim = function() {
	return (this.replace(/\s+$/, "").replace(/^\s+/, ""));
}
Element
		.addMethods({
			selectedValue : function(e) {
				return e.options[e.selectedIndex].value;
			},
			setText : function(e, v) {
				if (e.firstChild)
					e.firstChild.nodeValue = v;
			},
			show : function(e, v) {
				e.style.display = v;
				return e;
			},
			removeChildren : function(e) {
				e.childElements().invoke('remove');
			},
			center : function(e) {
				var h = document.viewport.getHeight(), w = document.viewport
						.getWidth();
				// if (isIE && (browserVersion != undefined && browserVersion <
				// 7)) {
				// h = document.body.clientHeight; w =
				// document.body.clientWidth; }
				e.style.top = ((h - e.getHeight()) / 2) + 'px';
				e.style.left = ((w - e.getWidth()) / 2) + 'px';
				return e;
			},
			isRelated : function(e, ev) {
				var r = ev.relatedTarget;
				if (!r) {
					if (ev.type == 'mouseover')
						r = ev.fromElement;
					else if (ev.type == 'mouseout')
						r = event.toElement;
				}
				while (r) {
					if (r == e)
						return true;
					r = r.parentNode;
				}
				return false;
			},
			getAbsPos : function(e) {
				var scrollLeft = 0, scrollTop = 0;
				if (/^div$/i.test(e.tagName)) {
					scrollLeft = e.scrollLeft;
					scrollTop = e.scrollTop;
				}
				var r = {
					x : e.offsetLeft - scrollLeft,
					y : e.offsetTop - scrollTop
				};
				if (e.offsetParent) {
					var t = e.offsetParent.getAbsPos();
					r.x += t.x;
					r.y += t.y;
				}
				return r;
			},
			append : function(e, tag) {
				var t = $(document.createElement(tag));
				e.insert(t);
				return t;
			},
			switchClass : function(e, c, c2) {
				return e.removeClassName(c).addClassName(c2);
			}
		});
Element.addMethods('SELECT',
		{
			selectValue : function(e, v) {
				for ( var i = 0; i < e.options.length; i++)
					e.options[i].selected = e.options[i].value == v;
			},
			selectText : function(e, v) {
				for ( var i = 0; i < e.options.length; i++)
					e.options[i].selected = e.options[i].text == v;
			},
			selectedText : function(e) {
				return e.options[e.selectedIndex].text;
			},
			clear : function(e) {
				e.options.length = 1;
			},
			clearAll : function(e) {
				e.options.length = 0;
			},
			add : function(e, t, v, s, ds) {
				e.options[e.options.length] = new Option(t, v, ds || false,
						s || false);
			}
		});
Element.addMethods('TEXTAREA', {
	addLineHeight : function(e, v) {
		if (!v)
			v = 1;
		e.style.height = (e.getHeight() + e.getLineHeight() * v) + 'px';
	},
	removeLineHeight : function(e, v) {
		if (!v)
			v = 1;
		e.style.height = (e.getHeight() - e.getLineHeight() * v) + 'px';
	},
	getHeight : function(e) {
		return parseInt(e.style.height.substr(0, e.style.height.length - 2));
	},
	getLineHeight : function(e) {
		return parseInt(e.getHeight() / e.value.split('\n').length);
	}
})
function GetLabel(key) {
	for (x in BASELabels)
		if (x.toLowerCase() == key.toLowerCase())
			return BASELabels[x];
	return '';
}
function PostBack(method, params) {
	$('BASE__postBackForm__method').value = method;
	$('BASE__postBackForm__params').value = Object.toJSON(params);
	$('BASE__postBackForm').submit();
}
function OpenDialog(url, name, w, h) {
	options = '';
	if (w > 0 && h > 0) {
		if (isIE)
			w += 15;
		options = 'height=' + h + ',width=' + w + ',';
	}
	pleft = (screen.width - w) / 2;
	ptop = (screen.height - h) / 2;
	options += 'top=' + ptop + ',left=' + pleft + ',';
	options += 'scrollbars=yes,status=yes,location=no,toolbar=no,menubar=no';
	window.open(url, name, options);
}
function GetUrl(url) {
	document.location.href = url;
}
function GetBlankUrl(url) {
	window.open(url, '_blank');
}
function GetModeUrl(m) {
	GetUrl('index.php?mode=' + m);
}
function LoadingInfo() {
}
LoadingInfo.Show = function(v) {
	$('loadingInfoText').innerHTML = v;
	$('loadingInfo').center().show('block');
}
LoadingInfo.Hide = function() {
	$('loadingInfo').hide();
}
Form.Validate = function(f) {
	for ( var i = 1; i < arguments.length; i++) {
		var e = f[arguments[i]];
		if (!Form.ValidateRequired(e, GetLabel('FieldIsMandatory'))) {
			e.focus();
			return false;
		}
	}
	return true;
}
Form.ValidateRequired = function(e, msg) {
	if (e.value == null || e.value == "") {
		alert(msg);
		return false;
	}
	return true;
}
function ValidateEmail(s) {
	var f = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	return f.test(s);
}
function Dialog(title, params, callback) {
	if (!callback)
		callback = ShowDialog;
	$('dialog_title').innerHTML = GetLabel(title);
	BA.Update('dialog_content', {
		parameters : params,
		onComplete : callback
	});
}
function ShowDialog() {
	$('dialog').show('block');
}
function ValidateContactForm() {
	var valid = true;

	if ($F('cfName') == '') {
		$('cfName').addClassName('missing');
		valid = false;
	} else {
		$('cfName').removeClassName('missing');
	}

	if ($F('cfEmail') == '') {
		$('cfEmail').addClassName('missing');
		valid = false;
	} else {
		$('cfEmail').removeClassName('missing');
	}

	if ($F('cfMessage') == '') {
		$('cfMessage').addClassName('missing');
		valid = false;
	} else {
		$('cfMessage').removeClassName('missing');
	}

	if (valid) {
		BA.Call({
			parameters : {
				service : 'Ctrl.mail.send',
				name : $F('cfName'),
				email : $F('cfEmail'),
				message : $F('cfMessage')
			},
			onComplete : OnContactFormSent
		});
	}

	return valid;
}
function OnContactFormSent(t) {
	alert("Ihre Nachricht wurde erfolgreich an business pro austria gesendet.");
}
var sshowContent = [];
function SShow(id) {
	if (!isIE)
		FadeOut('bpasc');
	if (sshowContent[id] != '' && sshowContent[id] != 'undefined') {
		BA.Update('bpasc', {
			parameters : {
				service : 'Ctrl.contentPane.loadModuleInstanceContent',
				moduleInstanceId : id
			},
			onComplete : OnSShow
		});
	} else
		$('bpasc').innerHTML = sshowContent[id];
}
function OnSShow(t) {
	if (!isIE)
		FadeIn('bpasc');
	else
		$('bpasc').innerHTML = t.responseText;
	sshowContent[id] = t.responseText;
}
function FadeIn(id) {
	window.clearTimeout(fadeTimeout);
	$(id).style.opacity = 0;
	Fade(id, 0, 1, 1000);
}
function FadeOut(id) {
	window.clearTimeout(fadeTimeout);
	Fade(id, 1, 0, 1000);
}
var fadeTimeout;
var fadeFinished = true;
function Fade(id, opacityStart, opacityEnd, duration) {
	var e = $(id);
	if (e == null)
		return;

	var oldOpacity = parseFloat(e.style.opacity);
	var newOpacity = opacityEnd > opacityStart ? oldOpacity + 0.01
			: oldOpacity - 0.01;
	e.style.opacity = newOpacity;

	if (newOpacity < Math.max(opacityStart, opacityEnd)
			|| newOpacity > Math.min(opacityStart, opacityEnd)) {
		fadeTimeout = setTimeout("Fade('" + id + "'," + opacityStart + ","
				+ opacityEnd + "," + duration + ")", 10);
	} else {
		fadeFinished = true;
	}
}
function Sleep(m) {
	var d = new Date();
	var cd = null;
	do {
		cd = new Date();
	} while (cd - d < m);
}
function load_contentPane(pid, cpid, target, lang) {
	//$('dc_mitglied').innerHTML = "";
	BA.Call({
		parameters : {
			service : 'Load_DynCon',
			pid : pid,
			cpid : cpid,
			l : lang			
		},
		evalScripts: true,
		onSuccess: function(response) { 
			$(target).update(response.responseText);
			disable = true;
			if(init==true) {
				
				setTimeout(function() { location.href = "http://www.vto.at/index.php?tabid=10#heading";},50);
			}
			init = true;
			//window.location.hash = "heading";
		}
		
	});
} 
  
function locationHashChanged() {  
	if(disable==false) {
		document.getElementById('site_inhalt').scrollTop = 1;	
	}
	disable = false;
}  
  
window.onhashchange = locationHashChanged;
