function showTabTeaserContent(id,items) {
  for(var i = 1;i <= items; i++) {
    document.getElementById('content'+i).className = 'newsitem passive';
    document.getElementById('tab'+i).className = '';
  }
  document.getElementById('content'+id).className = 'newsitem';
  document.getElementById('tab'+id).className = 'active';
}

function resizeTabTeaserContent(items) {
  var height = 0;
  for(var i = 1; i <= items; i++) {
    if (document.getElementById('content'+i).offsetHeight > height) height = document.getElementById('content'+i).offsetHeight;
  }
  for(var i = 1; i <= items; i++) {
    document.getElementById('content'+i).style.height = height+'px';
    if (i > 1) document.getElementById('content'+i).className = 'newsitem passive';
  }
}

function resizeStartTeaser() {
  if (document.getElementById('startleft').offsetHeight > document.getElementById('startmiddle').offsetHeight) {
    document.getElementById('startmiddle').style.height = (document.getElementById('startleft').offsetHeight - 2) + 'px';
  }
  else {
    document.getElementById('startleft').style.height = (document.getElementById('startmiddle').offsetHeight - 2) + 'px';
  }
}

function getAccordionBoxHeight(items) {
  var height = 0;
  for(var i = 1; i <= items; i++) {
    if (document.getElementById('tcontent'+i).offsetHeight > height) height = document.getElementById('tcontent'+i).offsetHeight;
  }
  return height;
}

function openPopUp(popupURL,popupName,popupWidth,popupHeight) {
  top.name = "popup";
  var popup = window.open(popupURL,popupName,"toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+popupWidth+",height="+popupHeight);
  if( navigator.appName.substring(0,8) == "Netscape" ) {
    popup.location = popupURL;
    popup.opener = self;
  }
  popup.focus();
}

function showBookmarks(id) {
  if (document.getElementById('bookmarks'+id)) {
    if (document.getElementById('bookmarks'+id).style.display == 'block') {
      document.getElementById('bookmarks'+id).style.display = 'none';
      document.getElementById('bookmark'+id).className = '';
      openbookmark = '';
   }
    else {
      document.getElementById('bookmarks'+id).style.display = 'block';
      document.getElementById('bookmark'+id).className = 'bookmarks';
      openbookmark = id;
    }
  }
}

var openbookmark = '';

window.addEvent('domready', function() {
  $$('body').addEvent('click', function(e) {
    if (openbookmark) showBookmarks(openbookmark);
  });
});


function showQuartier(showurl) {
  var req = new Request({url:showurl, 
		onSuccess: function(html) {
			$('mapcontent').set('html', html);
      Shadowbox.setup(); 
		}
	});
	req.send();
}

function zoomMap(layer,area,language) {
  Shadowbox.open({content:"/HafencityMap.swf",player:"swf",title:"",height:700,width:1508,options:{flashVars:{xmlurl:"/map.php",language:language,mode:"map",zoom_js:"unzoomMap",layer:layer,area:area,menu:"false"}}}); 
}

function unzoomMap() {
  Shadowbox.close(); 
}

function pageAkkordeon(open,color,background,backgroundpassive,border,image) {
  var myAccordion = new Accordion($('akkordeon'), 'h2.opener', 'div.content', {
	  opacity:false,
		show:open,
		alwaysHide:true,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#ffffff');
			toggler.setStyle('backgroundColor', background);
			toggler.setStyle('backgroundImage', 'url(/images/akkordeon_minus'+image+'.gif)');
			element.setStyle('border-bottom', '1px solid ' + border);
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', color);
			toggler.setStyle('backgroundColor', backgroundpassive);
			toggler.setStyle('backgroundImage', 'url(/images/akkordeon_plus'+image+'.gif)');
			element.setStyle('border-bottom', '0px');
		}
	});
}

function boxAkkordeon(items,id,open,color,background,backgroundpassive,border) {
  var height = getAccordionBoxHeight(items);
  var myBoxAccordion = new Accordion($('takkordeon'+id), 'h2.topener', 'div.tcontent', {
  	opacity:false,
  	show:open,
  	fixedHeight:height,
	  onActive: function(toggler, element){
	    toggler.setStyle('color', color);
	    toggler.setStyle('backgroundColor', background);
	    toggler.setStyle('border-bottom', '0px');
			element.setStyle('border-bottom', '1px solid ' + border);
			element.setStyle('padding-bottom', '8px');
		},
		onBackground: function(toggler, element){
		  toggler.setStyle('color', '#000000');
	    toggler.setStyle('backgroundColor', backgroundpassive);
		  toggler.setStyle('border-bottom', '1px solid ' + border);
		  element.setStyle('border-bottom', '0px');
		  element.setStyle('padding-bottom', '0px');
		}
	});
}

function openGallery(galleryname) {
  Shadowbox.open($(galleryname));
}

function openVideo() {
  Shadowbox.open($("videolink"));
}

function makeEMail() {
  document.location.href = 'mai'+'lto'+':info'+'@'+'hafenc'+'ity.com';
}

function showKInfo(id) {
  $$('.klinke').setStyle('display','none');
  $('klinke'+id).setStyle('display','block');
}

function unshowKInfo() {
  $$('.klinke').setStyle('display','none');
}

function showCalendar(month,year,language) {
	var req = new Request.HTML({
	      method: 'get',
	      url: '/calendar.php',
	      data: { 'month': month, 'year': year, 'language': language },
	      update: $('calendar'),
	      onComplete: function(response) { 
	    		$('calendarnext').addEvent('click', function(e) {
	    			var nextmonth = month + 1;
	    			var nextyear = year;
	    			if (nextmonth > 12) {
	    				nextmonth = 1;
	    				nextyear++;
	    			}
	    			showCalendar(nextmonth,nextyear,language);
	    		});
	    		
	    		$('calendarprev').addEvent('click', function(e) {
	    			var prevmonth = month - 1;
	    			var prevyear = year;
	    			if (prevmonth < 1) {
	    				prevmonth = 12;
	    				prevyear--;
	    			}
	    			showCalendar(prevmonth,prevyear,language);
	    		});
	      }
	    }).send();
}
