var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
} 
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}


$(document).ajaxComplete(function(){
    try{
        FB.XFBML.parse(); 
    }catch(ex){}
});

$(document).ready(function(){
    
    if($('.lyricsdiv').length ) 
    {
      $('.lyricsdiv').draggable();
      $('.lyricsdiv').draggable({cursor:'move'});
      $('.lyricsdiv').draggable({handle:'.lyricsdivinner'});
    }
    
    

    $('#main_outer').fadeIn();
    $('#side_menu').fadeIn();
                                                                                                                                                                       
    if($('#start_bg').length > 0)
    {
      if(getWidth() > 1680 )
      {
        $('body').css("background-image" , "url(img/bg/1920/selector_" + $('#start_bg').val() + ".jpg)");
      }
      else
      {
        $('body').css("background-image" , "url(img/bg/1680/selector_" + $('#start_bg').val() + ".jpg)");
      }
    }
  
      
    $("#selector_0").click().toggle( 
    function() {
     $('#main_outer').fadeOut();
     $('#bar').fadeOut();
     $('#playerbar').fadeOut();
     $('#street').fadeOut();
     $('#newsletter').fadeOut();
     $('#selector_0_img').attr('src','img/bg/bg_show.png');
    },
    function () {
     $('#main_outer').fadeIn();
     $('#bar').fadeIn();
     $('#playerbar').fadeIn();
     $('#street').fadeIn();
     $('#newsletter').fadeIn();
     $('#selector_0_img').attr('src','img/bg/bg_hide.png');
     }
    );
    
        
    $('#grayer').click(
       function() {
        $('#street').animate({top: '-550px'});
        $('#playerbar').animate({top: '-410px'});
        $('#bar').animate({left: '-50px'});
        $('#newsletter').animate({top: '-370px'});
        $('#home_msg').fadeOut();
        hideGrayer();
       }
    );
    
    $('#main_outer').click(
     function() {
      $('#street').animate({top: '-550px'});
      $('#playerbar').animate({top: '-410px'});
      $('#bar').animate({left: '-50px'});
      $('#grayer').fadeOut();
      $('#home_mgs').fadeOut();
     }
    );
    
    $('#bar').click(
     function() {
      $('#bar').animate({left: '-10px'});
     }
    );
    
    $('#super_outer').click(
     function() {
      $('#street').animate({top: '-550px'});
      $('#playerbar').animate({top: '-410px'});
      $('#bar').animate({left: '-50px'});
      $('#grayer').fadeOut();
     }
    );
    
    if(document.getElementById('sttmap'))
      stinitialize();
    
}); 

