(function($){
    $(document).ready(function(){
	/* Ukrywanie wyszukiwarki na forum do momentu jej naprawienia */
	$("form[name='wpf_search_form']").parent().parent().parent().remove();
	
	/* Instrukcje do wyszukiwarki na gorze strony */
	$("div#expresso-header-widget span:contains('Wyszukiwarka')").parent().prepend("<div class='side-search-header'>Aby wyszukać produkt po numerze wpisz go jako<br/>jeden ciąg znaków bez spacji i oddzielników</div>");
	
	if(!$("div#product-container").hasClass("product-page")) {
		$("div#expresso-right-sidebar-container div.expresso-sidebar-widget h3:contains('Powrót do wyszukiwania')").parent().remove();
	}
	
	if(($("div#product-container").hasClass("product-page")) && ($("div#expresso-right-sidebar-container div.expresso-sidebar-widget h3").is(":contains('Zawężanie wyszukiwania')"))) {
		$("div#expresso-right-sidebar-container div.expresso-sidebar-widget h3:contains('Powrót do wyszukiwania')").parent().remove();
	}
	
	// FIX PRODUCT VIEW
	$("div#product-container p.headline").css("clear","both");

	
	// CHECK IF PAGE IS A PRODUCT PAGE 
	if($("div#product-container").hasClass("product-page")) {
		$("div#expresso-right-sidebar-container div.expresso-sidebar-widget h3:contains('Zawężanie wyszukiwania')").each(function() {
			$(this).text("Powrót do wyszukiwania");

			$(this).parent().children("div.expresso-sidebar-widget-container").children().remove();
			$(this).parent().children("div.expresso-sidebar-widget-container").html("<a href='http://www.tlumiki.eu/sklep/' title='Wróć do sklepu'>Jeśli chcesz zmienić parametry wyszukiwania <strong>kliknij tutaj</strong></a>");
			
		});
	}

	// COMMENTS FORMATTING
	$("ol.commentlist li.comment p").addClass("box");
	$("ol.commentlist li.comment p").append("<span class='comment-arrow'></span>");
	$("ol.commentlist li.comment div.comment-author img").wrap("<span class='img-background'></span>");
	// FRONT PAGE WIDGETS
		$("body div.expresso-footer-widget-wrap h3.expresso-footer-widget-title:contains('Aktualno')").not("body.home div.expresso-footer-widget-wrap h3.expresso-footer-widget-title:contains('Aktualno')").parent().parent().remove();
	
	// FRONT PAGE POPUP ACTIVATED VIA WORDPRESS WIDGETS
	var popup_cookie = $.cookie('tlumiki_eu_frontpage_newsletter');
	
	if(popup_cookie != 'unclicked-DELETE-THIS') {
		$("div#expresso-front-page-popup-bg").fadeIn(500);
		$("div#expresso-front-page-popup-wrap").delay(500).slideDown(700);
		$("div#expresso-front-page-popup-close").delay(1200).show(1);
	};
		
		$("div#expresso-front-page-popup-close").click(function() {
			$("div#expresso-front-page-popup-close").hide();
			$("div#expresso-front-page-popup-wrap").slideUp(700);
			$("div#expresso-front-page-popup-bg").delay(800).fadeOut(500);
			$.cookie('tlumiki_eu_frontpage_newsletter', 'unclicked');
		});
	
	// FIX LAST UL IN THE TOP MENU
		$("ul#expresso-page-header-menu > li:last-child > ul").addClass("last-ul");
	
	// HIDE NO COMMENTS TEXT
		$("p.nocomments").remove();
		$("div.entry-utility span.comments-link span:contains('Komentarze')").remove();
		
	// COMMENT BUTTON
		$("#respond input#submit").addClass("box");
	
	// SIDE BLOG
		$(".expresso-sidebar-widget-container ul li small").hide();
	

/*
	// SIDE NEWSLETTER
		$("a#side-newsletter").hover(
			function() {
				$(this).stop(true,true).animate({
					left: '0px'
				},200);
			},
			function() {
				$(this).stop(true,true).animate({
					left: '-5px'
				},200);
			}
		);

*/
/*
	// SIDE FACEBOOK
		$("a#side-facebook").hover(
			function() {
				$(this).stop(true,true).animate({
					right: '0px'
				},200);
			},
			function() {
				$(this).stop(true,true).animate({
					right: '-5px'
				},200);
			}
		);
*/

	// MINGLE FORUM OPTIONS
		$("#wpf-wrapper td[width=100]").attr("width","150");
		$("#wpf-wrapper th[width=100]").attr("width","150");
		$("div#wpf-wrapper table").attr("cellpadding","0").attr("cellspacing","0").css("border","0px");
		$("div#wpf-wrapper .wpf").css("border","0px");
		$("td.mirrortab_first").remove();
		$("td.mirrortab_last").remove();
		$("table#wp-mainmenu tbody tr td a").addClass("bottomradius");
		$("td.mirrortab_back a").addClass("topradius");
		$("input#wpf-search-submit").addClass("box");
		$("input#quick-reply-submit").addClass("box");
		$("input#wpf-post-submit").addClass("box");
		$("td.maintab_first").parent().parent().parent().remove();
		
		
	// SPECS HOVER
		$("dl.details dt").hover(
			function() {
				$(this).addClass("hovered").next("dd").addClass("hovered");
			},
			function() {
				$(this).removeClass("hovered").next("dd").removeClass("hovered");
			}
		);
		$("dl.details dd").hover(
			function() {
				$(this).addClass("hovered").prev("dt").addClass("hovered");
			},
			function() {
				$(this).removeClass("hovered").prev("dt").removeClass("hovered");
			}
		);
		
	// PREMIUM
		$("strong:contains('PREMIUM')").attr("title","To „klasa S” wśród części do układów wydechowych. Znaleźli się tu producenci uznani na całym świecie, których wyroby nierzadko trafiają na linie montażowe takich marek jak: Alfa Romeo, Audi, BMW, Lancia, Mercedes, Opel czy Volkswagen. Mowa tu o firmach: Bosal, Eberspächer, Imasaf, Klarius, Magnaflow, MTS czy Walker.");
	
	// SHOPP SIDE FILTERS
		$("ul.filters").parent("div").addClass("shopp_filters");
		$("div.shopp_filters ul").not("ul.filters").addClass("elements");
		$("ul.elements").wrap("<div class='elements-wrap' />");
		$("div.shopp_filters ul.elements").hover(
			function() {
				$(this).css("height","150px").css("z-index","300").css("overflow-y","scroll").addClass("nobg");
			},
			function() {
				$(this).css("height","20px").css("z-index","1").css("overflow-y","hidden").removeClass("nobg");
			}
		);
		$("div.elements-wrap ul.elements li:odd").css("background","#f4f4f4");
		$("div.elements-wrap ul.elements li").not("div.elements-wrap ul.elements li:first-child").css("border-top","1px #bfbfbf solid");
		
/*
		// SHOPP MODELE SAMOCHODÓW
			$("div.shopp_filters h4:contains('Model')").addClass("model-title");
			$("div.shopp_filters h4:contains('Model')").next("div.elements-wrap").children("ul").addClass("model-list");
			$("ul.model-list li").hide();
			$("ul.model-list").append("<li class='select-brand'>Wybierz markę</li>");
			
			var marka_container = $("ul.filters li:contains('Marka')").text();
			marka = marka_container.substring(7,marka_container.length-2);
			if(marka.length > 0) {
				$("h4.model-title").show();
				$("ul.model-list").show();
				$("ul.model-list li:contains('"+marka+"')").each(function() {
					var marka_model = $(this).children("a").text();
					$(this).children("a").text(marka_model.substring(marka.length+1));
					$(this).show();
					$("li.select-brand").hide();
				});
			}
			
*/
		
	
	// SHOPP SIDE CATEGORIES
		$("ul.shopp_categories li.current").parent("ul").parent("li").addClass("current");
		$("div.expresso-sidebar-widget-container:has('ul.shopp_categories')").addClass("nopadding");
		$("ul.shopp_categories li:last-child a").addClass("last").addClass("bottomradius");
		
		// BOX RADIUS
		$("ul.shopp_categories li ul").addClass("smallshadow");
		$("ul.shopp_categories li ul").addClass("topleftradius").addClass("bottomradius");
		$("ul.shopp_categories li ul li:nth-child(1)").addClass("topleftradius");
		$("ul.shopp_categories li ul li:nth-child(1) a").addClass("topleftradius");
		$("ul.shopp_categories li ul li:last-child").addClass("bottomradius");
		$("ul.shopp_categories li ul li:last-child a").addClass("bottomradius");
		
		// ARROW DOWN
		$("ul.shopp_categories li ul").parent().children("a").append("<div class='arrow-down'></div>");
		
		// SHOW SUBMENU ON HOVER
		$("ul.shopp_categories li").hover(
			function() {
				$(this).children("ul").stop(true,true).slideDown(300);
			},
			function() {
				$(this).children("ul").stop(true,true).slideUp(150);
			}
		);
		
		
	
	// MINGLE FORUM FORMATTING
		$("#wpf-info").remove();
	
	// COLUMNS
		$("div.column-half").wrapAll("<div class='columns-container' />");
		$("div.column-half:last").addClass("column-half-last");
		$("div.column-half").next("br").remove();
		$("div.columns-container").append("<div class='clear'></div>");
		$("div.columns-container").next("br").remove();
	
	// LIST COLORS
		// LOOP LIST COLOR
			$("div.expresso-loop-content ul li").each(function() {
				var text = $(this).html();
				$(this).html("<span class='li-text'>"+text+"</span>");
			});
		// SIDE WIDGET LIST COLOR
			$("#expresso-right-sidebar-container ul li").not("#expresso-right-sidebar-container ul.shopp_categories li").each(function() {
				var text = $(this).html();
				$(this).html("<span class='li-text'>"+text+"</span>");		
			});
		// FOOTER WIDGET LIST COLOR
			$("#expresso-footer-widgets-container ul li").each(function() {
				var text = $(this).html();
				$(this).html("<span class='li-text'>"+text+"</span>");		
			});
	
	// FIX POST VIEW
		$("div.entry-content h2:first").css("margin-top","0px");
	
	// QUICK CONTACT FORM
		$("div#expresso-quick-contact-form-bottom input[type=submit]").addClass("box");

	
		$("div#expresso-quick-contact-form-email input").val("Tutaj wpisz swój adres e-mail").attr("alt","Tutaj wpisz swój adres e-mail");
		$("div#expresso-quick-contact-form-email input").addClass("unfocused");
		$("div#expresso-quick-contact-form-email input").focus(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == input_alt) {
				$(this).removeClass("unfocused").val("");
			}
		});
		$("div#expresso-quick-contact-form-email input").blur(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == '') {
				$(this).val(input_alt);
				$(this).addClass("unfocused");
			};
		});
		
		
		
		$("div#expresso-quick-contact-form-content textarea").val("Tutaj napisz wiadomość jaką chcesz nam wysłać").attr("alt","Tutaj napisz wiadomość jaką chcesz nam wysłać");
		$("div#expresso-quick-contact-form-content textarea").addClass("unfocused");
		$("div#expresso-quick-contact-form-content textarea").focus(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == input_alt) {
				$(this).removeClass("unfocused").val("");
			}
		});
		$("div#expresso-quick-contact-form-content textarea").blur(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == '') {
				$(this).val(input_alt);
				$(this).addClass("unfocused");
			};
		});
		
		$("div#expresso-quick-contact-form-captcha-input input").val("Przepisz kod").attr("alt","Przepisz kod");
		$("div#expresso-quick-contact-form-captcha-input input").addClass("unfocused");
		$("div#expresso-quick-contact-form-captcha-input input").focus(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == input_alt) {
				$(this).removeClass("unfocused").val("");
			}
		});
		$("div#expresso-quick-contact-form-captcha-input input").blur(function() {
			var input_text = $(this).val();
			var input_alt = $(this).attr("alt");
			if(input_text == '') {
				$(this).val(input_alt);
				$(this).addClass("unfocused");
			};
		});
		
		
	// WIDGETS
		$("div.expresso-sidebar-widget-container").addClass("bottomradius");
		$("h3.expresso-sidebar-widget-title").addClass("topradius");
		
	// LOGO ANIMATION
		$("#expresso-logo-image-container").hover(
			function() {
				$(this).stop(true,true).animate({
					opacity: 0.6
				});
			},
			function() {
				$(this).stop(true,true).animate({
					opacity: 1.0
				});
			}
		);
	
	// POST THUMBNAILS
		$("div.post-list-view p img").not("div.post-list-view .expresso-thumbnail img").remove();
		$("div.expresso-post-container:first").removeClass("expresso-post-container-separator");
	
	// MAPPRESS
		$("div.mapp-container div.mapp-canvas").wrap("<div class='mapp-canvas-container' />");
	
	// WP TABLE RELOADED
		$("table.wp-table-reloaded tbody tr").not("table.wp-table-reloaded tbody tr.intable-header").hover(
			function() {
				$(this).addClass("hovered");
			},
			function() {
				$(this).removeClass("hovered");
			}
		);
		$("table.wp-table-reloaded").wrap("<div class='wp-table-reloaded-container' />");
		$("table.wp-table-reloaded thead tr th").each(function() {
			var naglowek = $(this).text();
			$(this).html("<div class='wp-table-reloaded-header-text topradius'>"+naglowek+"</div>");
		});
		$("table.wp-table-reloaded tbody tr td[colspan=3]:first-child strong").parent().parent().addClass("intable-header");
		$("table.wp-table-reloaded tbody tr td[colspan=2]:first-child strong").parent().parent().addClass("intable-header");
		$("table.wp-table-reloaded tbody tr td:first-child strong").parent().parent().addClass("intable-header");
		
		$(window).load(function() {
			// PRELOADER - Show tables after the transformations are done
			$("div.wp-table-reloaded-container").show();
			$("table.wp-table-reloaded").show();
		});
		
		
	
	// CONTACT FORMS
		$(".contact-form-columns .wpcf7-submit").wrap("<center/>");
	
	// LIST FORMATTING
		$("#expresso-quick-contact-form-captcha-input br").remove();
	

	
	// CENTROWANIE OBRAZKÓW
		$("a:has('img.aligncenter')").addClass("center");
		
	// NEXTGEN GALLERY - ADD TO INDEX
		// CLEAR ALBUM VIEW
		$("div.ngg-albumoverview div.galleryblock").append("<div class='clear'></div>");
		$("div.ngg-albumoverview div.galleryblock:last").addClass("galleryblock-last");
		$("div.ngg-galleryoverview div:nth-child(4n) div.galleryblock").addClass("galleryblock-lastline");
	
	
	// CUSTOMER CONTACT FORM FORMATTING - ADD TO INDEX
		// MARGIN FIX FOR FIRST TITLE
		$(".contact-form-columns .contact-form-title:first").addClass("first-title");
		// ROUNDED CORNERS FOR TITLES
		$(".contact-form-columns .contact-form-title").addClass("topradius");
		// ROUNDED CORNER FOR LAST ROW
		$(".contact-form-columns .contact-form-title").prev(".contact-form-row").addClass("bottomradius").addClass("last-row").wrap("<div class='last-row-container' />");
		$(".contact-form-columns .contact-form-row:last").addClass("bottomradius").addClass("last-row").wrap("<div class='last-row-container' />");
		// ROUNDED CORNERS FOR SUBMIT BUTTON
		$(".contact-form-columns .wpcf7-submit").addClass("box");		
		// SHOW HOVER OF FORM ROWS
		$(".contact-form-row").hover(
			function() {
				$(this).addClass("row-hovered");
			},
			function() {
				$(this).removeClass("row-hovered");
			}
		);
		// SHOW FIELD FOR OTHER PRODUCT TYPE
		$("div.contact-form-row div.contact-form-column-2:has('span.jaki')").parent().hide();
		$("select[name=rodzaj]").change(function() {
			if($(this).children("option:selected").is(":contains('inny')")) {
				$("div.contact-form-row div.contact-form-column-2:has('span.jaki')").parent().slideDown(700);
			} else {
				$("div.contact-form-row div.contact-form-column-2:has('span.jaki')").parent().slideUp(500);
			};
		});
		// SHOW AND HIDE SHOPP SUBCATEGORIES
		$("#expresso-left-sidebar-container-wrap .shopp_categories li:has('ul')").prepend("<span class='shopp-toggle-arrow leftradius'></span>");
		$("span.shopp-toggle-arrow, span.shopp-toggle-arrow-up").click(
			function() {
				$(this).parent().children("ul").slideToggle(500);
				$(this).toggleClass("shopp-toggle-arrow");
				$(this).toggleClass("shopp-toggle-arrow-up");
			}
		);
		$(".shopp_categories li").each(
			function() {
				if($(this).is(".current")) {
					$(this).children("span.shopp-toggle-arrow").toggleClass("shopp-toggle-arrow").toggleClass("shopp-toggle-arrow-up");
				}
			}
		);
	
	// SEARCH INSIDE HEADER WIDGET
		$("div#expresso-header-widget form div label.screen-reader-text").hide();
		$("div#expresso-header-widget input").addClass("box");
		$("div#expresso-header-widget input#s").val("Szukaj produktu...");
		$("div#expresso-header-widget input#s").focus(function() {
			var search_input_lenght = $(this).val();
			if(search_input_lenght == 'Szukaj produktu...') {
				$(this).val("");
				$(this).addClass("expresso-search-focused");
			}
		});
		$("div#expresso-header-widget input#searchsubmit").click(function() {
			var search_input_lenght = $("div#expresso-header-widget input#s").val();
			if(search_input_lenght == 'Szukaj produktu...') {
				$("div#expresso-header-widget input#s").val("");
			}
		});
		
		
		$("div#expresso-header-widget input#s").blur(function() {
			var search_input_lenght = $(this).val();
			if(search_input_lenght == '') {
				$(this).val("Szukaj produktu...");
				$(this).removeClass("expresso-search-focused");
			};
		});
		
		

		
		// 00. GLOBAL CUNTIONS
		
		
		// Functions used in many places
		
		// updateGlobalColors(); Used for updating global colors when working with configurator
			function updateGlobalColors(hex) {
				// Create dynamic variables
				var gstart = $("input#expresso_gradient_start").val();
				var gend = $("input#expresso_gradient_end").val();
				var gcolor = $("input#expresso_gradient_color").val();
				var altstart = $("input#expresso_alt_gradient_start").val();
				var altend = $("input#expresso_alt_gradient_end").val();
				var altcolor = $("input#expresso_alt_gradient_color").val();
				var menuheight = parseFloat($("#expresso_menu_height").val());
						
				// Update input formatting
				$("input.currently-editing").val(hex).css("background","#"+hex).css("color","#"+hex);

				// Generate dynamic change
				$("#temp-stylesheet style").empty();
				$("#temp-stylesheet style")
					.append("#expresso-page-header-menu-wrap-wrap {background: #"+gstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gstart+"&end="+gend+"&height="+menuheight+"&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu > li {border-right: 1px #"+gend+" solid;}")
					.append("ul#expresso-page-header-menu li a {color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu > li > a {border-right: 1px #"+gstart+" solid;}")
					.append("ul#expresso-page-header-menu li a:hover {background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height="+menuheight+"&width=1') repeat-x;background-position: center bottom;color: #"+altcolor+";}")
					.append("ul#expresso-page-header-menu > li.currently-hovered {border-right: 1px #"+altstart+" solid;}")
					.append("ul#expresso-page-header-menu > li.currently-hovered > a {border-right: 1px #"+altend+" solid;}")
					.append("ul#expresso-page-header-menu ul {border-right: 1px #"+altstart+" solid;border-left: 1px #"+altstart+" solid;border-bottom: 1px #"+altstart+" solid;}")
					.append("ul#expresso-page-header-menu ul li a {background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height=40&width=1') repeat-x;background-position: center bottom;color: #"+altcolor+";border-top: 1px #"+altend+" solid;}")
					.append("ul#expresso-page-header-menu ul li a:hover {background: #"+gstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gstart+"&end="+gend+"&height=40&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu li.currently-hovered a.currently-hovered{background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height=40&width=1') repeat-x;background-position: center bottom;color: #"+altcolor+";}")
					.append("ul#expresso-page-header-menu li ul li.currently-hovered a.currently-hovered{background: #"+gstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gstart+"&end="+gend+"&height=40&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu > li > a.expresso-current-page{background: #"+gend+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gend+"&end="+gstart+"&height=40&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu > li > a {text-shadow: #"+gend+" 1px 1px 1px;}ul#expresso-page-header-menu li a:hover,ul#expresso-page-header-menu li:hover > a {text-shadow: #"+altstart+" 1px 1px 1px;}ul#expresso-page-header-menu ul li a {text-shadow: #"+altstart+" 1px 1px 1px;}ul#expresso-page-header-menu ul li a:hover {text-shadow: #"+gend+" 1px 1px 1px;}")
					


						
									
					.append("div#expresso-footer-widgets-container-wrap {background: #"+gstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gstart+"&end="+gend+"&height=70&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("div#expresso-second-menu-container-wrap {background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height=30&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("div#expresso-second-menu-container-wrap a {color: #"+altcolor+";}")
					.append("div#expresso-copyright-container-wrap {background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height=30&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}");
			};
		
		// updateMenuDimensions(); Used for updating Main Menu Dimensions while working with configurator
			function updateMenuDimensions() {
				var menuheight = parseFloat($("#expresso_menu_height").val());
				var menupaddingleft = parseFloat($("#expresso_menu_padding_left").val());
				var menupaddingright = parseFloat($("#expresso_menu_padding_right").val());
				var menufontsize1 = parseFloat($("#expresso_menu_first_font_size").val());
				var menufontsize2 = parseFloat($("#expresso_menu_second_font_size").val());
				var menupaddingtop = Math.round((menuheight - menufontsize1)/2);
				var menupaddingbottom = Math.round((menuheight - menufontsize1)/2);
				var gstart = $("input#expresso_gradient_start").val();
				var gend = $("input#expresso_gradient_end").val();
				var gcolor = $("input#expresso_gradient_color").val();
				var altstart = $("input#expresso_alt_gradient_start").val();
				var altend = $("input#expresso_alt_gradient_end").val();
				var altcolor = $("input#expresso_alt_gradient_color").val();
							
				$("#temp-menu-stylesheet style").empty();
				$("#temp-menu-stylesheet style")
					.append("ul#expresso-page-header-menu li a {padding-left: "+menupaddingleft+"px;padding-right: "+menupaddingright+"px;padding-top: "+menupaddingtop+"px;padding-bottom: "+menupaddingbottom+"px;font-size: "+menufontsize1+"px;}")
					.append("ul#expresso-page-header-menu ul {top: "+(menuheight+2)+"px;}")
					.append("ul#expresso-page-header-menu ul li a {font-size: "+menufontsize2+"px;}");
					
				$("#temp-stylesheet style")
					.append("#expresso-page-header-menu-wrap-wrap {background: #"+gstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+gstart+"&end="+gend+"&height="+menuheight+"&width=1') repeat-x;background-position: center bottom;color: #"+gcolor+";}")
					.append("ul#expresso-page-header-menu li a:hover {background: #"+altstart+" url('http://www.tlumiki.eu/wp-content/themes/expresso2-tlumiki/expresso/gradient.php?start="+altstart+"&end="+altend+"&height="+menuheight+"&width=1') repeat-x;background-position: center bottom;color: #"+altcolor+";}")
					
					
			};
		
		
		// EXPRESSO LINK BLOCKS
			$("div#expresso-link-blocks > ul > li:last-child").addClass("last-li");
			$("div#expresso-link-blocks > ul > li > a").each(function() {
				var image_link = $(this).children("img").attr("src");
				$(this).children("img").remove();
				$(this).css("background-image","url('"+image_link+"')").css("background-position","center bottom");
				$(this).addClass("topradius");
				$(this).parent().addClass("box");
				var image_link = $(this).text();
				$(this).html('<span class="block-link-title">'+image_link+'</span>');
			});
			$("div#expresso-link-blocks > ul > li ").each(function() {
				var link_container = $(this).children("a");
				$(this).children("a").remove();
				var link_description = $(this).text();
				$(this).empty();
				$(this).html('<span class="block-link-description">'+ link_description +'</span>');
				$(this).prepend(link_container);
			});
			$("div#expresso-link-blocks > ul > li > a").hover(
				function() {
					$(this).css("background-position","center top");
				},
				function() {
					$(this).css("background-position","center bottom");
				}
			);
			$("div#expresso-link-blocks-container").show();
		
		// 01. MAIN MENU
		// Menu on the top of the page

			// 01a. FIX FOR WHEN MENU IS A WIDGET
			$("ul#expresso-page-header-menu div").unwrap();
			$("div#expresso-page-header-menu-wrap div ul:first").attr('id','expresso-page-header-menu');
		
			// 01b. ANIMATIONS
				// First level animations
					$("ul#expresso-page-header-menu > li").hover(
						function() {
							$(this).children("ul").stop(true, true).slideDown(300);
						},
						function() {
							$(this).children("ul").stop(true,true).slideUp(100);
						}
					);
					
				// All levels but firstChild
					$("ul#expresso-page-header-menu li ul li").hover(
						function() {
							$(this).children("ul").stop(true,true).show(200);
						},
						function() {
							$(this).children("ul").stop(true,true).hide(100);
						}
					);
				
			// 01c. IE fix
				$("ul#expresso-page-header-menu li").hover(
					function() {
						$(this).addClass("hovered");
						$(this).children("ul").addClass("ul-hovered");
					},
					function() {
						$(this).removeClass("hovered");
						$(this).children("ul").removeClass("ul-hovered");
					}
				);
			
			// 01d. CORNERS
				$("ul#expresso-page-header-menu li").each(function() {
					// Overall Radius
					$(this).children("ul").addClass("shadow").addClass("bottomradius");
					
					// Bottom Radius
					$(this).children("ul").children("li:last").addClass("bottomradius");
					$(this).children("ul").children("li:last").children("a").addClass("bottomradius");

					// Top Corners of menu
					// $("#expresso-page-header-menu-wrap-wrap").addClass("topradius");
					// $("#expresso-page-header-menu-wrap-wrap-wrap li:first").addClass("topleftradius");
					// $("#expresso-page-header-menu-wrap-wrap-wrap li:first a:first").addClass("leftradius");
					
				});
			
			// 01e. CURRENT
				$("ul#expresso-page-header-menu li").hover(
					function() {
						$(this).addClass("currently-hovered");
						$(this).children("a").addClass("currently-hovered");

					},
					function() {
						$(this).removeClass("currently-hovered");
						$(this).children("a").removeClass("currently-hovered");

					}
				);
				$("ul#expresso-page-header-menu li.current_page_item, ul#expresso-page-header-menu li.current_page_ancestor").each(function() {
					$(this).addClass("expresso-current-page");
					$(this).children("a").addClass("expresso-current-page");
				});
			
			// 01f. LAST CLASSES
				$("#expresso-page-header-menu ul li:last-child").addClass("menu-last-li");

			// 01g. NAVIGATION ARROWS
				$("#expresso-page-header-menu > li:has('ul') > a").append("<span class='arrow'></span>");
				$("#expresso-page-header-menu li ul li:has('ul') > a").append("<span class='arrow'></span>");


				
		// 02. SECOND MENU
			// Different formatting on the front page and other page
				$("body div#expresso-second-menu-container-wrap").not("body.home div#expresso-second-menu-container-wrap").css("margin-bottom","29px");
		
			// Secone menu at the bottom of the page
			
				// All pages but Front Page
				$("body div#expresso-second-menu-container-wrap").not("body.home div#expresso-second-menu-container-wrap").addClass("box");
				$("body div#expresso-second-menu-container > ul").not("body.home div#expresso-second-menu-container > ul").addClass("box");
				$("body div#expresso-second-menu-container > ul > li:first").not("body.home div#expresso-second-menu-container > ul > li:first").addClass("leftradius");
				$("body div#expresso-second-menu-container > ul > li:first > a:first").not("body.home div#expresso-second-menu-container > ul > li:first > a:first").addClass("leftradius");
			
				// Front page			
					$("body.home div#expresso-second-menu-container-wrap").addClass("topradius");
					$("body.home div#expresso-second-menu-container > ul").addClass("topradius");
					$("body.home div#expresso-second-menu-container > ul > li:first").addClass("topleftradius");
					$("body.home div#expresso-second-menu-container > ul > li:first > a:first").addClass("topleftradius");
			
			// 02a. FIX FOR WHEN SECOND MENU IS A WIDGET
			$("div#expresso-second-menu-container ul div").unwrap();
			$("div#expresso-second-menu-container div ul:first").unwrap();
		
			// 02b. ANIMATE FIRST LEVEL SUBMENU
				// First level animations
					$("div#expresso-second-menu-container > ul > li").hover(
						function() {
							$(this).children("ul").stop(true, true).slideDown(300);
						},
						function() {
							$(this).children("ul").stop(true,true).slideUp(100);
						}
					);
			// 02c. ANIMATE SECOND LEVEL SUBMENU
					$("div#expresso-second-menu-container ul li ul li").hover(
						function() {
							$(this).children("ul").stop(true,true).show(200);
						},
						function() {
							$(this).children("ul").stop(true,true).hide(100);
						}
					);
			// 02d. ADD CORNERS TO MENU
				$("div#expresso-second-menu-container ul li").each(function() {
					// Overall Radius
					$(this).children("ul").addClass("shadow").addClass("bottomradius");
					
					// Bottom Radius
					$(this).children("ul").children("li:last").addClass("bottomradius");
					$(this).children("ul").children("li:last").children("a").addClass("bottomradius");

					// Top Right Radius for last ul
					
				});
			
			// 02e. CURRENT
				$("div#expresso-second-menu-container ul li.current_page_item, div#expresso-second-menu-container ul li.current_page_ancestor")
				.not("div#expresso-second-menu-container > ul > li.current_page_item")
				.not("div#expresso-second-menu-container > ul > li.current_page_ancestor")
				.each(function() {
					$(this).addClass("expresso-current-page");
					$(this).children("a").addClass("expresso-current-page");
				});
			$("div#expresso-second-menu-container > ul > li.current_page_item, div#expresso-second-menu-container > ul > li.current_page_ancestor").each(function() {
					$(this).addClass("expresso-current-page-first");
					$(this).children("a").addClass("expresso-current-page-first");
				});
			// 02f. LAST CLASSES
			
			// 02g. HOVER CLASSESS
				$("div#expresso-second-menu-container > ul > li").hover(
					function() {
						$(this).addClass("first-li-hover");
						$(this).children("a").addClass("first-a-hover");
					},
					function() {
						$(this).removeClass("first-li-hover");
						$(this).children("a").removeClass("first-a-hover");
					}
				);
				$("div#expresso-second-menu-container ul li li").hover(
					function() {
						$(this).addClass("li-hover");
						$(this).children("a").addClass("a-hover");
					},
					function() {
						$(this).removeClass("li-hover");
						$(this).children("a").removeClass("a-hover");
					}
				);
				
			// 02h. CHILDREN CLASSESS
				$("div#expresso-second-menu-container > ul > li").addClass("first-level-li");
				$("div#expresso-second-menu-container > ul > li > a").addClass("first-level-a");

			// 02i. NAVIGATION ARROWS
				$("div#expresso-second-menu-container > ul > li:has('ul') > a").append("<span class='arrow'></span>");
				$("div#expresso-second-menu-container ul li ul li:has('ul') > a").append("<span class='arrow'></span>");	
			
		// 03. ANIMATION
			// START ANIMATION
				// CODE FOR JQUERY CYCLE
								
				// CODE FOR NIVO SLIDER
									// Start the animation
					$(window).load(function() {
						$('#slider').nivoSlider({
							effect: 'sliceUpDownLeft',
							pauseTime: 10000
						});
						// Add corners to caption
						$("div.nivo-caption").addClass("box");
					});
									
				
				
		// 06. BREADCRUMBS
			// Add class bold to the first element
			$("#expresso-breadcrumbs span:last").addClass("bold");
			
			// Add bottom corners
			$("#expresso-breadcrumbs-container-wrap").addClass("topradius");
			
			// Animation Toggle
			$("div#expresso-animation-toggle").click(function() {
				$("div#expresso-show-animation").toggle();
				$("div#expresso-hide-animation").toggle();
				$("div#expresso-animation-container-wrap-wrap-wrap").slideToggle(500);
			});
				
				
		// 07. FOOTER WIDGETS
			// 07a. FIRST CLASS
			$("div.expresso-footer-widget-wrap:first").addClass("first-footer-widget-wrap");
			$("div.expresso-footer-widget:first").addClass("first-footer-widget");
			
			$("div.expresso-footer-widget-wrap:nth-child(2)")
				.addClass("second-footer-widget-wrap")
				.children("div.expresso-footer-widget")
				.addClass("second-footer-widget");
		
			$("div.expresso-footer-widget-wrap:nth-child(2)")
				.addClass("third-footer-widget-wrap")
				.children("div.expresso-footer-widget")
				.addClass("third-footer-widget");
		
			$("div.expresso-footer-widget-wrap:nth-child(2)")
				.addClass("fourth-footer-widget-wrap")
				.children("div.expresso-footer-widget")
				.addClass("fourth-footer-widget");
		
			$("div.expresso-footer-widget-wrap:nth-child(2)")
				.addClass("fifth-footer-widget-wrap")
				.children("div.expresso-footer-widget")
				.addClass("fifth-footer-widget");
		
		// 08. COPYRIGHT BAR
			// 08a. CURRENT CLASSESS
			$("div#expresso-copyright-container ul li.current_page_item, div#expresso-copyright-container ul li.current_page_ancestor").each(function() {
					$(this).addClass("expresso-current-page");
					$(this).children("a").addClass("expresso-current-page");
				});
			// 08b. HOVER CLASSESS
				$("div#expresso-copyright-container ul li").hover(
					function() {
						$(this).addClass("li-hover");
						$(this).children("a").addClass("a-hover");
					},
					function() {
						$(this).removeClass("li-hover");
						$(this).children("a").removeClass("a-hover");	
					}
				);
			// 08c. FIRST CLASS
				$("div#expresso-copyright-container ul li:first").addClass("first-li");
				$("div#expresso-copyright-container ul li:first a").addClass("first-a");
				$("div#expresso-copyright-container ul li:first").hover(
					function() {
						$(this).addClass("first-li-hover");
						$(this).children("a").addClass("first-a-hover");
					},
					function() {
						$(this).removeClass("first-li-hover");
						$(this).children("a").removeClass("first-a-hover");
					}
				);
				
				
				
		
		$(window).load(function() {
			$("#expresso-body").show();
			
		});
});
})(jQuery);
