
        
//twitter
$(window).ready(function() {
	$("#twitter").getTwitter({
		userName: "barbara_lohmann",
		numTweets: 3,
		loaderText: "News werden geladen...",
		slideIn: true,
		showHeading: false,
		headingText: " ",
		showProfileLink: false
	});
});

			
//form replace on form click
function remName(a, b){
  if(a.value==b){
    a.value='';
    a.style.color='#454545';
  }else if(a.value==''){
    a.value=b;
    a.style.color='#9c9c9c';
  }else{
    a.value=a.value;
  }
}   
function chkName(a, b){
  if(a.value==''){
    a.value=b;
    a.style.color='#9c9c9c';
  }else{
    a.value=a.value;   
  }
}

//probe pic change
var probe_previous=0;
function probe(value){  
  document.getElementById('probe_l'+probe_previous).style.display='none';
  document.getElementById('probe_l'+value).style.display='block';
  probe_previous=value;
}

//browser check
function checkBrowserName(name){  
  var agent = navigator.userAgent.toLowerCase();  
  if (agent.indexOf(name.toLowerCase())>-1) { 
    return true;  
  }  
  return false;  
}  

//vertical centering
function centervertical() {  
  var windowHeight = 0;
  var contentHeight = 650; //should match the total content height
  var differ = 0;
  
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body && document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}                                                                  
  if(windowHeight<contentHeight){    
    differ=contentHeight-windowHeight;
    if(differ>40){differ=40;}    
    windowHeight=contentHeight;                                                                 
  }
  var bottomspace;                    
  if(checkBrowserName('iphone') || checkBrowserName('ipad') || checkBrowserName('MSIE')){
    bottomspace=40;
    }else{
    bottomspace=65;
  }
  
  document.getElementById('wrapper').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 5 + 'px'; //extra distance to remove ipad bottom scrollbar
  //document.getElementById('header').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 'px';
  document.getElementById('header').style.top = 0 + 'px';
  //document.getElementById('footer').style.top = ((windowHeight / 2) - ((contentHeight+differ*2) / 2)) + 620 + 'px';  
  document.getElementById('footer').style.top = windowHeight-differ-bottomspace + 'px';
  document.getElementById('popuppicture').style.top = ((windowHeight / 2) - (document.getElementById('popuppicture').clientHeight / 2)) -10 + 'px';      
  document.getElementById('popupvideo1').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 160 + 'px';
  document.getElementById('katalog').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 160 + 'px';
  document.getElementById('newsletter').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 190 + 'px';
  document.getElementById('presse').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 100 + 'px';
  document.getElementById('impressum').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 80 + 'px';
  document.getElementById('stores').style.top = ((windowHeight / 2) - (contentHeight / 2)) + 160 + 'px';
}
//overlay resize and center site on load and window resize
if(!checkBrowserName('iphone') && !checkBrowserName('ipad')){
  window.onload = function() {
    centervertical();      
  }
  window.onresize = function() {
  	centervertical();
  	setoverlay();
  }
}

//on iphone/ipad orientation change
function setHeight() {
  centervertical();
  setoverlay();
  sizeImage(picAligns[picIdActual-1]);
  //vertical iphone/pad scrollung enabled                   
  document.getElementById('wrapper').style.height = window.innerHeight + 'px';
}

//ipad/phone scrolling abillity
var myScroll;            
function loaded(){    
	if(checkBrowserName('iphone') || checkBrowserName('ipad')){
    setHeight();
    myScroll = new iScroll('scroller');    
  }
}
if(!checkBrowserName('MSIE')){                                    
  window.addEventListener('resize', setHeight, false);
  document.addEventListener('touchmove', function(e){ e.preventDefault(); }, true);
  document.addEventListener('DOMContentLoaded', loaded, false);
}
  
//mousewheel disabled
if(checkBrowserName('firefox')){
  document.addEventListener('DOMMouseScroll', function(e){
      e.stopPropagation();
      e.preventDefault();
      e.cancelBubble = false;
      return false;
  }, false);
}
if(checkBrowserName('safari')){
  document.addEventListener('mousewheel', function(e){
      e.stopPropagation();
      e.preventDefault();
      e.cancelBubble = false;
      return false;
  }, false);
}
if(checkBrowserName('opera')){
  document.attachEvent('mousewheel', function(e){
      if (!e) var e = window.event;
      e.returnValue = false;
      e.cancelBubble = true;
      return false;
  }, false);
}



//scrolling via button for all browsers (different scripts)
function jumpto(value){
  if(myScroll){
    myScroll.scrollTo(value*-1,0);
  }else{
    $.scrollTo(value, {duration:500,axis:'x'});
  }
}  


