/**********************************

Homepage:	Kinderzirkus Datterino
Use: 		Kinderzirkus-Datterino.de
Author: 	Alexander Kuhn

**********************************/

//**
// Funktion zum Setzen eines Button-Hintergrunds
//**
function menu_active(value) {
 switch(value) {
  case 'startseite':
   document.getElementById('menuChild1').style.background = 'url(media/gfx/menu_child1_hover.png)';
   break;
  case 'kinderzirkus':
   document.getElementById('menuChild2').style.background = 'url(media/gfx/menu_child2_hover.png)';
   break;
  case 'anmeldung':
   document.getElementById('menuChild3').style.background = 'url(media/gfx/menu_child3_hover.png)';
   break;
  case 'shop':
   document.getElementById('menuChild4').style.background = 'url(media/gfx/menu_child4_hover.png)';
   break;
  case 'foerderkreis':
   document.getElementById('menuChild5').style.background = 'url(media/gfx/menu_child5_hover.png)';
   break;
 }
}

//**
// Funktion zum Reseten der Webseite
//**
function reset_page() {
 window.alert('Die Seite wurde nicht gefunden. Sie werden auf die Startseite umgeleitet.');
 window.location.href='index.php?site=startseite#top';
}

//**
// Zirkusteam Picture Hitcounter
//**
function count_teamgallerypic(pic_id) {
 new Ajax.Request('ajax_teamgallerypiccounter.php?id='+pic_id);
}

//**
// Bildergalerie Picture Hitcounter
//** 
function count_picturegallerypic(pic_id) {
 new Ajax.Request('ajax_picturegallerypiccounter.php?id='+pic_id);
}

//**
// Funktion zum Highlighten und Faden eines DIVs
//** 

function highlight_fade() {
 new Effect.Highlight('shop_information', { startcolor: '#f1eb4a',endcolor: '#dce48c' }, { duration: 3.0}, { queue: 'front' }); 
 new Effect.Fade('shop_information', { duration: 5.0}, { queue: 'end' }); return false;
}

//**
// Funktion zum URL-Aufruf
//** 

function href_sortiment() {
 window.location.href='index.php?site=shop&sub=sortiment#top';
}

function href_shopkategorie(shopkategorie_id) {
 window.location.href='index.php?site=shop&sub=sortiment&shopkategorie=' + shopkategorie_id + '#top';
}


//**
// Pinnwand AJAX
//**
var pinnboardUpdateTimer = 0;
var http_request = false;

function pinboardUpdateRequest() {
 http_request = false;
 if (window.XMLHttpRequest) {
  http_request = new XMLHttpRequest();
  if (http_request.overrideMimeType) {
   http_request.overrideMimeType('text/xml');
  }
 } else if (window.ActiveXObject) {
  try {
   http_request = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (e) {}
  }
 }
 if (!http_request) {
  alert('Giving up :( Cannot create an XMLHTTP instance');
  return false;
 }
 http_request.onreadystatechange = updatePinboard;
 http_request.open('GET', "ajax_pinboard.php", true);
 http_request.send(null);
}

var outputCounter = 0;

function updatePinboard() {
 if(http_request.readyState == 4) {
  if(http_request.status == 200) {
   var xmldoc = http_request.responseXML;
   var rootNode = xmldoc.getElementsByTagName("pinboard").item(0);
   document.getElementById("pinboard_namecontent").innerHTML = rootNode.nodeName;
   if(outputCounter >= rootNode.childNodes.length) {
    outputCounter = 0; 
   }
   var intervalTime = rootNode.childNodes[outputCounter].getAttribute("interval")*1000;
   var newName = rootNode.childNodes[outputCounter].getAttribute("firstname") + " " + rootNode.childNodes[outputCounter].getAttribute("lastname");
   var newDate = rootNode.childNodes[outputCounter].getAttribute("date");
   var newText = rootNode.childNodes[outputCounter].firstChild.data;
   var newGender = rootNode.childNodes[outputCounter].getAttribute("gender");
   if(newGender == 1) {
	newGender = '<img src="media/gfx/home_pinboard_man.png" width="60" height="74" alt="Mann" />';   
   } else {
    newGender = '<img src="media/gfx/home_pinboard_woman.png" width="60" height="74" alt="Frau" />'; 
   }
   document.getElementById("pinboard_namecontent").innerHTML = newName;
   document.getElementById("pinboard_datecontent").innerHTML = newDate;
   document.getElementById("pinboard_textcontent").innerHTML = newText;
   document.getElementById("pinboard_gendercontent").innerHTML = newGender;
   pinboardUpdateTimer = window.setTimeout("pinboardUpdateRequest();", intervalTime);
   outputCounter++;
  }
 }
}
