no_func = function() {
                //preventDefault            
}

function stageVideoHeight() {
                $("#page").height(787);
                $("#main").height(557);
                $("#stage").animate({height: "555px"},1000);
                $("#fb_mod_buehne_flash").height(555);
}


function stageSlideshowHeight() {
                $("#page").animate({height: "620px"},500);
                $("#main").animate({height: "464px"},600);
                $("#stage").animate({height: "388px"},1000);
                $("#fb_mod_buehne_flash").height(388);
}


//adding js class to <html> to prevent flashing of hiding layers - along with css
$('html').addClass('js');



//zebra table as function to call it after DOM manipulation
function zebratable() {
                var tSelects = $("#mainContent table.table_normal tr:odd, #mainContent table.table_download tr:odd, table.dat tr:odd");
                tSelects.each(function(index) {
                               $(this).addClass("stripe_dark");
                });
}

//tr hover
function trHover() {
$("#mainContent table tr, #tblToGrid tr").not( $("#mainContent table tr:first, #tblToGrid tr:first, tr.hidden_details")).hover(
                function() {
                               $(this).addClass("tr_hover");
                               },
                function() {
                               $(this).removeClass("tr_hover");
                });
}

function trHover1() {
$("#mainContent table.contenttable tr").hover(
                function() {
                               $(this).addClass("tr_hover");
                               },
                function() {
                               $(this).removeClass("tr_hover");
                });
}



//top_dropdown_menu
function mainmenu_dropdown(){
$("#nav_main ul ul").css({display: "none"}); // Opera Fix
$("#nav_main ul li").hover(function(e){
                               $(this).addClass("active");
                               $(this).find('a:not(ul ul a)').addClass("active");
                               $(this).find('ul:first').css({visibility: "visible",display: "none"}).show(10);
                },function(){
                               $(this).removeClass("active");
                               $(this).find('a:not(ul ul a)').removeClass("active");
                               wth = $(this).find('ul:first')
                               wth.hide(50,function() {$(wth).css({visibility: "hidden"}).end();});
                               });
}


//extra func as it is not working with hover
function loginOn() {
                $("li.login").bind("click.login",function(e) {
                               e.preventDefault();
                               $(this).find('a').toggleClass("active");
                               $(this).parent().toggleClass("active");
                               $("#login_box").toggleClass("showing");
                               $("#helpsub").removeClass("showing");
        $("#langsub").removeClass("showing");        
                               $("li.helper").find('a:first').removeClass("activeHelp");
                               $("li.helper").find('a:first').removeClass("active");
                               $("li.helper").find('span:first').removeClass("active");
                               $("#dropdown").removeClass("activeHelp");


                });
}


function loginOff() {
                $("li.login").unbind("click.login");
}


// extra func as it is not working with hover
// help, display and hide help layer
function helpOn() {
                $("li.helper").bind("click", function(e) {
                               e.preventDefault();
                               $(this).find('a:first').toggleClass("activeHelp");
                               $(this).parent().toggleClass("activeHelp");
                               $("#helpsub").toggleClass("showing");
                               $("#login_box").removeClass("showing");
        $("#langsub").removeClass("showing");        
                               $("li.login").find('a:first').removeClass("active");
                               $("li.login").find('span:first').removeClass("active");
                               $("#dropdown").removeClass("active");
                });
}

  // show language menu
function langOn() {
                $("li.languages").bind("click", function(e) {
                               e.preventDefault();
                               $(this).find('a').toggleClass("activeLang");
                               $(this).parent().toggleClass("activeLang");
                               
                               $("#langsub").toggleClass("showing");
                               
                               $("#login_box").removeClass("showing");
        $("#helpsub").removeClass("showing");
        
                               $("li.login").find('a:first').removeClass("active");
                               $("li.login").find('span:first').removeClass("active");
                               $("#dropdown").removeClass("active");
                });
}





 