function closeMapList() {
  if( $('#maplist').css("height") == "30px") {
   $('#maplist').removeClass("closedlist");
   $('#maplistclose').html("Map List&nbsp;&nbsp;&nbsp;[close]")
  }
  else {
   $('#maplist').addClass("closedlist");
   $('#maplistclose').html("Map List&nbsp;&nbsp;&nbsp;[open]")
  }
}
 
 var geocoder = new google.maps.Geocoder();;
 var map;
 var megamap;
 var venues = new Array();
 var ndates = new Array();
 var odates = new Array();
 var tdiarys = new Array();
 var ndate_coord = new Array();
 var ndate_title = new Array();
 var odate_coord = new Array();
 var odate_title = new Array();
 var venues_coord = new Array();
 var venues_title = new Array();
 var tdiary_coord = new Array();
 var tdiary_title = new Array();
 var tdiary_text = new Array();
 var iwn = new Array();
 var iwb = new Array();
 var iwo = new Array();
 var iwv = new Array();
 var iwtd = new Array();
 
 var band = new Array();
 var bandmarker = new Array();
 band[0] = new Array();
 band[0][0] = "Teheran,+Iran";
 band[0][1] = "Behrang Alavi";
 band[0][2] = 35.6961111;
 band[0][3] = 51.4230556;
 band[0][4] = "Vocals, Guitar";
 band[0][5] = '<div class="ivwbimg">';
 band[0][5] += '<img src="img/band/live/behrang_live_1_mid.jpg" hspace="0" vspace="0" border="0">';
 band[0][5] += '<img src="img/band/live/behrang_live_2_mid.jpg" hspace="0" vspace="0" border="0">';
 band[0][5] += '<img src="img/band/live/behrang_live_3_mid.jpg" hspace="0" vspace="0" border="0">';
 band[0][5] += '</div>';
 
 band[1] = new Array();
 band[1][0] = "Berlin+Friedrichshain,+Deutschland";
 band[1][1] = "Andreas Voland";
 band[1][2] = 52.5127269;
 band[1][3] = 13.44551;
 band[1][4] = "Bass guitar, Backvocals";
 band[1][5] = '<div class="ivwbimg">';
 band[1][5] += '<img src="img/band/live/andi_live_1_mid.jpg" hspace="0" vspace="0" border="0">';
 band[1][5] += '<img src="img/band/live/andi_live_2_mid.jpg" hspace="0" vspace="0" border="0">';
 band[1][5] += '<img src="img/band/live/andi_live_3_mid.jpg" hspace="0" vspace="0" border="0">';
 band[1][5] += '</div>';
 
 band[2] = new Array();
 band[2][0] = "Berlin+Friedrichshain,+Deutschland";
 band[2][1] = "Stephan Voland";
 band[2][2] = 52.5127269;
 band[2][3] = 13.44551;
 band[2][4] = "Drums, Backvocals";
 band[2][5] = '<div class="ivwbimg">';
 band[2][5] += '<img src="img/band/live/stephan_live_1_mid.jpg" hspace="0" vspace="0" border="0">';
 band[2][5] += '<img src="img/band/live/stephan_live_2_mid.jpg" hspace="0" vspace="0" border="0">';
 band[2][5] += '<img src="img/band/live/stephan_live_3_mid.jpg" hspace="0" vspace="0" border="0">';
 band[2][5] += '</div>';
 
 band[3] = new Array();
 band[3][0] = "Berlin+Lichtenberg,+Deutschland";
 band[3][1] = "Marco Wirth";
 band[3][2] = 52.514556;
 band[3][3] = 13.498307;
 band[3][4] = "Lead guitar, Backvocals";
 band[3][5] = '<div class="ivwbimg">';
 band[3][5] += '<img src="img/band/live/marco_live_1_mid.jpg" hspace="0" vspace="0" border="0">';
 band[3][5] += '<img src="img/band/live/marco_live_2_mid.jpg" hspace="0" vspace="0" border="0">';
 band[3][5] += '<img src="img/band/live/marco_live_3_mid.jpg" hspace="0" vspace="0" border="0">';
 band[3][5] += '</div>';

 band[4] = new Array();
 band[4][0] = "Berlin,+Deutschland";
 band[4][1] = "Samavayo";
 band[4][2] = 52.5234051;
 band[4][3] = 13.4113999;
 band[4][4] = "Rock from Berlin";
 band[4][5] = '<div class="ivwbimg">';
 band[4][5] += '<img src="img/band/band_2011_1_small.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '<img src="img/band/band_2011_2_small.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '<img src="img/band/live/band_live_1_mid.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '<img src="img/band/live/band_live_2_mid.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '<img src="img/band/live/band_live_3_mid.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '<img src="img/band/live/band_live_4_mid.jpg" hspace="0" vspace="0" border="0">';
 band[4][5] += '</div>';
 band[4][5] += '<div id="bandtselector" onClick="toggleBandInfo();">German | English</div><div id="bandtext_de">';
 band[4][5] += '<h2>Nicht nur die Attitüde ist Rock</h2>';
 band[4][5] += 'SAMAVAYO legen das ehrlichste Album ihrer Geschichte vor und proben mit ihre neuen Platte „ Cosmic Knockout“ die Revolution der Reduktion. Alles ordnet sich einem einzigen Gesamtziel unter: „Es muss rocken! Verdammt rocken!“';
 band[4][5] += '<br /><br />';
 band[4][5] += 'SAMAVAYO ist eine dieser Bands, die vor fiebriger Leidenschaft lichterloh brennen. Mit der aktuellen Veröffentlichung, dem 3. Album „Cosmic Knockout“ ist es SAMAVAYO gelungen, diesen kreativen Flächenbrand auf Platte zu bannen. SAMAVAYO [sanskrit, alt indisch] bedeutet Eintracht, Einheit und einträchtig entscheiden die vier Berliner Großstadtrocker auch, welche musikalischen Schleusen geöffnet werden: „Wir machen nichts anderes, als unsere Musik. Gespeist wird sie aus den gehaltvollen Quellen von Psychedelischem Rock, Funk, Metal, Alternative-Rock der 90er und natürlich dem guten alten Rocksound der 70er. Natürlich sind wir aber auch jahrelang mit Popmelodien berieselt worden. Auch das hat Eingang in unsere Musik gefunden“, lassen Sänger Behrang Alavi und Gitarrist Marco Wirth vermelden. Kein Wunder, wenn sich die zwölf Lieder im Ohr festkrallen und geradezu infektiös im ganzen Körper ausbreiten </div>';
 band[4][5] += '<div id="bandtext_eng" style="display:none;">';
 band[4][5] += '<h2>Not only the attitude is Rock</h2>';
 band[4][5] += 'SAMAVAYO submit the most honest album of their history and rehearsing with their new album "Cosmic Knockout" the revolution of the reduction. Everything is arranged under a single overall objective: "It must rock! Fucking rock!" <br /><br />';
 band[4][5] += 'SAMAVAYO is one of those bands that are ablaze in front of feverish passion. With the current publication, the 3rd Album "Cosmic Knockout" succeeded SAMAVAYO to capture this creative conflagration on record. SAMAVAYO [Sanskrit, old Indian] means harmony, unity and amicably decide the four Berlin City rocker also what musical floodgates are opened: "We are doing nothing more than our music. It is fed from the full-bodied sources of psychedelic rock, funk, metal, alternative rock of the 90s and of course the good old rock sound of the 70s. Of course we are but were also sprayed for years with pop melodies. This also has made inroads into our music" can be reported Behrang Alavi singer and guitarist Marco Wirth. No wonder, then, the twelve songs claws in the ear and downright infectious in the whole body.</div>';

 function codeAddress(address,html) {  
    if (geocoder) {
      geocoder.geocode( { 'address': address}, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) {
          
          var marker = new google.maps.Marker({
              map: map, 
              position: results[0].geometry.location
          });
          
          var contentString = html;
          var infowindow = new google.maps.InfoWindow({
              content: contentString
          });
          google.maps.event.addListener(marker, 'click', function() {
            infowindow.open(map,marker);
          });
          
        } 
        /// 
         //alert('notfound: ' + address);
      });
    }
  }
  
   function showMyAd(laty,lony,html) {
      
      var latlon = new google.maps.LatLng(laty,lony);
      
      var marker = new google.maps.Marker({
          position: latlon,
          map: map
      });    
      
      marker.setMap(map);
      
      var contentString = html;
      var infowindow = new google.maps.InfoWindow({
          content: contentString
      });
      google.maps.event.addListener(marker, 'click', function() {
        infowindow.open(map,marker);
      });
          
  }
 
  
  function toggleBandInfo() {
    if($('#bandtext_eng').css("display") ==  "none")
    {
        $('#bandtext_de').hide();
        $('#bandtext_eng').show();
    
    }
    else
    {
        $('#bandtext_eng').hide();
        $('#bandtext_de').show();
    }
  }
  
  function codeAddressMap(address) {
    if (geocoder) {
      
    }
  }
  
  var nsi;
  function showNewCoords() {
     for(nsi=0; nsi < ndate_coord.length;nsi++) {
          var lat = ndate_coord[nsi][0];
          var lon = ndate_coord[nsi][1];
          var latlon = new google.maps.LatLng(lat,lon);
          var newshows = "img/newshows.png";
          ndates[nsi] = new google.maps.Marker({
              position: latlon,
              icon: newshows
          });      
          ndates[nsi].setMap(megamap);
          attachSecretMessage(ndates[nsi], nsi,iwn); 
     
     }
  }
  
  
  var osi;
  function showOldCoords() {
     for(osi=0; osi < odate_coord.length;osi++) {
          var lat = odate_coord[osi][0];
          var lon = odate_coord[osi][1];
          var latlon = new google.maps.LatLng(lat,lon);
          var oldshows = "img/oldshows.png";
          odates[osi] = new google.maps.Marker({
              position: latlon,
              icon: oldshows
          });
          odates[osi].setMap(megamap);
          attachSecretMessage(odates[osi], osi,iwo);
     }
  }
  
  function showVenueCoords()
  {  
     for(var i=0; i < venues_coord.length;i++) {
          var lat = venues_coord[i][0];
          var lon = venues_coord[i][1];
          var latlon = new google.maps.LatLng(lat,lon);
          var house = "img/house_icon.png";
          venues[i] = new google.maps.Marker({
              position: latlon,
              icon: house
              
          });
          venues[i].setMap(megamap);
          attachSecretMessage(venues[i], i,iwv); 
     }
  }
  
  function showDiaryCoords()
  {  
     for(var i=0; i < tdiary_coord.length;i++) {
          var lat = tdiary_coord[i][0];
          var lon = tdiary_coord[i][1];
          var latlon = new google.maps.LatLng(lat,lon);
          var book = "img/book_open.png";
          tdiarys[i] = new google.maps.Marker({
              position: latlon,
              icon:book
          });
          tdiarys[i].setMap(megamap);
          attachSecretMessage(tdiarys[i], i,iwtd); 
     }          
    $('.iwbox_diary a.img').fancybox(); 
  }
  
  var mylat;
  function showBandCoords()
  {  
     for(var i=0; i < band.length;i++) {
          mylat = new google.maps.LatLng(band[i][2],band[i][3]);
          var bandi = "img/band-icon.png";
          bandmarker[i] = new google.maps.Marker({
            position: mylat,
            icon: bandi
         });
          bandmarker[i].setMap(megamap);
          attachSecretMessage(bandmarker[i], i,iwb);
     }          
  }
  
  
  function attachSecretMessage(marker, number,arr) {
    var infowindow = arr[number];
    google.maps.event.addListener(marker, 'click', function() {
      infowindow.open(megamap,marker);
    });
  }
  
  function hideVenueCoords()
  { 
    for(var i=0; i < venues.length;i++) {
      venues[i].setMap(null);
    }
  }
  
  function hideOldCoords()
  { 
    for(var i=0; i < odates.length;i++) {
      odates[i].setMap(null);
    }
  }
  
  function hideNewCoords()
  { 
    for(var i=0; i < ndates.length;i++) {
      ndates[i].setMap(null);
    }
  }
  
  function hideDiaryCoords()
  { 
    for(var i=0; i < tdiarys.length;i++) {
      tdiarys[i].setMap(null);
    }
  }
  
  function hideBandCoords()
  { 
    for(var i=0; i < bandmarker.length;i++) {
      bandmarker[i].setMap(null);
    }
  }
  
  
  function mapVenues() {
    if(document.getElementById('mapvstate').checked == false) 
       hideVenueCoords();
    else
    {
      $.ajax({
              type     : "POST",
              async    : false,
              url      : "php/mapquery.php?mode=venues",
              cache    : false,
              dataType : 'json',
              success: function(data) {
                  object = data;
                  venues_coord = object[0];
                  venues_title = object[1];
                  var newhtml = "";
                    for(var i=0; i < venues_title.length;i++) {
                      newhtml += "<div class=\"mlitem\" onClick=\"openOverlay(iwv[" + i + "],venues[" + i + "]);\" onmouseover=\"highlightMarker(venues[" + i + "]);\" onmouseout=\"normalizeMarker(venues[" + i + "]);\">" + venues_title[i] +"</div>";
                    }
                  $('#maplist_inner').html(newhtml);
                  for(var i=0; i < venues_title.length; i++) {
                     iwv[i] = new google.maps.InfoWindow({
                        content: '<div class="iwbox">' + venues_title[i] + '</div>'
                    });
                  }
              },
          });
          showVenueCoords();
    }
          
  }
  
  function mapNewShows() {
    if(document.getElementById('mapnstate').checked == false)
       hideNewCoords();
    else
    {
        $.ajax({
              type     : "POST",
              async    : false,
              url      : "php/mapquery.php?mode=newshows",
              cache    : false,
              dataType : 'json',
              success: function(data) {
                  object = data;
                  ndate_coord = object[0];
                  ndate_title = object[1];
                  ndate_text = object[2];
                  ndate_date = object[3];
                  var newhtml = "";
                    for(var i=0; i < ndate_title.length;i++) {
                      newhtml += "<div class=\"mlitem\" onClick=\"openOverlay(iwn[" + i + "],ndates[" + i + "]);\" onmouseover=\"highlightMarker(ndates[" + i + "]);\" onmouseout=\"normalizeMarker(ndates[" + i + "]);\">" + ndate_date[i] + '<br>' + ndate_title[i] + "</div>";
                    }
                  $('#maplist_inner').html(newhtml);
                  for(var i=0; i < ndate_title.length; i++) {
                     iwn[i] = new google.maps.InfoWindow({
                        content: '<div class="iwbox">' + ndate_date[i] + '<br>' + ndate_title[i] + '<br>' + ndate_text[i] + '</div>'
                    });
                  }
              },
          });
       showNewCoords();
    }
  }
  
  function openOverlay(mywindow,mymarker) {
    mywindow.open(megamap,mymarker);
  }
  
  function highlightMarker(marker) {
     var str = marker.icon;
     var newstr = str.replace("_high.",".");
     var newstr = newstr.replace(".","_high.");
     marker.setIcon(newstr);
  }
  
  function normalizeMarker(marker) {
     var str = marker.icon;
     var newstr = str.replace("_high.",".");
     marker.setIcon(newstr);
  }
  
  function creatMapList(arr) {
    var newhtml = "";
    for(var i=0; i < arr.length;i++) {
      newhtml += arr[i] + "<br>";
    }
    alert(newhtml);
    return newhtml;
  }
  
  function mapDiary() {
     if(document.getElementById('mapdstate').checked == false)
       hideDiaryCoords();
    else
    {
        $.ajax({
              type     : "POST",
              async    : false,
              url      : "php/mapquery.php?mode=tdiary",
              cache    : false,
              dataType : 'json',
              success: function(data) {
                  object = data;
                  tdiary_coord = object[0];
                  tdiary_title = object[1];
                  tdiary_text = object[2];
                  tdiary_date = object[3];
                  var newhtml = "";
                    for(var i=0; i < tdiary_title.length;i++) {
                      newhtml += "<div class=\"mlitem\" onClick=\"openOverlay(iwtd[" + i + "],tdiarys[" + i + "]);\" onmouseover=\"highlightMarker(tdiarys[" + i + "]);\" onmouseout=\"normalizeMarker(tdiarys[" + i + "]);\">" + tdiary_date[i] +  tdiary_title[i] +"</div>";
                    }
                  $('#maplist_inner').html(newhtml);
                  for(var i=0; i < tdiary_title.length; i++) {
                     iwtd[i] = new google.maps.InfoWindow({
                        content: '<div class="iwbox_diary">' + tdiary_date[i] + tdiary_title[i] + " " + tdiary_text[i] + '</div>'
                    });
                  }
              },
          });
       showDiaryCoords();
    }
  }
  
  
  function mapBand() {
     if(document.getElementById('mapbstate').checked == false)
       hideBandCoords();
    else
    {
      var newhtml = "";
        for(var i=0; i < band.length;i++) {
          newhtml += "<div class=\"mlitem\" onClick=\"openOverlay(iwb[" + i + "],bandmarker[" + i + "]);\" onmouseover=\"highlightMarker(bandmarker[" + i + "]);\" onmouseout=\"normalizeMarker(bandmarker[" + i + "]);\"><b>" + band[i][1] + '</b><br>' + band[i][4] + "</div>";
        }
      $('#maplist_inner').html(newhtml);
      for(var i=0; i < band.length; i++) {
         iwb[i] = new google.maps.InfoWindow({
            content: '<div class="iwbox_bandinfo"><b>' + band[i][1] + '</b><br>' + band[i][4] + band[i][5] + '</div>'
        });
      }
      showBandCoords();
      
    }
  }
  
  
  
  function mapFullscreen() {
    if(document.getElementById('mapfstate').checked == false)
    {
       $('body').css("overflow","auto");
       $('#megamap').removeClass("fullscreen");
       $('#legend').removeClass("lfullscreen");
       $('#fs_legend').removeClass("lfullscreen_mini");
       $('#maplist').removeClass("fullscreenlist");
       
    }
    else
    {
       scrollTo(0,0);
       $('body').css("overflow","hidden");
       $('#megamap').addClass("fullscreen");
       $('#legend').addClass("lfullscreen");
       $('#fs_legend').addClass("lfullscreen_mini");
       $('#maplist').addClass("fullscreenlist");
    } 
    initialize("megamap",5,51.151786,10.415039);
    mapVenues(); 
    mapNewShows();
    mapOldShows();
    mapDiary();
    mapBand();
  }
  
  function mapOldShows() {
    if(document.getElementById('mapostate').checked == false)
       hideOldCoords();
    else
    {
       $.ajax({
              type     : "POST",
              async    : false,
              url      : "php/mapquery.php?mode=oldshows",
              cache    : false,
              dataType : 'json',
              success: function(data) {
                  object = data;
                  odate_coord = object[0];
                  odate_title = object[1];
                  odate_date = object[2];
                  var newhtml = "";
                  for(var i=0; i < odate_title.length;i++) {
                    newhtml += "<div class=\"mlitem\" onClick=\"openOverlay(iwo[" + i + "],odates[" + i + "]);\" onmouseover=\"highlightMarker(odates[" + i + "]);\" onmouseout=\"normalizeMarker(odates[" + i + "]);\">" + odate_date[i] + odate_title[i] + "</div>";
                  }
                 $('#maplist_inner').html(newhtml);
                  for(var i=0; i < odate_title.length; i++) {
                     iwo[i] = new google.maps.InfoWindow({
                        content: '<div class="iwbox">' + odate_date[i] + odate_title[i] + '</div>'
                    });
                  }
              },
          });
          showOldCoords();
    }
          
  }


