
  $(document).ready(function() {



	// MAINTABS

	  $(".mainTab").hover(
 		function () {
    		$(this).find('.mainPopout, .tab').addClass("active");
  		},
  		function () {
  	$(this).find('.mainPopout, .tab').removeClass("active");
  		});

  		 $("li.locations").hover(
 		function () {
    		$(this).parents("ul.mainNav").find('ul.mainNav.lvl2').addClass("active");
  		},
  		function () {
  	$(this).parents("ul.mainNav").find('ul.mainNav.lvl2').removeClass("active");
  		});


	// locationSnap


	$(".info").hover(
 		function () {
    		$(this).find(".infoBlock").animate({ marginTop: "3px" }, 150, 'swing');
    		},

  		function () {
  	$(this).find(".infoBlock").animate({ marginTop: "160px" }, 150, 'swing');
  	});



    $('.quoteButton, p.cancel').live('click', function(){
    	$('.quoteForm').slideToggle("fast",function() { 
				if($(".quoteForm").is(":visible"))
		      jQuery.scrollTo( '#scrolltoform', 800);
    		});
//    	$("button").html("SENDEN");
    	$("p#RegisterErrors").css('display', 'none');
    });


    $("p.cancel").click(function () {
      $(".quoteForm input").val("");
      $("div").removeClass("error");
    });


     $(".sectionheader.br").hover(
 		function () {
    		//$(this).animate({ opacity: 0.25}, 500 )
    		},

  		function () {
  	// $(this).removeClass("active");
  		});


    	/* This is basic - uses default settings */

	$("a.single_image").fancybox({
		'overlayColor' : '#F1F1F1'

	});

	/* Using custom settings */

	$("a#inline").fancybox({
		'hideOnContentClick': true,
		'overlayColor' : '#F1F1F1',
		'speedOut'		:	20,
		'speedIn'		:	20,
		'transitionOut' : 'none'
	});

	/* Apply fancybox to multiple items */

	$("a.group").fancybox({
		'changeFade'	:	'fast',
		'overlayShow'	:	true,
		'hideOnOverlayClick'	: 'true',
		'overlayColor'	: '#F1F1F1',
		'padding'	: 10,
		'transitionIn' : 'none',
		'transitionOut' : 'none',
		'changeSpeed' : 300,
		'changeFade' : 'fast',
		'titleShow' : 'true',
		'titlePosition' : 'inside'

	});

	$('table.locationOverview tr:even, table.locationSingle tr:even, table.costComparison tr:even').addClass('even');
	$('td:last-child, th:last-child, div.inner div.wrapper:last-child, form fieldset:last-child, ul.mainNav li:nth-child(3)').addClass('last');
	$("table.locationSingle td:nth-child(2)").addClass('border');

	$('span.switch').click(function () {
		$(this).toggleClass('active').siblings().toggleClass('active');
		$(this).parents('.teaserBox').find('div.table').toggleClass('hidden');


	});

    $("#slider-1, #slider-2, #slider-3, #slider-4").hover(
 		function () {
    		$(this).find('.nivo-prevNav, .nivo-nextNav').animate({ opacity: '1' }, "fast");
  		},
  		function () {
  	$(this).find('.nivo-prevNav, .nivo-nextNav').animate({ opacity: '0.4' }, "fast");
  		});

    $('.clickable').fitted();





    /* Form validate options */

    $(document).ready(function() {

	// validate signup form on keyup and submit
	$("#freeform").validate({
	errorLabelContainer: $("#RegisterErrors"),

		rules: {
			first_name: "required",
			last_name: "required",
			phone: "required",
			message: "required",
			street: "required",
			city: "required",
			subject: "required",

			entryy: "required",
			email: {
				required: true,
				email: true
			},

			captcha: 
			{ required: true,
				equalTo: '#get_name'
			},
			agree: "required"
		},
			highlight: function(element){
				$(element.form).find("div[id="+element.id +"]")
                                                   .addClass('error');
                },
			unhighlight: function(element){
				$(element.form).find("div[id="+element.id +"]")
                                                .removeClass('error');
                                                $(element.form).find("div[id="+element.id +"]")
                                                .removeClass('captcha');
                },


		messages: {
			first_name: "",
			last_name: "",
			phone: "",
			message: "",
			street: "",
			city: "",
			subject: "",
			captcha: "",
			entryy: "",
			password: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long"
			},
			
			confirm_password: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long",
				equalTo: "Please enter the same password as above"
			},
			email: "<!-- <br /><br />Bitte geben Sie eine g&uuml;ltige Email-Adresse an. -->",
			agree: "Please accept our policy"
		}
	});



	// validate signup form on keyup and submit
	$(".kontaktform").validate({
	errorLabelContainer: $("#RegisterErrors"),

		rules: {
			first_name: "required",
			last_name: "required",
			message: "required",
			captcha: 
			{ required: true,
				equalTo: '#get_name'
			},

			entryy: "required",
			email: {
				required: true,
				email: true
			},

			agree: "required"
		},
			highlight: function(element){
				$(element.form).find("div[id="+element.id +"]")
                                                   .addClass('error');
                },
			unhighlight: function(element){
				$(element.form).find("div[id="+element.id +"]")
                                                .removeClass('error');
                                                $(element.form).find("div[id="+element.id +"]")
                                                .removeClass('captcha');
                },


		messages: {
			first_name: "",
			last_name: "",
			phone: "",
			message: "",
			street: "",
			city: "",
			subject: "",
			captcha: "",
			entryy: "",
			password: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long"
			},
			
			confirm_password: {
				required: "Please provide a password",
				minlength: "Your password must be at least 5 characters long",
				equalTo: "Please enter the same password as above"
			},
			email: "<!-- <br /><br />Bitte geben Sie eine g&uuml;ltige Email-Adresse an. -->",
			agree: "Please accept our policy"
		}
	});

});