$(document).ready(function() {
                                                
                   //show browser update div 
		   if ($.browser.mozilla && (parseFloat($.browser.version) < 1.9)) {
			$("#IE5_FF2").slideDown(1000);
		   }	   
		                            
                
		   //bind click handler for top menu
		   helpOn();
		   loginOn();
		   langOn();
		   mainmenu_dropdown();
		   trHover();
		   trHover1();
		   zebratable();
		   
		   
		    //extra style for standard RTE tables
		   $('.contentTextImage table').each(function() {
				$(this).find('tr:even').addClass("stripe_dark");											
		   });

		        //in #news the last li needs extra class to prevent floating
		   $("#news li:last").addClass("last_text");		   
		   

			//fix for top-link
		   var currentURL = document.location.href;
		   $("a.top").attr({ href: currentURL+"#top"});
										  
		   
		   
		   //fixes headerpart grafic
		   var dropdownWidth = $("#dropdown").width();
		   //alert (dropdownWidth);
		   $("#header_parts").after("<div id='dropdownGrafic' style='width: "+dropdownWidth+"px'></div>");


		   //adds or remove background depending on classes > for overview cat and detail pages
		   if ( $("div").hasClass("abstract") ) {
						   $('#page #main #mainContent .bg_content').css('background', 'url(fileadmin/templates/lib/gfx/bg_content.png) 0 100% no-repeat');
		   }
		   if ( $("a").hasClass("dc-bmecat-print") ) {
						   $('#page #main #mainContent .bg_content').css('background', 'none');             
		   }                                                                                               
		   
		   
		   //adds extra class for text teaser
		   $(".mod_teaser_text:even").addClass("margin_right");
		   //for IE it's mandetory to attach an shim gif instead of background none!
		   $("#right_col .mod_related_text:last p").css({background: "url(gfx/common/div_rightCol_teaser_no.gif) 0 100% repeat-x"})
		   
										  
		   if (jQuery.browser.msie) {
			  if(parseInt(jQuery.browser.version) == 6) {
			   // $('.tab_menu ul').bgiframe();
			  }
			} 

		   
		   /////////////////////////////////////////////////
		   
		   //CSS SELECTORS FOR SPECIAL CASES
		   $("#main input[type='text'],#main input[type='password']").addClass("input_text");
		   
		   $("a.btn_orange:last").css({marginRight: "0"});


		   //giving padding only to the first ul. It's impossible to do this without each()                                    
		   $("div.teaser_box").each(function() {
						   $(this).find("ul:first").css({paddingTop: "10px"});
		   });
		   
		   
		   
			//JUST FOR ONE SPECIAL MODULE, NOT FOR ALL. giving in box special_p the second p an extra padding top
		   //$("div.special_p p:eq(1)").css({paddingTop: "10px"});
		   
		   
		   //change each link with # to javascript void();
		   $('#mainContent').find('a').each( function(){
						   if ($(this).attr('href')=='#') { 
										  $(this).attr('href','javascript:no_func();');
						   }
		   });           
		   
		   
		   //add support for FF2 for inline-block
		   jQuery.each(jQuery.browser, function(i, val) {
						   if(i=="mozilla" && jQuery.browser.version.substr(0,3)=="1.8.1")
						   $("span.block, span.btn_orange").css({display: "-moz-inline-box"});
										  
		   });
		   
		   
		   //register form hiding and showing element
		   if($("#new_customer:checked").val()=='new_customer'){
						   $("#customer").hide();                                                               
		   }
		   if($("#regular_customer:checked").val()=='regular_customer'){
						   $("#full, #business_wrap").hide();
		   }
		   
		   $("input#new_customer").click(function() {
						   $("#customer").fadeOut(200);
						   $("#full, #business_wrap").fadeIn(200); //fade in extra checkbox
						   $(".registerBox_l h6").css("backgroundImage","url(fileadmin/templates/lib/gfx/bg_registerBox_rl_top.png)"); //swap image to prevent broken gradient
						  $("#customer .required").addClass("no_data").removeClass("required"); //adds a new identifier class for the required fields
						   $("#full .no_data").addClass("required").removeClass("no_data"); //and removes the required class to submit form also for hidden fields
		   });
		   $("input#regular_customer").click(function() {
						   $("#full, #business_wrap").fadeOut(200);
						   $("#customer").fadeIn(200);
						   $(".registerBox_l h6").css("backgroundImage","url(fileadmin/templates/lib/gfx/bg_registerBox_rl_topG.png)");
						   $("#full .required").addClass("no_data").removeClass("required");
						   $("#customer .no_data").addClass("required").removeClass("no_data");
		   });

		   
		   
		   //submit_btns - hover
		   $(".submit_btn").hover(
			 function () {
						   $(this).addClass("submit_btn_act");
			 }, 
			 function () {
						   $(this).removeClass("submit_btn_act");
			 }
		   );
														  
		   
		   //submit_btns - click
		   $(".submit_btn").click(function() {
						   $(this).addClass("submit_btn_click");                                                                                                                 
		   });
		   
		   
		   
			//orange_btns - hover
		   $(".btn_orange").hover(
			 function () {
						   $(this).addClass("btn_orange_act");
			 }, 
			 function () {
						   $(this).removeClass("btn_orange_act");
		   });
		   
			//grey_btns - hover
		   $(".btn_grey").hover(
			 function () {
						   $(this).addClass("btn_grey_act");
			 }, 
			 function () {
						   $(this).removeClass("btn_grey_act");
		   });
										  
		   
//orange_btns - click
		   $(".btn_orange").mousedown(function() {
				$(this).addClass("btn_orange_click");                                                                                                                 
		   }); 
		   
		   $(".btn_orange").mouseup(function () {
				$(this).removeClass("btn_orange_click");
		   });                           
		   
		   $(".btn_orange").mouseout(function () {
				$(this).removeClass("btn_orange_click");
		   });           

//grey_btns - click
		   $(".btn_grey").mousedown(function() {
						   $(this).addClass("btn_grey_click");                                                                                                                      
		   }); 
		   
		   $(".btn_grey").mouseup(function () {
						   $(this).removeClass("btn_grey_click");
		   });                           
		   
		   $(".btn_grey").mouseout(function () {
						   $(this).removeClass("btn_grey_click");
		   });                                                                          
		   
		   
		   //input focus
		   $("input[type=text],input[type=password],textarea").not("input#smallSearchfield").focus(function() {
						   $(this).css({backgroundPosition: "0 -500px", borderBottomColor: "#c3c3c3", borderRightColor: "#c3c3c3"});                                                                                                               
		   });
		   $("input[type=text],input[type=password],textarea").blur(function() {
						   $(this).css({backgroundPosition: "0 0", borderBottomColor: "#e8e8e8", borderRightColor: "#e8e8e8"});                                                                                                                                  
		   });


			//show hide text in input
		   $("#smallSearchfield, .basket_usersize, .zipsearch").toggleVal();
		   
		   
		   //temp news class
		   $(".topnews:odd").addClass("topnews_right");
		   $(".topnews:even").addClass("topnews_left");
															 
		   
		   $(".btn_search_selection").click(function() {
						   $("#searching ul.dropdown").slideToggle("fast");
						   return false;
		   });
						   
						   
						   
						   
		   //Main Nav Dropdown - just working through find() otherwise always the last 
		   $("#nav_main ul ul").find('a:last').css("border","none");


		   //Search Button
		   $("#searchButtonMagnifier").hover(
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search_over.gif'});
						   },
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search.gif'});
		   });
		   
		   $("#searchButtonMagnifier").mousedown(
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search_click.gif'});
						   },
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search.gif'});
		   });
		   
		   $(".searchsubmit").hover(
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search_over.gif'});
						   },
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search.gif'});
		   });
		   
		   $(".searchsubmit").mousedown(
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search_click.gif'});
						   },
						   function() {
										   $(this).attr({src: 'fileadmin/templates/lib/gfx/menus/btn_search.gif'});
		   });
		   
														  
		   
		   //TABS
		   $("#tab_2_content").hide();
		   
		   
		   //Basket address handling
		   $("#address_selection ul.level_1").hide();
		   
		   $("#address_selection ul.level_0").hover(
						   function() {
										   $(this).parent().css({backgroundPosition: "0 -70px"});
						   },
						   function() {
										   $(this).parent().css({backgroundPosition: "0 0"});
		   });
		   
		   
		   $("#address_selection ul.level_1 div.inlineEdit").hover(
						   function() {
										   $(this).css({background: "#e5e5e5"});
						   },
						   function() {
										   $(this).css({background: "none"});
		   });
																																																																																									

		   
		   //Standard but in other table
		   var tSelects = $("#mainContent table.table_normal_inline tr:even");
		   tSelects.each(function(index) {
						   $(this).addClass("stripe_dark");
		   });
		   
		   //Table with hidden trs
		   var tSelect = $("#mainContent table.hidden_tr tr:has(a):odd");
		   tSelect.each(function(index) {
						   $(this).addClass("stripe_dark");
		   });
		   
		   
		   //different bgs for DL
		   $("dl.catEntry:even").addClass("odd");
		   
		   
		   //binds function to all links with ID
		   /*
		   $.localScroll ({
						   hash: true, //adds a hash into the address bar to go back/front
						   lazy: true //to add the scrollTo func to new addes elements via AJAX
		   });
		   */
		   
		   
		   $('#privacy_wrap').click(function() {
//                                           self.location.href = "#footer"
		   });
		   
						   
		   /*JS form validation
		   $(".tx_powermail_pi1_form, #registerform").validate({
						   messages: {
										   required: "Bitte ausfuellen!"
						   }
		   });
		   */
		   
						   // validation page "Registrierueng" eshop
						   // validate signup form on keyup and submit
