/***************************************************
		IMAGE ZOOM
***************************************************/
$(document).ready(function() {
	$("a.zoom img").mouseover(function(){
		$(this).stop(true,true);
		$(this).fadeTo(300, 0.5);
	});

	$("a.zoom img").mouseout(function(){
		$(this).fadeTo(400, 1.0);
	});
	
		// FancyBox
		$("a#contactform-inline").fancybox({
			'transitionIn'		:'elastic',
			'overlayShow'		:true,
			'speedIn'			:600,
			'titleShow':false
		});

});





/***************************************************
		PRETTYPHOTO  & Ajax contact form
***************************************************/

$(document).ready(function(){
	$("a[rel^='prettyPhoto']").prettyPhoto({animationSpeed:'slow',theme:'light_square',autoplay_slideshow: false});
	
	
		//Ajax Contact Form Submission
		$("#ajax-contact-form").submit(function(){
		var str = $(this).serialize();
		   $.ajax({
		   type: "POST",
		   url: "contact/contact.php",
		   data: str,
		   success: function(msg){
			$("#notification").ajaxComplete(function(event, request, settings){
			if(msg == 'OK') // Message Sent? Show the 'Thank You' message and hide the form
			{
			result = '<div class="notification_ok">Your message has been sent. Thank you!</div>';
			$("#fields").hide();
			}
			else
			{
			result = msg;
			}
			$(this).html(result);
			});
			}
		 });
		return false;
		});
});

	$(document).ready(function(){	
		$('#slider ul#panel').anythingSlider({
			delay: 7000,
			resizeContents      : true, 
			animationTime: 600,
			autoPlay: true,
			buildNavigation: false,
			hashTags: false, 
			easing: 'easeInExpo'
		});		
	});	

$(document).ready(function(){
//ANYTHING SLIDER NAVIGATION BUTTONS
	
/*	var q = ["#prev-button", "#next-button", ".arrow", ".forward", ".back"];
	var buttons = q.join(", ");
	
	$("#slider-area").hover( function() {
		$(buttons).stop().show()
	}).mouseleave( function() {
		$(buttons).stop().hide()
	});*/
});

	
	/// CUFON ////////////////////////////////////////////
 
    Cufon.replace('h1,h2,h3,h4,th,h5,.dropcap');
    
    // Submit Form
    
$(document).ready(function(){

	$(".topBG").fadeIn(6000,function() { activateBody("StepByStep") });

	$("#requestRueckrufSubmit").click(function() {

		name = jQuery.trim($("#rueckruf_name").val());
		firma = jQuery.trim($("#rueckruf_firma").val());
		telefon = jQuery.trim($("#rueckruf_telefon").val());
		action = "SendMailToDatabase";
		
		actionstring = "action="+action+"&name="+name+"&firma="+firma+"&telefon="+telefon;
		
	$.ajax({
		type: "POST",
		url: "flow.php",
		data: actionstring,
		success: function(msg){

			if(msg == "1") {
				$("#RueckrufFormDiv").html("<div class='notification_ok'>Ihre Anfrage hat uns erreicht.<br /><br />Besten Dank.<br /><br />Wir werden uns schnellstm&ouml;glich mit Ihnen in Verbindung setzen.</div>");
			} else {
				alert("Es ist ein Fehler aufgetreten beim Versenden des Formulars. Bitte kontrollieren Sie Ihre Eingabe. Vielen Dank.")
			}

		}
	});
		return false;
	})

	function blackout(action) {
		if(action == "in") {
			$(".blackout").fadeTo(500,0.6);			
		} else if(action == "out") {
			$(".blackout").fadeOut(500);
		}
	}

	$("a[href='#beratung']").click(function() {
		activateBody("all");
		blackout("in");
	});

	$(".blackout").click(function() {
			blackout("out");
		}
	);

	$(".inputbg").focus(function() {
		blackout("in");
	})
	
	function activateBody(method) {
		if(method == "all") {
			$("div[id^='mainStep']").fadeIn(500); 
		} else if(method == "slide") {
			$("div[id^='mainStep']").slideDown(750); 
		} else if(method == "StepByStep") {
			$("#mainStepOne").fadeIn(750,function () {
				$("#mainStepTwo").delay(2500).fadeIn(750,function () {
					$("#mainStepTwo-one").fadeIn(750,function () {
						$("#mainStepTwo-two").delay(2500).fadeIn(750,function () {
							$("#mainStepTwo-three").delay(2500).fadeIn(750, function () {
								$("#mainStepTwo-four").delay(2500).fadeIn(750, function () {
									$("#mainStepThree").delay(5000).slideDown(750, function () {
										$("#mainStepFour").delay(5000).fadeIn(1000, function () {
											$("#mainStepFive").delay(4000).slideDown(1000);
											});
										});
									});						
								});
							});
						});
					});
				});
		}

	}

	
	$("a[href='#weiterlesen']").click(function () {
		activateBody("StepByStep");
	});

	// Demo
	
	var demoLogin = "0";
	
	$("#launchDemo").click(function () {
		startDemo()
	}).hover(function () {
		$(this).attr('src','http://www.verwalten.ch/sliderimg_hover.png');
	}, function () {
		$(this).attr('src','http://www.verwalten.ch/sliderimg.png');
	});

	$("#launchDemoBottom").click(function () {
		startDemo();
	});

	$(".liveDemo").click(function () {
		closeDemo();
	});

	function closeDemo() {
		$(".liveDemo").fadeOut(500);
		$("body").css('overflow','scroll');
	}
	
	function startDemo() {
		
			// ScreenDimension
			
			w = $(window).width();
			h = $(window).height();
			
			spare = 25;
			w = w - spare*2;
			h = h - spare*2;
		
			$("body").css('overflow','hidden');
	
			currFrameURL = $(".liveDemoIframe").attr('src');
			
			if(demoLogin == 0) {
				frameSource = "http://edit-in-place-cms.com/admin.php";
			} else {
				frameSource = "http://edit-in-place-cms.com/";
			}

			$(".liveDemoIframe").css({
				'width' : w+'px',
				'height' : h+'px',
				'display' : 'block'
			});
						
			if(currFrameURL != frameSource) {
				$(".liveDemoIframe").attr('src',frameSource);
			}
			

			demoLogin = 1;
			$(".liveDemo").show();
		
	}



});