function stinitialize() {
    var latlng = new google.maps.LatLng(51.151786,10.415039);
    var myOptions = {
      zoom: 6,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("sttmap"), myOptions);
    for(var i=0; i < stcoords.length;i++) {
          var lat = stcoords[i][0];
          var lon = stcoords[i][1];
          var latlon = new google.maps.LatLng(lat,lon);
          teamer[i] = new google.maps.Marker({
              position: latlon,
          });
          teamer[i].setMap(map);
           
     }
  }

var mapnums;  
function initialize(idname,myzoom,mylat,mylon) {
    var latlng = new google.maps.LatLng(mylat,mylon);
    var myOptions = {
      zoom: myzoom,
      center: latlng,
      mapTypeId: google.maps.MapTypeId.TERRAIN ,
      backgroundColor: '#000'
    };
    
    megamap = new google.maps.Map(document.getElementById(idname), myOptions);
    
     $.ajax({
              type     : "POST",
              async    : false,
              url      : "php/mapquery.php?mode=nums",
              cache    : false,
              dataType : 'json',
              success: function(data) {
                    mapnums = data;
                  },
          });
    
    $('#lband .num').html("(" + band.length + ")");
    $('#lvenues .num').html("(" + mapnums['venues'] + ")");
    $('#lcshows .num').html("(" + mapnums['newshows'] + ")");
    $('#loshows .num').html("(" + mapnums['oldshows'] + ")");
    $('#ldiary .num').html("(" + mapnums['diary'] + ")");
  }
  