/*
		   $("#registerform").validate({
						   rules: {
										   company:        { required: true },
										   street:         { required: true },
										   zip:            { required: true }, 
										   city:           { required: true },
										   surename:       { required: true },
										   lastname:       { required: true },
										   department:     { required: true },
										   email:          { required: true, email: true },
										   phone:          { required: true },
										   business:       { required: true },                                                                                
										   privacy_policy: { required: true },                                                                           
										   TAC:            { required: true }                                                                                      
						   },
						   messages: {
										   business:       { required: "Bestätigen Sie, daß Sie als Firmenkunde bestellen!" },
										   privacy_policy: { required: "<div style=\"width: 100%; height:52px;\">&nbsp;</div>Stimmen Sie den Datenschutzbestimmungen zu!" },
										   TAC:            { required: "<div style=\"width: 100%; height:53px;\">&nbsp;</div>Akzeptieren Sie die Lapp Kabel e-shop AGB!" }
						   }
		   });
		   
		   $.extend($.validator, {
						   messages: {
										   required: "Bitte ausf�llen!",
										   email: "E-Mail nicht korrekt!"
						   }
		   });
*/                           
		   
		   
		   // site crossing search
		   $('ul.dropdown li a').click(function(e) {
						   $('#tx-dgpsitecrossingsearch-pi2-search-type-small').val(e.target.title);
		   });


		   //Dialogs
		   $(".privacyPolicy").click(function(e) {
						   e.preventDefault();
						   $("#privacyPolicyTitle").dialog('open');
		   });
		   
		   $(".tac").click(function(e) {
						   e.preventDefault();
						   $("#tacTitle").dialog('open');
		   });
		   
		   $("#jq-dialog-wrapping").click(function(e) {
						   e.preventDefault();
						   $("#jq-dialog-wrappingBox").dialog('open');
		   });
		   
		   $(".standardlength").click(function(e) {
						   e.preventDefault();
						   $("#standardlength").dialog('open');
		   });
		   
		   $(".iconUserNew").click(function(e) {
						   e.preventDefault();
						   $("#newUser").dialog('open');
		   });
		   
		   $(".iconBasketImport").click(function(e) {
						   e.preventDefault();
						   $("#importBasket").dialog('open');
		   });
		   
		   $(".user_edit").click(function(e) {
						   e.preventDefault();
						   $("#editUser").dialog('open');
		   });
		   
		   $(".registerForm").click(function(e) {
						   e.preventDefault();
						   $("#registerFormL").dialog('open');
		   });

						   
		   // textimage, hide image div, if no img is present - get all container, then check if img is there or no and just remove this
		   $('.bg_content .image_container').each(function(index) {
						   var n = $(this).find("img").length;
						   if ( n == 0 ) {
										   $(this).remove();
						   }
		   });



		   // remove IE6 Bug. Li is displayed even though a-tag is hidden in li, li is still displayed.
		   $('#main div.nav_sub ul.naviSub').find('a.amzHide').parent().remove();                            

		   
			// beta layer with form
		   $("div.beta").click(function(){
						   $("#betaModal1").dialog('open');
		   });
		   
		   
		   //set flags for language menu
		   $("#langsub a:contains('de')").addClass("de");
		   
		   
		   
		   //adds an Highlight status to the tab nav if the menu point is selected 
			$("#breadcrumbNav:contains('Kabelfinder'),#breadcrumbNav:contains('Steckerfinder')").parents().find("a.productfinder").addClass("topNavAct");
		   $("#breadcrumbNav:contains('e-shop')").parents().find("a.catalog").addClass("topNavAct");
		   $(".h1_grey:contains('suche'),#dc-cablefinder-recordsFound:contains('Trefferanzahl')").parents().find("a.search").addClass("topNavAct");
		   //EN
		   $("#dc-cablefinder-title:contains('Cablefinder'),#breadcrumbNav:contains('Cablefinder')").parents().find("a.productfinder").addClass("topNavAct");
		   $("#breadcrumbNav:contains('e-shop')").parents().find("a.catalog").addClass("topNavAct");
		   $(".h1_grey:contains('search'),#dc-cablefinder-recordsFound:contains('Trefferanzahl')").parents().find("a.search").addClass("topNavAct");
		   //PT
		   $("#dc-cablefinder-title:contains('Selecione'),#breadcrumbNav:contains('Selecione')").parents().find("a.productfinder").addClass("topNavAct");
		   $("#breadcrumbNav:contains('Catálogo')").parents().find("a.catalog").addClass("topNavAct");
		   $(".h1_grey:contains('Busca'),#dc-cablefinder-recordsFound:contains('mostre')").parents().find("a.search").addClass("topNavAct");
		   
		   
		   //get user name via plaintext as there is a xmlresponse bug in IE6
		   var userName = function() {
		   
			   $.ajax({
				   type: 'POST',
				   url: '..'+dgpsapshop_serverPath+'?obj=Users&method=POST&act=getUserName',
				   dataType: 'xml',
				   success: function(data) {
								  
					  $(data).find("getusername").each(function() {
						  var uname = $(this).find('LOGIN_NAME').text();
						  
						  if(uname.length > 0) {
										  $("#header_parts").before("<div id='status'>" + getLL('JQ_header_you_are_logged_in') + ":<br /> <span class='name'>" + uname + "</span></div>");
						  }
					  });
								  
												  
				   }
			   });                                          
		   }


			//loading functions
			$(window).load(function () {
						   userName();
			});           


						   // hide advicetext on overview (non product) pages
			var n = $('.bg_content').find('.tx-dgpwebcatalog09-pi').length;
			if( n < 1 ) {
						   $('.adviceText').remove();
			}

			
			
			// ATTENSION: THROWS AN ERROR ON IE!!!!!! remove last line in related boxes
			//$(".teaser_box").find("div:last, li:last").css({background: "url(fileadmin/templates/lib/gfx/shim.gif) repeat;"});
			
			
			//fixes the active status in product wizard
			$("#page").live("mousemove", function() {
						   $("li.wiz-visited:last").addClass("wiz-visited2");
			});
                
                //fixes the active status in registration and basket wizard
                $("#page").live("mousemove", function() {
				   $("ul.wizard li.wiz-no:not('.active')").addClass("visited");
				   $("ul.wizard li.wiz-no:last").removeClass("visited");
				   if ($('.wiz-no.end').is(".active")) {
								   $("ul.wizard li.wiz-no:first").removeClass("visited");
								   $("ul.wizard li.wiz-act").addClass("visited");
								   $("ul.wizard li.wiz-no.end").addClass("visited2");
				   };
				   
				   if ($('.wiz-act').is(".active")) {
								   $("ul.wizard li.wiz-no:first").removeClass("visited");
								   $("ul.wizard li.wiz-no:not('.end'):last").addClass("visited");
				   };
                               
                });
                
                
                $("a[rel^='prettyPhoto']").prettyPhoto({
					   animationSpeed: 'normal', /* fast/slow/normal */
					   padding: 0, /* padding for each side of the picture */
					   opacity: 0.35, /* Value betwee 0 and 1 */
					   showTitle: true, /* true/false */
					   allowresize: true, /* true/false */
					   counter_separator_label: '/', /* The separator for the gallery counter 1 "of" 2 */
					   theme: 'light_square', /* light_rounded / dark_rounded / light_square / dark_square */
					   hideflash: false, /* Hides all the flash object on a page, set to TRUE if flash appears over prettyPhoto */
					   modal: false, /* If set to true, only the close button will close the window */
					   changepicturecallback: function(){}, /* Called everytime an item is shown/changed */
					   callback: function(){} /* Called when prettyPhoto is closed */
                });
                
                
			   //problems with displaying the status and relay prices in IE7
			   if($.browser.msie){
				   $(".status").css("display","block");
				   setTimeout ( '$("#productCarousel").css("position","relative")',1000 );
			   }
                
                
                

}); // end document ready
//---------------------------------------------------------------------------------------------------------------------------------------------------
                
                               //close menus whenever you click somewhere else on the page
                               // respond to any clicks that happen anywhere
                $(document).click(function(e){

                // your menu root element
                var menu = $('#searching ul.dropdown');

                // the element that was clicked
                var target = $(e.target);

                // if the element clicked isn't the menu or inside the menu
                // and if the menu is visible
                if (target.parents().andSelf().not(menu) && menu.is(':visible')) {

        // slide the menu up
        menu.slideUp("fast");

                }
                
                });


                //Tooltip
                 $(function() {
                               $('.help a, .help img, .help span').tooltip({
                                               track: true,
                                               delay: 0,
                                               showURL: false
                               });
                });
                
                function getCookie(NameOfCookie)
                {

                // First we check to see if there is a cookie stored.
                // Otherwise the length of document.cookie would be zero.

                if (document.cookie.length > 0)
                {

                // Second we check to see if the cookie's name is stored in the
                // "document.cookie" object for the page.

                // Since more than one cookie can be set on a
                // single page it is possible that our cookie
                // is not present, even though the "document.cookie" object
                // is not just an empty text.
                // If our cookie name is not present the value -1 is stored
                // in the variable called "begin".

                begin = document.cookie.indexOf(NameOfCookie+"=");
                if (begin != -1) // Note: != means "is not equal to"
                {

                // Our cookie was set.
                // The value stored in the cookie is returned from the function.

                begin += NameOfCookie.length+1;
                end = document.cookie.indexOf(";", begin);
                if (end == -1) end = document.cookie.length;
                return unescape(document.cookie.substring(begin, end)); }
                }
                return null;

                // Our cookie was not set.
                // The value "null" is returned from the function.

                }

