
$(document).ready(function() { 
  if (arguments.callee.done) return;
  arguments.callee.done = true;
  
	function formatText(index, panel) {
    return index + "";
  }
  $(function () {
  
      $('.anythingSlider').anythingSlider({
      easing: "easeInOutExpo",
      autoPlay: true,
      delay: 5000,
      startStopped: true,
      animationTime: 600,
      hashTags: false,
      buildNavigation: false,
  		pauseOnHover: true,
  		startText: "Start",
      stopText: "Stop",
      navigationFormatter: formatText
      });
      
      $("#slide-jump").click(function(){
          $('.anythingSlider').anythingSlider(6);
      });
  });
  $(".tt[title]").tooltip({ effect: 'bouncy' });
});

// create custom animation algorithm for jQuery called "bouncy"
$.easing.bouncy = function (x, t, b, c, d) {
    var s = 1.70158;
    if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
    return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
}

// create custom tooltip effect for jQuery Tooltip
$.tools.tooltip.addEffect("bouncy",

	// opening animation
	function(done) {
		this.getTip().animate({top: '+=15'}, 500, 'bouncy', done).show();
	},

	// closing animation
	function(done) {
		this.getTip().animate({top: '-=15'}, 500, 'bouncy', function()  {
			$(this).hide();
			done.call();
		});
	}
);

function toggleLayer(id) {
  if (document.getElementById(id).style.display != 'block') {
    document.getElementById(id).style.display = 'block';
  }
  else {
    document.getElementById(id).style.display = 'none';
  }
}

function clearInfo(id) {
  if (id == 'newsletter') {
    if (document.getElementById(id).value == 'meine@email-adresse.de') {
      document.getElementById(id).value = '';
    }
  }
}

var reqSend = false;
function req(type){
  if (reqSend) {
    alert("Ihre Daten werden bereits gesendet.\nBitte warten Sie auf die Antwort des Servers!");
    return false;
  }
  reqSend = true;
  var chkForm = [];
  if (type == 'callback') {
    chkForm[0] = new Array("name",/[a-zA-Z]+/,"Bitte geben Sie Ihren Namen an!");
    chkForm[1] = new Array("telefon",/[0-9]{3,}/,"Bitte geben Sie Ihre Telefonnummer an!");
  }
  else {
    chkForm[0] = new Array("email",/@/,"Bitte geben Sie Ihren E-Mail Adreese an!");
  }
  for (var i = 0, ln = chkForm.length; i < ln; i++) {
    if(!chkForm[i][1].test(document.forms[type][chkForm[i][0]].value)){
    	alert(chkForm[i][2]);
    	document.forms[type][chkForm[i][0]].focus();
    	reqSend = false;
    	return false;
    }
  }

  var w = 400;
  var h = 250;
  h = h - 20; 
  var x=0, y=0, parameter="";
  if (w < screen.availWidth || h < screen.availHeight) {
     x = (screen.availWidth - w - 12) / 2;
     y = (screen.availHeight - h - 104) / 2;
     if (window.opera) y = 0;
     if (x<0 || y<0) { x=0; y=0; }
     else parameter = "width=" + w + ",height=" + h + ",";
  }
  parameter += "left=" + x + ",top=" + y;
  var name = '';
  var telefon = '';
  var email = '';
  if (type == 'callback') {
    name = document.forms[type]['name'].value;
    telefon = document.forms[type]['telefon'].value;
  }
  else {
    email = document.forms[type]['email'].value;
  }
  window.open('/quicksend.php?type='+type+'&name='+name+'&telefon='+telefon+'&email='+email,'callback',parameter+",scrollbars=no,menubar=no,location=no,toolbar=no,status=no,resizable=no");
  reqSend = false;
  return false;
}


  