/* SWITCH SERVICELIST */

		$("span.tabSwitch").click(
			function (){
				var activeTab = $(this).attr("rel");
				$(this).addClass("active").siblings().removeClass("active");
				$(this).parents("div.serviceList").find("ul.featureList."+activeTab+"").addClass("active").siblings("ul").removeClass("active");
			});


/* FORM AJAX */

  //bind form using 'ajaxForm'
  $('#freeform').ajaxForm({
   // target:"#hiddenDIV",
   // beforeSubmit:function() {
   //    $("button").html("SENDING &hellip;");
       // $("#msg").css({border:"1px solid #a00", backgroundColor:"#fdd"});
   // },
    success:function(response) {
      if (response=="thanks") {

				document.location= document.location + '?ready=true#scrolltothank';

      	//alert("success");

/* google conversations den Seiten in denen die conversation gezaehlt werden soll wurde ein der name der einzubindenen js datei als klasse zugewiesen 

				if(jQuery('body').hasClass('offices'))
					jQuery("body.offices").append('<div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1068604521/?label=tvbzCKP8oAIQ6bjG_QM&guid=ON&script=0"/></div>');
//					$.getScript('/_assets/scripts/googleconversation/office.js');

				if(jQuery('body').hasClass('virtual-office'))
					jQuery("body.virtual-office").append('<div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1068604521/?label=5CvdCJv9oAIQ6bjG_QM&guid=ON&script=0"/></div>');
//					$.getScript('/_assets/scripts/googleconversation/virtual-office.js');

				if(jQuery('body').hasClass('conference-rooms'))
					jQuery("body.conference-rooms").append('<div style="display:inline;"><img height="1" width="1" style="border-style:none;" alt="" src="http://www.googleadservices.com/pagead/conversion/1068604521/?label=AJf-CJP-oAIQ6bjG_QM&guid=ON&script=0"/></div>');
//					$.getScript('/_assets/scripts/googleconversation/conference-rooms.js');

        $("#freeform").resetForm();
        $(".form").html("<div class='grid_17 thanks'><h2>Vielen Dank für Ihre Nachricht.</h2><p>Wir werden uns umgehend bei Ihnen melden.</p><p class='cancel'>Schliessen</p></div>");

*/

      } else if (response=="error"){

      $("#captcha").addClass("error")
} else {
        $("#msg").html(  $("#hiddenDIV #content ul").html() );
        $("#hiddenDIV").empty();
      }
    }
  });


 }); // close
 