function toggleHomeClip() {
  if($('#vimeo_uni').css("display") != "none")
  {
    $('#vimeo_uni').fadeOut('slow',
    function() {
      $('#youtube_uni').fadeIn();
      $('#yts').html("Go back to Vimeo-Clip");
    });
  }
  else
  {
    $('#youtube_uni').fadeOut('slow',
    function() {
      $('#vimeo_uni').fadeIn();
      $('#yts').html("You can't see a damn sh... ? Try Youtube Version");
    });
  }
  
  
} 

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}

function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function xDocHeight()
{
  var b=document.body, e=document.documentElement;
  var esw=0, eow=0, bsw=0, bow=0, esh=0, eoh=0, bsh=0, boh=0;
  if (e) {
    esw = e.scrollWidth;
    eow = e.offsetWidth;
    esh = e.scrollHeight;
    eoh = e.offsetHeight;
  }
  if (b) {
    bsw = b.scrollWidth;
    bow = b.offsetWidth;
    bsh = b.scrollHeight;
    boh = b.offsetHeight;
  }
  return Math.max(esh,eoh,bsh,boh);
}

function showGrayer() {
  $('#grayer').animate({height: xDocHeight() + 'px'});
  $('#grayer').fadeIn('slow');
  
}

function hideGrayer() {
  $('#grayer').fadeOut('slow');
}
                            
