// --------------------------------------------------------------
// © i++ GmbH, 1999-2009"
// --------------------------------------------------------------
// --------------------------------------------------------------
// Sniff the browser
// --------------------------------------------------------------
function BrowserType()
{
	this.sAgent   = navigator.userAgent.toLowerCase();
	this.nMajor   = parseInt(navigator.appVersion);
 	this.fMinor   = parseFloat(navigator.appVersion);
	this.bIsIE    = this.sAgent.indexOf("msie") > -1;
	this.bIsIE3   = (this.bIsIE && (this.nMajor == 2));
	this.bIsIE4   = (this.bIsIE && (this.nMajor == 4));
	this.bIsIE5   = (this.bIsIE && (this.sAgent.indexOf('msie 5') > 0));
	this.bIsIE6   = (this.bIsIE && (this.sAgent.indexOf('msie 6') > 0));
	this.bIsNav   = ((this.sAgent.indexOf('mozilla')!=-1) && ((this.sAgent.indexOf('spoofer')==-1) && (this.sAgent.indexOf('compatible')==-1))) && !this.bIsIE;
  this.bIsNav2  = (this.bIsNav && (this.nMajor == 2));
  this.bIsNav3  = (this.bIsNav && (this.nMajor == 3));
  this.bIsNav4b = (this.bIsNav && (this.fMinor < 4.04));
  this.bIsNav4  = (this.bIsNav && (this.nMajor >= 4));
//  this.bIsNav6  = (this.bIsNav && (document.getElementById ? true : false) );
  this.bIsNav6  = (this.bIsNav && (this.sAgent.indexOf('gecko')!=-1));
  this.bIsOp    = (this.sAgent.indexOf("opera") != -1);
  this.bIsWin   = (this.sAgent.indexOf("win")!=-1);
  this.bIsMac   = (this.sAgent.indexOf("mac")!=-1);
  this.bIsUnix  = (this.sAgent.indexOf("x11")!=-1);
	this.bDoesAll = (this.bIsIE4 || this.bIsIE5 || this.bIsIE6 || this.bIsOp || this.bIsNav6) //&& !this.bIsMac;
}
// --------------------------------------------------------------
// Swap images
// --------------------------------------------------------------
function swappableImg(sImgOn,sImgOff,sImgHover)
{
	this.img_on = new Image();
	this.img_on.src = sImgOn;
	this.img_off = new Image();
	this.img_off.src = sImgOff;
	this.img_hover = new Image();
	this.img_hover.src = sImgHover;
	this.imgOn = imgOn;
	this.imgOff = imgOff;
	this.imgHover = imgHover;
}
// --------------------------------------------------------------
// Swap images
// --------------------------------------------------------------
function imgOn() {
	var e;
	e = window.event.srcElement;
	if(e.tagName == "IMG")
	{
		e.src = this.img_on;
	}
}
// --------------------------------------------------------------
// Swap images
// --------------------------------------------------------------
function imgOff() {
	var e;
	e = window.event.srcElement;
	if(e.tagName == "IMG")
	{
		e.src = this.img_off;
	}
}
// --------------------------------------------------------------
// Swap images
// --------------------------------------------------------------
function imgHover() {
	var e;
	e = window.event.srcElement;
	if(e.tagName == "IMG")
	{
		e.src = this.img_hover;
	}
}
// --------------------------------------------------------------
// Hover Button
// --------------------------------------------------------------
function cuttonOnHover(imgName) {
	if (document.images){
	    document[imgName].src = "images/Button_On_Hover.gif";
  }
}
// --------------------------------------------------------------
// Hover Button
// --------------------------------------------------------------
function buttonOffHover(imgName) {
	if (document.images){
	    document[imgName].src = "images/Button_Off_Hover.gif";
  }
}
// --------------------------------------------------------------
// Turn on Button
// --------------------------------------------------------------
function buttonOn(imgName) {
	if (document.images){
	    document[imgName].src = "images/Button_On.gif";
  }
}				
// --------------------------------------------------------------
// Turn off Button
// --------------------------------------------------------------
function buttonOff(imgName) {
	if (document.images){
	    document[imgName].src = "images/Button_Off.gif";
  }
}				
// --------------------------------------------------------------
// Preload Button
// --------------------------------------------------------------
function preLoad(imgName) {
  var browserType = new BrowserType();
  if (browserType.bDoesAll)
  {
	  img = new Image();
	  img.src = imgName;
  }
}
// --------------------------------------------------------------
// Get dynamic
// --------------------------------------------------------------
function setInnerHTML(Obj,sNewText) {
	Obj.innerHTML = sNewText;
}
// --------------------------------------------------------------
//  Local date
// --------------------------------------------------------------
function strDate() {
    var userTime = new Date();

    var currentDay = userTime.getDate();
    var currentMonth = userTime.getMonth() + 1;
    var currentYear = userTime.getFullYear();

    currentDay = ( currentDay < 10 ? "0" : "" ) + currentDay;
    currentMonth = ( currentMonth < 10 ? "0" : "" ) + currentMonth;

    var currentTimeString = 
        currentDay + "." + currentMonth + "." + currentYear; 
	return currentTimeString;
}
// --------------------------------------------------------------
//  Local year
// --------------------------------------------------------------
function strYear() {
	 var now=new Date();
	 return now.getYear();
}
// --------------------------------------------------------------
//  Local month
// --------------------------------------------------------------
function strMonth() {
	var now=new Date();
	return now.getMonth() + 1;
}
// --------------------------------------------------------------
//  Local day
// --------------------------------------------------------------
function strDay() {
	var now=new Date();
	return now.getDate();
}
// --------------------------------------------------------------
// Local time
// --------------------------------------------------------------
function strTime() {
  var userTime = new Date();

    var currentHours = userTime.getHours();
    var currentMinutes = userTime.getMinutes();
    var currentSeconds = userTime.getSeconds();

    currentHours = ( currentHours < 10 ? "0" : "" ) + currentHours;
    currentMinutes = ( currentMinutes < 10 ? "0" : "" ) + currentMinutes;
    currentSeconds = ( currentSeconds < 10 ? "0" : "" ) + currentSeconds;

    var currentTimeString = 
        currentHours + ":" + currentMinutes + ":" + currentSeconds;

  return currentTimeString;
}
// --------------------------------------------------------------
// Display time on line
// --------------------------------------------------------------
function tick() {

  Clock.innerHTML = strTime();

  window.setTimeout("tick();", 100);
}
// --------------------------------------------------------------
// Display date and time on line
// --------------------------------------------------------------
function ticktick() {

  Clock.innerHTML = strDate()+" "+strTime();

  window.setTimeout("ticktick();", 100);
}
// --------------------------------------------------------------
// Switch location
// --------------------------------------------------------------
function framecheck(sLocation) {
  if( parent.frames.length == 0 )
  {
    location.replace(sLocation)
  }
}
//---------------------------------------------------------------
// <a href="html-or.jpg" onclick="return popup(this,123,456)" title="..."
// or
// <a href="html-or.jpg" onclick="return popup(this)" title="..."
//---------------------------------------------------------------
var pop = null;