//overlay (popup and background)
function getPageSize() { //as seen in so many api's
    var xScroll, yScroll;
    var minContentHeight = 680;
    if (window.innerHeight && window.scrollMaxY) {	
    	xScroll = window.innerWidth + window.scrollMaxX;
    	yScroll = window.innerHeight + window.scrollMaxY;
    } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
    	xScroll = document.body.scrollWidth;
    	yScroll = document.body.scrollHeight;
    } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
    	xScroll = document.body.offsetWidth;
    	yScroll = document.body.offsetHeight;
    }
    var windowWidth, windowHeight;
    if (self.innerHeight) {	// all except Explorer
    	if(document.documentElement.clientWidth){
    		windowWidth = document.documentElement.clientWidth; 
    	} else {
    		windowWidth = self.innerWidth;
    	}
    	windowHeight = self.innerHeight;
    } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
    	windowWidth = document.documentElement.clientWidth;
    	windowHeight = document.documentElement.clientHeight;
    } else if (document.body) { // other Explorers
    	windowWidth = document.body.clientWidth;
    	windowHeight = document.body.clientHeight;
    }	
    // for small pages with total height less then height of the page			
    if(minContentHeight < windowHeight){
    	pageHeight = windowHeight;
    } else { 
    	pageHeight = minContentHeight;
    }			
    pageWidth = windowWidth;
    
    arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);	     		
    return arrayPageSize;
};

//popup picture and video

var picIdActual;  
var picAligns=new Array('h','v','v','v','h','h','h','v','v','h','v','v','v','v','h','h','h','v','v','h','v','v','h','h');
var picTotal=24; 

function nextpic(){
  picIdActual++;
  if(picIdActual>picTotal){picIdActual=1}
  $('#popupimage').attr('src', '');
  displayImage(picIdActual);  
}
function prevpic(){
  picIdActual--;
  if(picIdActual<1){picIdActual=picTotal}
  $('#popupimage').attr('src', '');
  displayImage(picIdActual);
}
function displayImage(id){        
    setoverlay();                                 
    $('#overlay').show();  
    $('#popup').show();
    $('#popuppicture').show(); 
    //set picture
    $('#popupimage').hide();                                                                                                         
    $('#picloading').show();                                                                                                                                                             
    sizeImage(picAligns[id-1]);    
    addzero='';
    if(id<10){addzero='0';}  
    $('#popupimage').attr('src', 'pix/kol'+addzero+id+'.jpg')
      .load(function() { $('#popupimage').show(); $('#picloading').hide();})
      .error(function() {  });    
    picIdActual=id;                    
}
function sizeImage(align){
    var arrPageSizes = getPageSize();
    var piclongest=2048;
    var picshortest=1320;
    var picspace=50;
      
    if(align=='h'){
      var picwidth=piclongest;
      var picheight=picshortest;
    }else{
      var picwidth=picshortest;
      var picheight=piclongest;
    }    
    var hrel=arrPageSizes[0]/picwidth;
    var vrel=arrPageSizes[1]/picheight;
    //horizontal picture relation smaller 
    if(hrel<vrel){
      $('#popuppicture').width(arrPageSizes[0]-picspace*2);
      $('#popuppicture').height(picheight*((arrPageSizes[0]-picspace*2)/picwidth));  
    //vertical picture relation smaller      
    }else{
      $('#popuppicture').height(arrPageSizes[1]-picspace*2);
      $('#popuppicture').width(picwidth*((arrPageSizes[1]-picspace*2)/picheight));        
    } 
    centervertical();
}

function setoverlay(){
    var arrPageSizes = getPageSize();
    $('#overlay').width(arrPageSizes[0]);
		$('#overlay').height(arrPageSizes[1]);
		$('#popup').width(arrPageSizes[0]);
		$('#popup').height(arrPageSizes[1]);		
}

//video or content popup display
function displaypopup(type,sa1,sa2){  
    setoverlay();          
    $('#popup').show();
    $('#popup').show();
    $('#'+type).show();
    $('#overlay').show();              
    if(type=='popupvideo1'){
      if(checkBrowserName('iphone') || checkBrowserName('ipad')){      
        var video = document.getElementsByTagName("video");
        video[0].src = "pix/fotoshoot.mp4";
        video[0].load();
      }
      stopslideshow();                   
    }else if(type=='stores'){
      $('#storehl').text(sa1);
      $('#hidden_st').attr('value',sa2);   
    }
}

//popup hide
function hideoverlay(type){
    $('#overlay').hide();  
    $('#popup').hide();
    $('#popuppicture').hide();
    $('#popupimage').hide();
    $('#'+type+' .error').hide();              
    $('#'+type).hide();
    if(checkBrowserName('MSIE')){
      document.getElementById('flashplayer').sendEvent('STOP');
    }else{
      document.getElementById('videoarea').pause();
    }
    if(type=='popupvideo1'){
      setslideshow();
    }  
}   

//image slideshow
$(function(){
  $('.videoslide img:gt(0)').hide();
  });
var inter;  
function setslideshow(){              
  inter=setInterval(function(){
    $('.videoslide :first-child').fadeOut()
       .next('img').fadeIn()
       .end().appendTo('.videoslide');}, 
    3000);
};
setslideshow();
function stopslideshow(){
  clearInterval(inter);
}                              