function loadNewsletterFinal()
{
   var fullURL = parent.document.URL 
   var querys = fullURL.substring(fullURL.indexOf('?')+3, fullURL.length)

   $.ajax({
    url: "php/newsletter_finish.php?" + querys,
    cache: false,
    success: function(html){
      showMsg(html,5000);
    }
    });
}

function showStreetText() {
  if(document.getElementById('text_ger').style.display=="none"){
      $('#text_en').fadeOut('slow',
      function() {
        $('#text_ger').fadeIn();
      }
      );
  }
  else {
     $('#text_en').fadeIn('slow',
      function() {
         $('#text_ger').fadeOut();
      }
     );
  }
}

function showNewsletterText() {
  if(document.getElementById('newsletter_ger').style.display=="none"){
      $('#newsletter_en').fadeOut('slow',
      function() {
        $('#newsletter_ger').fadeIn();
      }
      );
  }
  else {
     $('#newsletter_en').fadeIn('slow',
      function() {
         $('#newsletter_ger').fadeOut();
      }
     );
  }
}


function getWidth() {
    var myWidth = 0, myHeight = 0;
 
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return myWidth;
}

function getHeight() {
    var myWidth = 0, myHeight = 0;
 
    if( typeof( window.innerWidth ) == 'number' ) {
        //Non-IE
        myWidth = window.innerWidth;
        myHeight = window.innerHeight;
    } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
        //IE 6+ in 'standards compliant mode'
        myWidth = document.documentElement.clientWidth;
        myHeight = document.documentElement.clientHeight;
    } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
        //IE 4 compatible
        myWidth = document.body.clientWidth;
        myHeight = document.body.clientHeight;
    }
    return myHeight;
}



 function showTeam() {
  showGrayer();
  $('#street').animate({top: '-5px'});
}


