/****************************************
*
Bosch Main JS: Divisions OCS/CMS/ASA
*

e0: 	log message
e1: 	set/reset/validate default input text from textfields with class .cdVal
e2: 	mouseover for #leftNav
e3: 	iterate each #leftNav li.active to set active state
e4: 	!EXPIRED: fadeToggle stageContainer. Look at e16
e5: 	tab navigation (toggleTabContainer)
e6: 	accessory toggle up/down
e7: 	lightbox functions
e8: 	submit button: hover
e9: 	custom Bosch lightbox/popup with URL param processing and header include
e10: 	location change 
e11: 	flyout navigation (2-rows)
e12: 	autoresize height of current class elements
e13: 	slideToggle for FAQ Elements
e14: 	open Nyromodal with a function: openNyroManual (wUrl, WWidth, WHeight, WHeadline)
e15: 	search term validation: requires stvURL, stvWidth, stvHeight, stvHeadline
e16: 	Stage slideshow: 
		$('div#site').slideshow({duration:8000, delay:3000, autoPlay:true, ssButton: '.stagePg', ssContainer: '.stageContainer'});
e17: 	lightbox manual
e18: 	popup manual
e19: 	resize height of '.bobPreWrapper' 
*****************************************/


$(document).ready (function () {

	if ($('.foSub').length) {
		var index = navigator.appVersion.indexOf("Mobile");
		if (index > -1) {
			//mobile
			$('.foSub').bind('click', function () {
				var hovername = $(this).find('.foRow').attr('class');
				var hoverIndex = hovername.indexOf("hover");
				if (hoverIndex > -1) {
					$('.foRow').removeClass('hover');	
				} else {
					$(this).find('.foRow').addClass('hover');				
				}
			});
			$('.foSub a').bind('click', function(e) {
				var classname = $(this).attr('class');
				if (classname == "") {
					var active = $(this).parent().find('.foRow').attr('class');
					var activeIndex = active.indexOf("hover");
					if (activeIndex == -1) {
						e.preventDefault();
					}
				}
			});			
		} else {
			$('.foSub').bind('mouseenter', function () {
				$(this).find('.foRow').addClass('hover');
			});
			$('.foSub').bind('mouseleave', function () {
				$('.foRow').removeClass('hover');
			});
		}
		//$('.foSub').bind('mouseenter', function () {
		//	$(this).find('.foRow').addClass('hover');
		//});
		//$('.foSub').bind('mouseleave', function () {
		//	$('.foRow').removeClass('hover');
		//});
	}
	
	var test = navigator.appVersion.indexOf("Mobile");
	if (test > -1) {
		if ($('#mainNav ul li').length) {
			$('#mainNav ul li').each( function(index) {
				if ($(this).attr('class').length == 0 || $(this).attr('class') == 'active') {
					$(this).find('a').each( function(i) {
						var location = $(this).html().indexOf("span");
						if (location == -1) {
							$(this).click(function (e) {
								$('.foSub').find('.foRow').removeClass('hover');
								var hrefTest = $(this).attr('href');
								
								$('#mainNav ul li').each( function(innerindex) {
									if ($(this).attr('class').length == 0 || $(this).attr('class') == 'active') {
										$(this).find('a').each( function(inneri) {
											var innerlocation = $(this).html().indexOf("span");
											if (innerlocation == -1) {
												if ($(this).attr('href') != hrefTest) {
													$(this).attr('name', 'unclicked');
												}
											}
										});
									}
								});
								
								if ($(this).attr('name') != 'clicked') {
									e.preventDefault();
									$(this).attr('name', 'clicked');
								} 
							});						
						}
					});					
				}
			});
		}
	}
	
	// START e2 
		// bind: mouseover
		  if ($('#leftNavCat').length) {
		$('#leftNavCat li a').bind ('mouseover', function () {
			$('#leftNavCat li *').removeClass ('lnH');
			$(this).closest('li').children('.l1, .l2, .l3, .l4, span.navE').addClass('lnH');
		});
		
		// bind: mouseout
		$('#leftNavCat li a').bind ('mouseout', function () {
			$('#leftNavCat li *').removeClass ('lnH');
		});
		}
	// END e2 
		
	// START e3
	  if ($('#leftNavCat').length) {

		$('#leftNavCat li.active').each (function () {
			$(this).children('.l1, .l2, .l3, .l4, span.navE').addClass('lnA');
		});
		}
	// END e3 
		
	
});

// END e19


