
/*
===============================================================================

 template: Template 27 - JS

===============================================================================
*/

/* -------------------------------------------------------------
	{URL} - jQuery
	- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
	Autor:		i.A. (SSo)
	Company:	onOffice Software GmbH
	Release:	1.0
	------------------------------------------------------------- */

	$(document).ready(function() {

		/* -------------------------------------------------------------
		Defaults Function
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		defaults();

		/* -------------------------------------------------------------
		Forms Function
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		forms();

		/* -------------------------------------------------------------
		Open mobile navigation
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		// $('.open-mobile-navigation').click(function() {
		// 	mobileNavigationCheck();
		// 	return false;
		// });

		/* -------------------------------------------------------------
		Slider
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		/* -------------------------------------------------------------
        Slider
        - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

        if( !$('.slider-large .animation').hasClass('smartsitebanner-individual') )
        {

            if($('.slider-large .animation img').length >= 1)
            {
                $('.slider-large .animation img').each(function(index)
                {
                    var cssTop = '';

                    if($(this).attr('data-top') != undefined)
                    {
                        cssTop = ' background-position: center ' + $(this).attr('data-top');
                    }

                    $('.slider-large .animation').append('<div style="background-image: url(' + $(this).attr('src') + ');' + cssTop + '" id="slide-' + index + '"></div>');
                    $(this).hide().remove();
                });

                if($('.slider-large .animation div').length >= 2)
                {

                    var img_timeout = 6500;
                    var img_speed   = 4000;

                    $('.slider-large .animation div').each(function(index)
                    {
                        $(this).attr('id', 'slide-' + index);

                        $('.slider-large .slider-navigation p').append('<span data-slide="slide-' + index + '"></span>');
                    });

                    $('.slider-large .animation div:first').fadeIn().addClass('selected');
                    $('.slider-large .animation div:last').addClass('last');

                    $('.slider-large .slider-navigation p span:first').addClass('selected');

                    var slider = setInterval('$.fn.mySlider()', img_timeout);

                    $('.slider-large .slider-navigation p span').click(function()
                    {
                        $('.slider-large .animation div.selected').fadeOut(img_speed).removeClass('selected');
                        $('#' + $(this).attr('data-slide')).fadeIn(img_speed).addClass('selected');

                        $('.slider-large .slider-navigation p span.selected').removeClass('selected');
                        $(this).addClass('selected');

                        clearInterval(slider);
                        slider = setInterval('$.fn.mySlider()', img_timeout);
                    });
                }
                else {
                    $('.slider-large .animation div:first').fadeIn().addClass('selected');
                }
            }
        }

        /* -------------------------------------------------------------
		Startseite
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.homepage .grid-33:nth-child(3n)').after('<div class="clear"></div>');

		/* -------------------------------------------------------------
		Open mobile sub navigation
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.open-mobile-sub-navigation').click(function() {
			var thisSub = $(this).parent('li'),
			thisSubIcon = $(this).find('i'),
			thisSubId   = $('#' + $(this).attr('data-sub'));

			if( thisSub.hasClass('open') ) {
				thisSubId.slideUp('fast', function() {
					thisSub.removeClass('open');
					thisSubIcon.removeClass('icon-caret-up').addClass('icon-caret-down');
				});
			} else {
				thisSubId.slideDown('fast', function() {
					thisSub.addClass('open');
					thisSubIcon.removeClass('icon-caret-down').addClass('icon-caret-up');
				});
			}

			return false;
		});

		/* -------------------------------------------------------------
		Google Maps Standort
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		/*$('.google-maps-footer').each(function()

		{

			googleMaps($(this).find('input').val(), $(this).attr('id'));

		});*/


		/* -------------------------------------------------------------
		Interessenten / Eigentümer Formular
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		// $('.interessentenformular h3 , .eigentuemerformular h3').addClass('headline');

		/* -------------------------------------------------------------
		Social Media
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		if($.trim($('.social-media ul').html()) == '') {

			$('.social-media').hide().remove();

		}

		/* -------------------------------------------------------------
		Grid Test
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		var gridLength_1_layer = $('.new-grid > .grid').length;
		
		$('.new-grid > .grid').each(function(){

			var gridLength_2_layer = $(this).find('> .grid').length;

		});

		/* -------------------------------------------------------------
		Forms
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		// display feedback

		if ( $.trim($('.feedback-error').html()) != '' )
		{
			$('.feedback-error').prepend('<i class="fa fa-exclamation"></i>').addClass('visible');
		}
		else if ( $.trim($('.feedback-success').html()) != '' )
		{
			$('.feedback-success').prepend('<i class="fa fa-check"></i>').addClass('visible');
			$('.hide-on-success').hide();
		}

		// all forms

		var anrede = $('.hinput-anrede').val();

		$('.select-anrede option').each(function(){

			if ( $(this).attr('value') == anrede )
			{
				$(this).attr('selected','selected');
			}

		});

		// interest, provider

		$('.wrap-kaufpreis, .wrap-mietpreis').hide();

		$('.select-objekttyp option').each(function(){

			var objekttyp = $('.hinput-objekttyp').val();

			if ( $(this).attr('value') == objekttyp )
			{
				$(this).attr('selected','selected');
			}

		});

		$('#vermarktungsart option').each(function(){

			var vermarktungsart = $('.hinput-vermarktungsart').val();

			if ( $(this).attr('value') == vermarktungsart )
			{
				$(this).attr('selected','selected');
			}

		});

		/* -------------------------------------------------------------
		I-service
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */		

		$('.iservice-listobject').each(function(){

			$(this).find('tr').each(function(){

				var contentTd = $.trim($(this).find('td:eq(2)').html());

				if (contentTd == '') {

					$(this).hide().remove();

				}

			});

			$(this).find('tr:even').addClass('grey');

		});

		/* -------------------------------------------------------------
		Objekttracking
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.objektdaten table').each(function(){

			$(this).find('tr').each(function(){

				$(this).find('td:even').addClass('left-table-cell table-cell');

				$(this).find('td:odd').addClass('right-table-cell table-cell');

			});

		});

		/* -------------------------------------------------------------
		Obj tracking
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.showmore').hide();

		$('.objekttracking .link , .objekttracking .listenrahmen a').addClass('button');

		$('.objekttracking .tracking-details td').removeClass('headline');

		$('.tracking-details .links').addClass('grid-100');

		$('.tracking-details .links a').addClass('button');

		/* -------------------------------------------------------------
		Menu
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
		
		$('.menu_layer1 ul li.startseite a').html('<i class="icon-home"></i>');

		$('.menu_layer1 ul , .menu_layer2 ul').addClass('grid-100');

		menuWidthlayer('.menu_layer1');

		// menuWidthlayer('.menu_layer2');

		$('.menu_layer2 > .wrapper-center > ul > li:last').addClass('no-border');

		var menuLayer2Selected = $('.menu_layer2 .wrapper-center ul li a').hasClass('selected');

		if (menuLayer2Selected === false) {

			$('.menu_layer2 ul').animate({ 'top': '0px' }, 600 );

		}

		else {

			$('.menu_layer2 ul').css('top','0px');
		
		}

		if($.trim($('.menu_layer2 .wrapper-center').html()) == '') {

			$('.menu_layer2').hide().remove();

		}

		/* -------------------------------------------------------------
		Topobjekte
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.tabs a').addClass('button');

		$('.tab-content > div').not('.tab-content > div:first').addClass('hidden');

			$('.tabs ul li').click(function(){

			$('.tabs a').removeClass('selected');

			$('.tab-content > div').addClass('hidden');

			var tabID = $(this).find('a').attr('href');

			$(this).find('a').addClass('selected');

			$('.tab-content').find(tabID).removeClass('hidden');

			return false;

		});

		$('.tab-content > div > div').each(function(){

			var tabContent = $.trim($(this).html());

			if(tabContent == '') {

				var tabContentID = '#' + $(this).parent().attr('id');

				$('.tabs ul li').each(function(){

					var tabContentHref = $(this).find('a').attr('href');

					console.log(tabContentHref);

					if(tabContentID == tabContentHref) {

						$(this).hide();
					
					}

				});
			
			}

		});

		$('.tabs a:visible:first').addClass('selected').click();

		$('.top-container').each(function(){

			$(this).find('tr:last td').css('border-width','0');

		});

		/* -------------------------------------------------------------
		Slickslider Topobjekte
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		makeBackgroundImage();

		$('#startseiteobjecttop0 .top-objekte, #startseiteobjectall0 .top-objekte, #startseiteobjectall1 .top-objekte, #startseiteobjectreference0 .top-objekte').slick({
		  dots: false,
		  infinite: false,
		  speed: 300,
		  slidesToShow: 4,
		  slidesToScroll: 4,
		  prevArrow: '<button type="button" class="slick-prev"><i class="icon-chevron-sign-left"></i></button>',
		  nextArrow: '<button type="button" class="slick-next"><i class="icon-chevron-sign-right"></i></button>',
		  responsive: [
		    {
		      breakpoint: 1024,
		      settings: {
		        slidesToShow: 2,
		        slidesToScroll: 2,
		        infinite: true,
		        dots: true
		      }
		    },
		    {
		      breakpoint: 600,
		      settings: {
		        slidesToShow: 1,
		        slidesToScroll: 1
		      }
		    },
		    {
		      breakpoint: 480,
		      settings: {
		        slidesToShow: 1,
		        slidesToScroll: 1
		      }
		    }
		  ]

		});

		/* -------------------------------------------------------------
		Mobile Navigation
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.mobile-navigation > ul').slicknav({
			label: 'Navigation',
			duration: 500,
			allowParentLinks: true,
			duplicate: false,
			easingOpen: 'swing',
			easingClose: 'swing'
		});

		/* -------------------------------------------------------------
		Footer
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		if($('.meta-tabs a').length >= 1)
		{

			$('.meta-tabs a').click(function()
			{
				$('.meta-tabs a.selected').removeClass('selected');
				$(this).addClass('selected');

				$('.footer .meta-tab-content p.selected').removeClass('selected');
				$('.footer .meta-tab-content ' + $(this).attr('href')).addClass('selected');
			});
		}

		$('.footer-end ul li').each(function(){

			$(this).find('a').prepend('<i class="icon-sign-blank"></i>');

		});

		/* -------------------------------------------------------------
		Objectlist
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.listobject').each(function(){

			var imagePath = $(this).find('img').attr('src');

			$(this).find('li').attr('style','background-image:url(' + imagePath + ');');

			$(this).find('img').hide().remove();

		});

		$('.listobject:odd').after('<div class="clear"></div>');

		$('.object-list-details table').each(function(){

			$(this).find('tr:last').addClass('last-tr');

		});

		$('.pages a').each(function(){

			if($.trim($(this).html()) == '') {

				$(this).hide().remove();

			}

		});

		/* -------------------------------------------------------------
		Objectdetails
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('.objectdetails table').each(function(){

			$(this).find('tr:odd').addClass('grey');

			$(this).find('tr').each(function(){

				$(this).find('td:first').addClass('objectdetails-left-cell');

			});

		});

		$('.objectdetails-freitexte span strong').addClass('headline');

		$('.objectdetails-freitexte span').each(function(){

			$(this).find('p:last').removeAttr('style');

		});

		$('.objectdetails-freitexte > span > span').each(function(){

			if($.trim($(this).find('p:first').html()) == '') {

				$(this).parent().hide();

			}

		});

		var referenzcheck = $('.referenzen-check').val();

		if(referenzcheck == 1) {
		    $('form#request').remove();
		}

	});

	$(window).load(function() {

		//EINHEITLICHE HOEHE DER OBJEKTBOXEN

		// var maxheight = 0;
		// var realheight = 0;

		// $('.object-list-details').each(function() {
		// 	realheight = $(this).height();
		// 	if (realheight > maxheight) {
		// 		maxheight = realheight;
		// 	}
		// });

		// $('.object-list-details').height(maxheight);

		$('html').addClass('loaded');

		$('img').each(function() {
			var this_src      = $(this).attr('src');
			var this_data_src = $(this).attr('data-src');

			if( this_src != '' ) {
				if( this_data_src != undefined ) {
					$(this).attr( 'src', this_data_src );

					$(this).load(function() {
						$(this).fadeIn('fast');
					});
				}
			}
		});	

	});

	$(window).resize(function() {

		var bodyWidth = $('body').width();

		if(bodyWidth >= 940) {

			menuWidthlayer('.menu_layer1');

			// menuWidthlayer('.menu_layer2');

		}

	});

	$('form').submit(function() {

		$('input[type="text"]').each(function() {
			var this_default = $(this).attr('default');

			if( $(this).val() == this_default ) {
				$(this).val( '' );
			}
		});

		$('textarea').each(function() {
			var this_default = $(this).attr('default');

			if( $(this).text() == this_default ) {
				$(this).text( '' );
			}
		});

	});

	function defaults() {

		/* -------------------------------------------------------------
		Form Defaults
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('input[type="text"]').each(function() {
			var this_default = $(this).attr('default');

			if( $(this).val() == '' ) {
				$(this).val( this_default );
			}

			$(this).focus(function() {
				if( $(this).val() == this_default ) {
					$(this).val( '' );
				}
			});

			$(this).blur(function() {
				if( $(this).val() == '' ) {
					$(this).val( this_default );
				}
			});
		});

		$('textarea').each(function() {
			var this_default = $(this).attr('default');

			if( $(this).text() == '' ) {
				$(this).text( this_default );
			}

			$(this).focus(function() {
				if( $(this).text() == this_default ) {
					$(this).text( '' );
				}
			});

			$(this).blur(function() {
				if( $(this).text() == '' ) {
					$(this).text( this_default );
				}
			});

		});

		/* -------------------------------------------------------------
		Empty Clear
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('div.clear').html( '' );

		/* -------------------------------------------------------------
		External Links
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('a').each(function() {
			var this_href = $(this).attr('href');

			if( this_href != undefined ) {
				if( this_href.indexOf('?link') >= 0 ) {
					var external_link = this_href.split('?link=');

					$(this).attr( 'href', external_link[1] );

					if( external_link[1].indexOf('http') >= 0 ) {
						$(this).attr( 'target', '_blank' );
					}
				}
			}
		});

		/* -------------------------------------------------------------
		Table
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('table').each(function() {
			var this_cellspacing = $(this).attr('cellspacing');
			var this_cellpadding = $(this).attr('cellpadding');
			var this_border      = $(this).attr('border');

			if( this_cellspacing == undefined ) {
				$(this).attr('cellspacing', 0);
			}

			if( this_cellpadding == undefined ) {
				$(this).attr('cellpadding', 0);
			}

			if( this_border == undefined ) {
				$(this).attr('border', 0);
			}
		});

		/* -------------------------------------------------------------
		Images
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		$('img').each(function() {
			var this_src      = $(this).attr('src');
			var this_data_src = $(this).attr('data-src');

			if( this_src != '' ) {
				if( this_data_src != undefined ) {
					$(this).hide();
				}
			}

			if( $(this).attr('style') != undefined ) {
				if ( ( this_src.indexOf('cmspics') ) >= 0 && ( ($(this).attr('style').indexOf('float: left') ) >= 0 ) ) {
					$(this).css('margin-left','0px').css('margin-top','0px');
				} else if ( ( this_src.indexOf('cmspics') ) >= 0 && ( ($(this).attr('style').indexOf('float: right') ) >= 0 ) ) {
					$(this).css('margin-right','0px').css('margin-top','0px');
				}
			}
		});

		/* -------------------------------------------------------------
		Mobile Navigation
		- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

		// $('.mobile-navigation li').each(function(index) {
		// 	if( $(this).find('> ul').length >= 1 ) {
		// 		$(this).find('> span').addClass('open-mobile-sub-navigation').attr('data-sub', 'sub-' + index).append(' <i class="icon-caret-down"></i>');
		// 		$(this).find('> ul').attr('id', 'sub-' + index);
		// 	}
		// });

	}

	function forms() {

		var url = document.URL.split('?');

		if(url[1] != undefined)
		{
			url = url[1].split('&');

			for(x = 0; x <= (url.length - 1); x++)
			{
				var this_parameter = url[x].split('=');

				if (this_parameter != '')
				{
					var this_name = this_parameter[0].replace(/\%5B/g, '[').replace(/\%5D/g, ']');
					var this_value = '';

					if(this_parameter[1] != undefined)
					{
						this_value = this_parameter[1].replace(/\+/g, ' ').replace(/\+\%2F\+/g, ' / ').replace(/\%2C/g, ',');
					}

					$('select[name="' + this_name + '"]').each(function()
					{
						$(this).find('option').each(function()
						{
							if($(this).val() == decodeURIComponent(this_value))
							{
								$(this).attr('selected', 'selected');
							}
						});
					});

					$('input[name="' + this_name + '"]').each(function()
					{
						if($(this).attr('type') == 'text' || $(this).attr('type') == 'hidden')
						{
							if(this_value != '')
							{
								$(this).val(decodeURIComponent(this_value));
							}
						}
						else if($(this).attr('type') == 'checkbox')
						{
							if(this_value != '')
							{
								$(this).attr('checked', 'checked');
							}
						}
						else if($(this).attr('type') == 'radio' && $(this).val() == this_value)
						{
							$(this).attr('checked', 'checked');
						}
					});
				}
			}
		}

	}

	// function mobileNavigationCheck() {

	// 	var body      = $('body');
	// 	var bodyClass = 'open-mobile-navigation';

	// 	if( body.hasClass(bodyClass) ) {
	// 		body.removeClass(bodyClass);
	// 	} else {
	// 		body.addClass(bodyClass);
	// 	}

	// }

	function bodyClass( contentkey ) {

		var body_class = contentkey.split('.');

		$('body').addClass( 'body-' + body_class[0] );

	}

	function breadcrumb( params ) {

		if( $('.breadcrumb').length == 0 ) {
			return false;
		}

		var site = 0;

		if( params.request_page != '' ) {
			site = params.request_page;

			if( site > 1 ) {
				$('.breadcrumb ul').append('<li><a href="' + params.website_current + '?p[obj0]=' + site +'">' + params.page_name + ' ' + site + '</a></li>');
			}
		}

		if( params.request_id != '' ) {
			var id = params.request_id;
			var id_external = $('.details').attr('id');

			if( id_external != undefined ) {
				if( site > 1 ) {
					$('.breadcrumb ul li:last a').attr('href', $('.breadcrumb ul li:last a').attr('href') + '#object-' + id);
					$('.breadcrumb ul').append('<li><a href="' + params.website_current + '?p[obj0]=' + site +'&id[obj0]=' + id + '">' + params.object_name + ' ' + id_external + '</a></li>');
				} else {
					$('.breadcrumb ul li:last a').attr('href',$('.breadcrumb ul li:last a').attr('href') + '#object-' + id);
					$('.breadcrumb ul').append('<li><a href="' + params.website_current + '?id[obj0]=' + id + '">' + params.object_name + ' ' + id_external + '</a></li>');
				}
			}
		}

		$('.breadcrumb ul li a.selected').removeClass('selected');
		$('.breadcrumb ul li:last a').addClass('selected');

		$('.breadcrumb ul li').each(function() {
			if( !$(this).find('a').hasClass('selected') ) {
				$(this).append('&nbsp;/&nbsp;');
			}
		});

		if( params.website_current != params.website_home ) {
			$('.breadcrumb ul').prepend('<li>' + params.label_name + ':&nbsp;</li><li><a href="' + params.website_home + '" target="_self">' + params.home_name + '</a>&nbsp;/&nbsp;</li>');
		}

	}

	function status( params ) {

		if( $('.list-object').length ) {
			
			$('.list-object').each(function(index) {

				if( $(this).find('ul li span').length ) {

					sThisType = $(this).find('ul li span').attr('class');

					if( sThisType == 'status-top' ) {
						$(this).find('ul li span').text(params.top_name);
					}

					if( sThisType == 'status-rented' ) {
						$(this).find('ul li span').text(params.rented_name);
					}

					if( sThisType == 'status-reference' ) {
						$(this).find('ul li span').text(params.reference_name);
					}

					if( sThisType == 'status-new' ) {
						$(this).find('ul li span').text(params.new_name);
					}

					if( sThisType == 'status-sold' ) {
						$(this).find('ul li span').text(params.sold_name);
					}

					if( sThisType == 'status-reduced' ) {
						$(this).find('ul li span').text(params.reduced_name);
					}

					if( sThisType == 'status-reserved' ) {
						$(this).find('ul li span').text(params.reserved_name);
					}

					if( sThisType == 'status-courtage_free' ) {
						$(this).find('ul li span').text(params.courtage_free_name);
					}

					if( sThisType == 'status-exclusive' ) {
						$(this).find('ul li span').text(params.exclusive_name);
					}

					$(this).find('ul li span').css('background-image', '');
				}
			});
		}

	}

	function menuWidthlayer( menuClass ) {

		var menuWidthlayer = $('' + menuClass + ' > .wrapper-center > ul').width();
		
		var lengthMenuItemslayer = $('' + menuClass + ' > .wrapper-center > ul > li').length;

		$('' + menuClass + ' > .wrapper-center > ul > li').outerWidth(menuWidthlayer / lengthMenuItemslayer,true);

		$('' + menuClass + ' > .wrapper-center > ul > li:last').width($('' + menuClass + ' > .wrapper-center > ul > li:last').width() - 1);

	}

	function formsChangeSalesType( select ) {

		if ( select.value == 'miete' )
		{
			$('.wrap-kaufpreis').fadeOut(50);
			$('.wrap-mietpreis').delay(55).fadeIn(150);

			if ( select.className == 'salestype-interest' )
			{
				$('.hinput-kontaktart').val('Interessent Miete');
			}
		}
		else if ( select.value == 'kauf' )
		{
			$('.wrap-mietpreis').fadeOut(50);
			$('.wrap-kaufpreis').delay(55).fadeIn(150);

			if ( select.className == 'salestype-interest' )
			{
				$('.hinput-kontaktart').val('Interessent Kauf');
			}
		}
		else if ( select.value != 'miete' || select.value != 'kauf' )
		{
			$('.wrap-kaufpreis').fadeOut(150);
			$('.wrap-mietpreis').fadeOut(150);

			if ( select.className == 'salestype-interest' )
			{
				$('.hinput-kontaktart').val('');
			}
		}

	}

	/* -------------------------------------------------------------
    Slider
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

	$.fn.mySlider = function()
    {
        var fadeTime = 2000;

        if($('.slider-large .animation div.selected').hasClass('last'))
        {
            $('.slider-large .animation div.last').fadeOut(fadeTime);
            $('.slider-large .animation div:first').fadeIn(fadeTime).addClass('selected');
            $('.slider-large .animation div.last:first').removeClass('selected');

            $('.slider-large .slider-navigation p span:last').removeClass('selected');
            $('.slider-large .slider-navigation p span:first').addClass('selected');
        }
        else
        {
            $('.slider-large .animation div.selected').fadeOut(fadeTime);
            $('.slider-large .animation div.selected').next('div').fadeIn(fadeTime).addClass('selected');
            $('.slider-large .animation div.selected:first').removeClass('selected');

            $('.slider-large .slider-navigation p span.selected').next('span').addClass('selected');
            $('.slider-large .slider-navigation p span.selected:first').removeClass('selected');
        }
    }

    	/* -------------------------------------------------------------
    Google Maps
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

    /*function googleMaps(addressInput, mapID)
    {
        var address = '';
        var geocoder = '';
        var lat = '';
        var lng = '';

        address = addressInput;
        geocoder = new google.maps.Geocoder();

        geocoder.geocode(
        {
            'address': address
        }, function(results, status)
        {
            if (status == google.maps.GeocoderStatus.OK)
            {
                lat = results[0].geometry.location.lat();
                lng = results[0].geometry.location.lng();

                var latlng = new google.maps.LatLng(lat,lng);

                var myOptions =
                {
                    zoom: 15,
                    center: latlng,
                    mapTypeControl: false,
                    scaleControl: false,
                    panControl: false,
                    rotateControl: false,
                    streetViewControl: false,
                    scrollwheel: false,
                    zoomControl: false,
                    draggable: false,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
                };

                var map = new google.maps.Map(document.getElementById(mapID), myOptions);

                var marker = new google.maps.Marker(
                {
                    position: latlng
                });

                marker.setMap(map);
            }
        });
    }*/

    /* -------------------------------------------------------------
    MakeBackgroundImage
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */

    function makeBackgroundImage() {

		$('.makebackgroundimage img').each(function(){

			$(this).hide();

			var image_path = $(this).attr('src');

			var image_height = $(this).height();

			console.log(image_height);

			$(this).parent().css('display','block').css('height',image_height);
			
			$(this).parent().addClass('bg-responsive').css('background-image', 'url(' + image_path + ')');

		});

	}