function showLyrics(id)
{
  $('#lyrics_' + id).css("top",f_scrollTop() + 20 + "px");
  $('#lyrics_' + id).show();
  if($('#lyrics_inner_' + id).html() == "")
    loadItem('getlyrics','?lid=' + id,'lyrics_inner_' + id,1);
}

function hideLyrics(id){
  $('#lyrics_' + id).fadeOut();
}
     
function cOn(num) {
     $('#im' + num).animate({width: '140px',height: '140px'});
     $('#o' + num).fadeIn();
}

function cOn_disco(num) {
     $('#im' + num).animate({width: '100px',height: '100px'});
     $('#o' + num).fadeIn();
}

function cOut(num) {
     $('#im' + num).animate({width: '130px',height: '130px'});
     $('#o' + num).fadeOut();
}
function cOut_disco(num) {
     $('#im' + num).animate({width: '90px',height: '90px'});
     $('#o' + num).fadeOut();
}

function cOn_select(num) {
     $('#im' + num).animate({width: '70px',height: '70px'});
     $('#o' + num).fadeIn();
}

function cOut_select(num) {
     $('#im' + num).animate({width: '60px',height: '60px'});
     $('#o' + num).fadeOut();
}

function ctOn(num) {
     $('#imt' + num).animate({width: '200px',height: '200px'});
     $('#ot' + num).fadeIn();
}

function ctOut(num) {
     $('#imt' + num).animate({width: '190px',height: '190px'});
     $('#ot' + num).fadeOut();
}


function submitSlot() {

  /*if($("#to").attr("selectedIndex") == 0)
  {
    alert('Please select a recipient!\nBitte wähle einen Empfänger!');
    $('#to').focus();
    return false;
  }
    */
    
  if($('#name').val() == 'Bandname' || $('#name').val()=='')
  {
    alert('Bitte gib euren Bandnamen an!');
    $('#name').focus();
    return false;
  }  
  if($('#htname').val() == 'Euer Heimatort' || $('#htname').val()=='')
  {
    alert('Bitte gib euren Heimatort an!');
    $('#htname').focus();
    return false;
  }
  if($('#bemail').val() == 'E-Mail' || $('#bemail').val()=='')
  {
    alert('Bitte gib eure E-Mail-Adresse an!');
    $('#bemail').focus();
    return false;
  }
  
  if($('#url').val() == 'Homepage, Facebook- oder Myspace-Seite' || $('#url').val()=='')
  {
    alert('Bitte gib eine Webseite an!');
    $('#url').focus();
    return false;
  }
  
 
  

  $('#slot_submit').val('Sending...');
  $('#slot_submit').attr('disabled','disabled');
  $.post("php/supportslot_req.php", $("#form_slot").serialize(),
  function( data ) {
    showMsg('Thank you! We have received your message.');
    loadItem('supportslot');
  }
  
  );
  
  return false;
}


function submitContact() {

  if($("#to").attr("selectedIndex") == 0)
  {
    alert('Please select a recipient!\nBitte wähle einen Empfänger!');
    $('#to').focus();
    return false;
  }
  
  if($('#email').val() == 'E-Mail' || $('#email').val()=='')
  {
    alert('Please enter your e-mail address!\nBitte gib Deine E-Mail-Adresse an!');
    $('#email').focus();
    return false;
  }
  
  if($('#msg').val() == 'Message' || $('#msg').val()=='')
  {
    alert('Please enter your message!\nBitte gib Deine Nachricht ein!');
    $('#msg').focus();
    return false;
  }
  

  $('#contact_submit').val('Sending...');
  $('#contact_submit').attr('disabled','disabled');
  $.post("php/contact_req.php", $("#form_contact").serialize(),
  function( data ) {
    showMsg('Thank you! We have received your message.');
    loadItem('contact');
  }
  
  );
  
  return false;
}

function checkStreetForm() {

  if($('#fname').val() == 'First name *' || jQuery.trim($('#fname').val())=='')
  {
    alert('Please enter your first name!\nBitte gib Deinen Vornamen an!');
    $('#fname').focus();
    return false;
  }
  
  if($('#lname').val() == 'Last name *' || jQuery.trim($('#lname').val())=='')
  {
    alert('Please enter your last name!\nBitte gib Deine Nachnamen an!');
    $('#lname').focus();
    return false;
  }
  
  if($('#email').val() == 'E-Mail *' || jQuery.trim($('#email').val())=='')
  {
    alert('Please enter your e-mail address!\nBitte gib Deine E-Mail-Adresse an!');
    $('#email').focus();
    return false;
  }
  
  $('#street_submit').val('Sending...');
  $('#street_submit').attr('disabled','disabled');
  $.post("php/street_req.php", $("#street_form").serialize(),
  function( data ) {
    showMsg('Thank you! We have received your message.');
    loadItem('street','','street',1);
  }
  
  );
  
  return false;
}