// --------------------------------------------------------------
// Close popup
// --------------------------------------------------------------
function popdown() {
  if (pop && !pop.closed) pop.close();
}
// --------------------------------------------------------------
// Open popup
// --------------------------------------------------------------
function popup(obj,w,h) {
  var url = (obj.getAttribute) ? obj.getAttribute('href') : obj.href;
  if (!url) return true;
  w = (w) ? w : 500;  // 500px*300px is the default size
  h = (h) ? h : 300;
  var args = 'width='+w+',height='+h+',resizable';
  popdown();
  pop = window.open(url,'',args);
  return (pop) ? false : true;
}
// --------------------------------------------------------------
// Set opacity
// --------------------------------------------------------------
function setOpacity(elem, opacityAsInt) {
  var opacityAsDecimal = opacityAsInt;

  if (opacityAsInt > 100)
    opacityAsInt = opacityAsDecimal = 100; 
  else if (opacityAsInt < 0)
    opacityAsInt = opacityAsDecimal = 0; 

  opacityAsDecimal /= 100;
  if (opacityAsInt < 1)
    opacityAsInt = 1; // IE7 bug, text smoothing cuts out if 0

  elem.style.opacity = (opacityAsDecimal);
  elem.style.filter  = "alpha(opacity=" + opacityAsInt + ")";
}
// --------------------------------------------------------------
// Ad detailinfo marker to map at point
// --------------------------------------------------------------
function addInfoMarker(map,point) {
  // Force info windows to load as to be ready when map is loaded
  map.getInfoWindow().show();
  // Create narker with tabbed info window with map and i++ marker icon
  var title = "i++ GmbH";
  var iplusplusIcon = new google.maps.Icon(G_DEFAULT_ICON);
  iplusplusIcon.image = "images/iplusplusmarker.png";
 var marker = new google.maps.Marker(point,{title:title,icon:iplusplusIcon});
 google.maps.Event.addListener(marker, "click", function() {
 	var tab1 = new google.maps.InfoWindowTab("Adresse", "<div id='addr_panel'><h2>i++&reg GmbH</h2><br />Herzogspitalstr. 11/III<br />D-80331 M&uuml;nchen</div>");
	var tab2 = new google.maps.InfoWindowTab("Detailkarte", "<div id='map_detail' style='overflow: hidden; width: 210px; height: 180px'>Karte</div>");
	var infoTabs = [tab1,tab2];
	marker.openInfoWindowTabsHtml(infoTabs);
     // Add another map to info tab
	var dMap = document.getElementById("map_detail");
	var detailMap = new google.maps.Map2(dMap);
	detailMap.setCenter(point, 13);
     detailMap.setUIToDefault();
	detailMap.addOverlay(new google.maps.Marker(point,{title:title,icon:iplusplusIcon}));
	dMap.firstChild.nextSibling.style.display = "none";
	dMap.firstChild.nextSibling.nextSibling.style.display = "none";
  });
  map.addOverlay(marker);
}
