/*jslint browser: true */ /*global jQuery: true */

/**
 * jQuery Cookie plugin
 *
 * Copyright (c) 2010 Klaus Hartl (stilbuero.de)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 *
 */
		
// TODO JsDoc

/**
 * Create a cookie with the given key and value and other optional parameters.
 *
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Set the value of a cookie.
 * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
 * @desc Create a cookie with all available options.
 * @example $.cookie('the_cookie', 'the_value');
 * @desc Create a session cookie.
 * @example $.cookie('the_cookie', null);
 * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
 *       used when the cookie was set.
 *
 * @param String key The key of the cookie.
 * @param String value The value of the cookie.
 * @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
 * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
 *                             If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
 *                             If set to null or omitted, the cookie will be a session cookie and will not be retained
 *                             when the the browser exits.
 * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
 * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
 * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
 *                        require a secure protocol (like HTTPS).
 * @type undefined
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */

/**
 * Get the value of a cookie with the given key.
 *
 * @example $.cookie('the_cookie');
 * @desc Get the value of a cookie.
 *
 * @param String key The key of the cookie.
 * @return The value of the cookie.
 * @type String
 *
 * @name $.cookie
 * @cat Plugins/Cookie
 * @author Klaus Hartl/klaus.hartl@stilbuero.de
 */
jQuery.cookie = function (key, value, options) {
    
    // key and at least value given, set cookie...
    if (arguments.length > 1 && String(value) !== "[object Object]") {
        options = jQuery.extend({}, options);

        if (value === null || value === undefined) {
            options.expires = -1;
        }

        if (typeof options.expires === 'number') {
            var days = options.expires, t = options.expires = new Date();
            t.setDate(t.getDate() + days);
        }
        
        value = String(value);
        
        return (document.cookie = [
            encodeURIComponent(key), '=',
            options.raw ? value : encodeURIComponent(value),
            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
            options.path ? '; path=' + options.path : '',
            options.domain ? '; domain=' + options.domain : '',
            options.secure ? '; secure' : ''
        ].join(''));
    }

    // key and possibly options given, get cookie...
    options = value || {};
    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
};




$(document).ready(function() {


// this will give you your path ie /light/saber/
urlPath=window.location.pathname;

//this splits your url in pieces using the / as a separator
urlPathArray = urlPath.split('/');

//get the first section of your path ie light
urlPath1=urlPathArray[2];
urlPath2=urlPathArray[3];
urlPath3=urlPathArray[4];


if (urlPath1 == "architektur") {$(".subnav_architektur").removeClass("hide");};

if (urlPath1 == "expertisen") {$(".subnav_expertisen").removeClass("hide");};

if (urlPath1 == "energieberatung") {$(".subnav_energieberatung").removeClass("hide");};

if (urlPath1 == "immobilien") {$(".subnav_immobilien").removeClass("hide");};

if (urlPath1 == "buero") {$(".subnav_buero").removeClass("hide");};




// Set cookie
if($.cookie("cookie_name") != 'neu') {

	$(".button_ein").css("text-decoration", "blink");


}













$('.mainnav_item').click(function() {
    $(this).children().addClass("current2");
    $(this).siblings().children().removeClass("current2");
    $(this).children().removeClass("hide");
    $(this).siblings().children().nextAll().addClass("hide");
});


//Einblenden der Navigation beim Laden der Seite
if (urlPath1 != "team") {

	$('#slide').stop().animate({
		opacity: 0,
		top: '450' // war 450
	  }, 0, function() {
					});


	$('#slide').stop().delay(1000).animate({
		opacity: 0.95,
		top: '120' // war 450
	  }, 1000, function() {});};



$('#main, .ref_img img, #main_corners_bottom, #main_corners_top').mouseenter(function() {
 $('#slide').stop().animate({
    opacity: 0.95,
	top: '120'
  }, 600, function() {
	// Animation complete.
			});


});


$('#main, #main_corners_bottom, #main_corners_top, #main').mouseleave(function() {
  $('#slide').stop().animate({
    opacity: 1,
	top: '450'
  }, 600, function() {
    // Animation complete.
	    $(".button_aus").addClass("hide");
	    $(".button_ein").removeClass("hide");
  });
});




$('.button_ein').click(function() {
		$.cookie('cookie_name', 'neu', { path: '/' });
		$(".button_ein").css("text-decoration", "none");
	    $("#button_ein").addClass("hide");
	    $(".button_ein").addClass("hide");
	    $(".button_aus").removeClass("hide");
		$('#slide').stop().animate({
			top: '-150'
  		}, 600, function() {
    	// Animation complete.

  		});
});


$('.button_aus').click(function() {
	    $(".button_aus").addClass("hide");
	    $(".button_ein").removeClass("hide");
  $('#slide').stop().animate({
	top: '120'
  }, 500, function() {
    // Animation complete.

  });
});




$('.ref_minis').click(function() {

	$(this).addClass("ref_minis_ein");
	$(this).siblings().removeClass("ref_minis_ein");


	$('#slide').stop().animate({
			opacity: 0
  		}, 600, function() {
    	// Animation complete.
  		});

});


$('.ref_minis').mouseleave(function() {

	$('#slide').stop().animate({
			opacity: 1
  		}, 600, function() {
    	// Animation complete.
  		});

});






$('.bauten_wrap_img').click(function() {
    $(this).addClass("bauten_wrap_img_ein");
    $(this).siblings().removeClass("bauten_wrap_img_ein");
});



$('.ref_minis_1').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '0'
  }, 600, function() {
    // Animation complete.
  });
});


$('.ref_minis_2').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-850'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_3').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-1700'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_4').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-2550'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_5').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-3400'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_6').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-4250'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_7').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-5100'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_8').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-5950'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_9').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-6800'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_10').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-7650'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_11').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-8500'
  }, 600, function() {
    // Animation complete.
  });
});

$('.ref_minis_12').click(function() {
  $('div.ref_img_wrap_container').stop().animate({
	left: '-9350'
  }, 600, function() {
    // Animation complete.
  });
});











        // put all your jQuery goodness in here.
    });