function getComputedHeight(theElt){
    if(navigator.appName=='Microsoft Internet Explorer'){
        tmphght = document.getElementById(theElt).offsetHeight;
    }
    else{
        docObj = document.getElementById(theElt);
        var tmphght1 = document.defaultView.getComputedStyle(docObj, "").getPropertyValue("height");
        tmphght = tmphght1.split('px');
        tmphght = tmphght[0];
    }
    return tmphght;
}

function showNews(idn) {
  showGrayer();
  $('#home_msg').animate({top: f_scrollTop() + (Math.round(getHeight()) - 400)/2 + 'px'});
  $('#home_msg_html').html($('#news_c_' +  idn).html());
  $('#home_msg').fadeIn('slow');
}

function showMsg(html,timing) {
  var myt = 3000;
  if(timing != undefined)
    myt = timing;
  $('#success_msg').animate({top: f_scrollTop() + (Math.round(getHeight()) - 400)/2 + 'px'});
  $('#success_msg_html').html(html);
  $('#success_msg').fadeIn('slow');
  setTimeout("$('#success_msg').fadeOut('slow');",myt);
}

function checkNform() {
  if($('#nemail').val() == 'Your E-Mail *' || $('#nemail').val()=='')
  {
    alert('Please enter your e-mail address!\nBitte gib Deine E-Mail-Adresse an!');
    $('#nemail').focus();
    return false;
  }
  
  $('#nsub').val('Sending...');
  $('#nsub').attr('disabled','disabled');
  $.post("php/newsletter_req.php", $("#nform").serialize(),
  function( data ) { 
    showMsg('Thank you! you will receive an E-Mail!');
    loadItem('newsletter','','newsletter',1);
  }
  
  );
  return false;
  
}


function focIn(elem,val) {
  if($(elem).val()==val)
    $(elem).val('');
  $(elem).addClass("highIn");
}

function blurIn(elem,val) {
  if($(elem).val()=='')
    $(elem).val(val);
  $(elem).removeClass("highIn");
}

function loadText(lang) {
   var other;
   if(lang == 'de') other = 'eng';
   if(lang == 'eng') other = 'de';
   $('#bandtext_' + other).fadeOut('slow',
     function() {
      $('#bandtext_' + lang).fadeIn('slow');
     }
   );
   
   $('#sel_band').val(lang);
   
   $('#bandsubitem_' +  lang).animate({
    marginTop: '-25px'
    });
    
    $('#bandsubitem_' +  other).animate({
    marginTop: '-35px'
    });
   
}


function loadItem(sec,vars,divc,leturl,optvar)
{
  var myvars = "";
  if(vars != undefined)
  {
    myvars = vars.replace("?","&");
  }
  if(leturl != 1)
  {
      try {
        window.history.replaceState('Object', 'Samavayo.com - Cosmic Knockout', 'index.php?page=' + sec + myvars);
      }
      catch(e)
      {
      
      }
  }
  
  
  var varss;
  var aim = '#content_inner';
  if(vars!=undefined)
    varss = vars;
  else
    varss = "";
  if(divc != undefined )
      aim = '#' + divc;
  $(aim).fadeOut('slow',
  function() {
  $.ajax({
    url: "php/" + sec + ".php" + varss,
    cache: false,
    success: function(html){
      $(aim).html(html);
      $(aim).fadeIn(); 
      $('#bandpics a.pic').fancybox();
      $('#bandpicsall a').fancybox();
      $('a.diary_pics').fancybox();
      $('#albump a').fancybox();
      $('#flyer a').fancybox();
      loadBC();
      //loadShares();
      switch(sec)
      {
        case "shows":
          loadShowsComing();
          loadShowsPast();
          loadTourdiary();
          break;
          
        case "map":
          initialize("megamap",5,51.151786,10.415039);
          mapNewShows();
          break;
          
        case "home":
          loadShowsHome();
          loadTourdiaryHome();
          loadHomeNews();          
          break;
          
        case "album":
           $('.lyricsdiv').draggable();
           $('.lyricsdiv').draggable({cursor:'move'});
           $('.lyricsdiv').draggable({handle:'.close_lyrics_div'});
           break;
         
        case "tourdiary_gettext":
          
          $('#diary_list_inner').css("height",$('#tdtext_inner').css("height"));
          var sel = $('#selected_d').val();
          if(sel != "")
            $('#more_diary_' + sel).css("background-color", "#404040");
          $('#selected_d').val(optvar);  
          $('#more_diary_' + optvar).css("background-color", "#707070");
          try {
            window.history.replaceState('Object', 'Samavayo.com - Cosmic Knockout', 'index.php?page=tourdiary&text=' + optvar);
          }
          catch(e)
          {
          
          }
          break;  
      }
      
    }
    });     
  });
  var act = $('#mm_active').val();
  $('#mm_' + act).val('0');
  downMenu(document.getElementById('mmenu_' +  act),act);
  highMenu(document.getElementById('mmenu_' +  sec));
  $('#mm_' + sec).val('1');
  $('#mm_active').val(sec); 
}