/**
 * jQuery.ScrollTo - Easy element scrolling using jQuery.
 * Copyright (c) 2007-2009 Ariel Flesler - aflesler(at)gmail(dot)com | http://flesler.blogspot.com
 * Dual licensed under MIT and GPL.
 * Date: 5/25/2009
 * @author Ariel Flesler
 * @version 1.4.2
 *
 * http://flesler.blogspot.com/2007/10/jqueryscrollto.html
 */
;(function(d){var k=d.scrollTo=function(a,i,e){d(window).scrollTo(a,i,e)};k.defaults={axis:'xy',duration:parseFloat(d.fn.jquery)>=1.3?0:1};k.window=function(a){return d(window)._scrollable()};d.fn._scrollable=function(){return this.map(function(){var a=this,i=!a.nodeName||d.inArray(a.nodeName.toLowerCase(),['iframe','#document','html','body'])!=-1;if(!i)return a;var e=(a.contentWindow||a).document||a.ownerDocument||a;return d.browser.safari||e.compatMode=='BackCompat'?e.body:e.documentElement})};d.fn.scrollTo=function(n,j,b){if(typeof j=='object'){b=j;j=0}if(typeof b=='function')b={onAfter:b};if(n=='max')n=9e9;b=d.extend({},k.defaults,b);j=j||b.speed||b.duration;b.queue=b.queue&&b.axis.length>1;if(b.queue)j/=2;b.offset=p(b.offset);b.over=p(b.over);return this._scrollable().each(function(){var q=this,r=d(q),f=n,s,g={},u=r.is('html,body');switch(typeof f){case'number':case'string':if(/^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(f)){f=p(f);break}f=d(f,this);case'object':if(f.is||f.style)s=(f=d(f)).offset()}d.each(b.axis.split(''),function(a,i){var e=i=='x'?'Left':'Top',h=e.toLowerCase(),c='scroll'+e,l=q[c],m=k.max(q,i);if(s){g[c]=s[h]+(u?0:l-r.offset()[h]);if(b.margin){g[c]-=parseInt(f.css('margin'+e))||0;g[c]-=parseInt(f.css('border'+e+'Width'))||0}g[c]+=b.offset[h]||0;if(b.over[h])g[c]+=f[i=='x'?'width':'height']()*b.over[h]}else{var o=f[h];g[c]=o.slice&&o.slice(-1)=='%'?parseFloat(o)/100*m:o}if(/^\d+$/.test(g[c]))g[c]=g[c]<=0?0:Math.min(g[c],m);if(!a&&b.queue){if(l!=g[c])t(b.onAfterFirst);delete g[c]}});t(b.onAfter);function t(a){r.animate(g,j,b.easing,a&&function(){a.call(this,n,b)})}}).end()};k.max=function(a,i){var e=i=='x'?'Width':'Height',h='scroll'+e;if(!d(a).is('html,body'))return a[h]-d(a)[e.toLowerCase()]();var c='client'+e,l=a.ownerDocument.documentElement,m=a.ownerDocument.body;return Math.max(l[h],m[h])-Math.min(l[c],m[c])};function p(a){return typeof a=='object'?a:{top:a,left:a}}})(jQuery);

    function switchLanguage(lang) {
			var first = document.location.href;
			if(lang=='de') var now = first.replace(/\/en\//,"/de/");
			else var now = first.replace(/\/de\//,"/en/");
			document.location.href=now;
    }
    