function loadShowsComing() {
  $.ajax({
    url: "php/liveshowscoming.php",
    cache: false,
    success: function(html){
      $("#shows_inner").html(html);
    }
    });
}

function loadBC() {
  var fullURL = parent.document.URL 
  var querys = fullURL.substring(fullURL.indexOf('?')+1, fullURL.length)
  $.ajax({
    url: "php/breadcrumb.php?" + querys,
    cache: false,
    success: function(html){
      $("#breadc").html(html);
    }
    });
}

function loadShares() {
  html = '<!-- AddThis Button BEGIN -->';
  html += '<div class="addthis_toolbox addthis_default_style ">';
  html += '<a class="addthis_button_preferred_1"></a>';
  html += '<a class="addthis_button_preferred_2"></a>';
  html += '<a class="addthis_button_preferred_3"></a>';
  html += '<a class="addthis_button_preferred_4"></a>';
  html += '<a class="addthis_button_compact"></a>';
  html += '<a class="addthis_counter addthis_bubble_style"></a>';
  html += '</div>';
  html += '<!-- AddThis Button END -->';  
  loadobjs('http://s7.addthis.com/js/250/addthis_widget.js#pubid=ra-4e6b3f1e2fdff2c6');
  $('#sharbs').html(html);
}

function loadTourdiaryHome() {
  $.ajax({
    url: "php/tourdiary_home.php",
    cache: false,
    success: function(html){
      $("#diary_home_inner").html(html);
    }
    });
}

function loadHomeNews() {
  $.ajax({
    url: "php/homenews.php",
    cache: false,
    success: function(html){
      $("#news_inner").html(html);
    }
    });
}

function loadTourdiary() {
  
  $.ajax({
    url: "php/tourdiary_shows.php",
    cache: false,
    success: function(html){
      $("#diary_shows_inner").html(html);
    }
    });
}

function loadShowsHome() {
  $.ajax({
    url: "php/liveshowshome.php",
    cache: false,
    success: function(html){
      $("#home_shows_inner").html(html);
    }
    });
}

function loadShowsPast() {
  $.ajax({
    url: "php/liveshowspast.php",
    cache: false,
    success: function(html){
      $("#history_inner").html(html);
    }
    });
}

function showMenuItem(elem,sec) {
  if($(elem).css("marginLeft")=="-28px")
  {
    $(elem).animate({
     marginLeft: '-15px'
    });
  }
  else
  {
     $(elem).animate({
     marginLeft: '-28px'
    });
  }
       
}

function highMenu(elem)
{   
    $(elem).animate({
    marginLeft: '-15px'
    });
}

function downMenu(elem,sec) {
    if($('#mm_' + sec).val() == 0)
    {
      $(elem).animate({
      marginLeft: '-28px'
      });
    }
    
    
}

function downSub(elem)
{
    $(elem).animate({
    marginTop: '-25px'
    });
}

function upSub(elem)
{
    var sel = $('#sel_band').val();
    var tid = $(elem).attr('id');
    if('bandsubitem_' + sel != tid)
    {
      $(elem).animate({
      marginTop: '-35px'
      });
    }
    
}

function selectSelector(elem) {
    for(var i=1;i<=10;i++)
    {
      if($('#selector_' + i))
      {
        $('#selector_' + i).animate({
          width: '30px',
        }, 'slow');
        $("#selector_" + i + "_width").val("30");
      }
    }
    var eid = elem.getAttribute("id");
    var widelem = eid + "_width";
    var path = "";
    if(getWidth() > 1680)
      path = "1920";
    else
      path = "1680";
    
     $('body').css("background-image", "url(img/bg/" + path + "/" + eid + ".jpg)");
    $(elem).animate({
      width: '50px',
    }, 'slow');
    $("#" + widelem).val("50");
}

function highlightSelector(elem) {
      var eid = elem.getAttribute("id");
      var imgelem = eid + "_img";
      $(elem).animate({
        width: '150px',
        height: '125px'
      }, 'slow');
      $('#' + imgelem).animate({
        height: '125px'
      }, 'slow');     
}

var aktiv;
function hidepBarTO()
{
   
 aktiv = window.setTimeout("hidepBar()", 5000);
}

function hidepBar() {
      window.clearTimeout(aktiv);
      $('#playerbar').animate({
        top: '-410px'
      }, 'slow');
}

function hideDiv(id, offw) {
   window.clearTimeout(aktiv);
      $('#' + id).animate({
        top: offw + 'px'
      }, 'slow');
}


function showpBar() {
        showGrayer();
        $('#playerbar').animate({
          top: '-50px'
        }, 'slow');
        
}

function showDiv(id,onw) {
        showGrayer();
        $('#' + id).animate({
          top: onw + 'px'
        }, 'slow');
        
}

function resetSelector(elem) {
      var eid = elem.getAttribute("id");
      var imgelem = eid + "_img";
      var widelem = eid + "_width";
      mwid = $('#'+ widelem).val();
      $(elem).animate({
        width: mwid,
        height: '100px'
      }, 'slow');
      
      $('#' + imgelem).animate({
        height: '100px'
      }, 'slow');  
}

function highlightSelectorMini(elem) {
      $(elem).animate({
        width: '70px',
        height: '100px'
      }, 'slow');
}
function resetSelectorMini(elem) {
      $(elem).animate({
        width: '30px',
        height: '100px'
      }, 'slow');
}


   
