var current_site = window.location.href;
var curr_site = current_site.split ("/");
var reverse_current_site = curr_site.reverse ();

if (reverse_current_site[0] != 'updatebrowser')
{

	switch (BrowserDetect.browser)
	{
		case 'Firefox':
			if (BrowserDetect.version < 3)
				window.location.href = '/updatebrowser';
		break;
		
		case 'Explorer':
			if (BrowserDetect.version < 7)
				window.location.href = '/updatebrowser';
		break;
				
		default: ;
	}
}

function image_changer (img_src, obj)
{
	$('image').src = img_src;
	$('more-images').childElements().each (function (subdiv) {
		$(subdiv).childElements().each (function (elements) {
			if ($(elements).hasClassName ('active'))
			{
				$(elements).removeClassName ('active');
			}
		
		});
	});
	$(obj).up().addClassName ('active');
}

function shipping_opener ()
{
	window.open('/versand', 'fenster1','width=720,height=720,status=yes,scrollbars=yes,resizable=yes');
	return false;
}

function print_opener (url)
{
	window.open(url, 'fenster1','width=625,height=720,status=yes,scrollbars=yes,resizable=yes');
	return false;
}

jQuery (document).ready (function () {

	var menu_close = false;
	var default_miny = 100;
	var default_maxy = 350;
	var miny = default_miny;
	var maxy = default_maxy;
	var gallery = 0;
	var move_images = 149;
	
	var change_active_coord = false;
	hide_sitemap ();
	
		var change_height = 0;
			
		if (jQuery ('.mini-cart.highlight').height () > 0 )
		{
			change_height = 30;
		}	
		
		var colleftHeight = jQuery ('.middle.col-2-left-layout').height() - 300 - 1;
		
		
		if (jQuery ('.col-2-left-layout .col-left.side-col').height () > 0 && colleftHeight > jQuery ('.col-2-left-layout .col-left.side-col').height ())	
		{
			jQuery ('.col-2-left-layout .col-left.side-col').height (colleftHeight);
		}	
		if (jQuery ('.col-2-left-layout .category_overview').height () > 0 && colleftHeight > jQuery ('.col-2-left-layout .category_overview').height ())
		{
			jQuery ('.col-2-left-layout .category_overview').height(colleftHeight + change_height);
		}	
		if (jQuery ('.catalog-category-view .col-2-left-layout .catalog-listing').height () > 0 && (colleftHeight + change_height) > jQuery ('.catalog-category-view .col-2-left-layout .catalog-listing').height ())
		{
			jQuery ('.catalog-category-view .col-2-left-layout .catalog-listing').height(colleftHeight + change_height);
		}
		
		
		if (jQuery ('.cms-page-view .cms_content').height () > 0 && (colleftHeight + change_height) > jQuery ('.cms-page-view .cms_content').height ())
		{
			//alert (colleftHeight);
			jQuery ('.cms-page-view .cms_content').height(colleftHeight + change_height - 70);
		}
		
		if (jQuery ('.cms-index-noroute .cms_content').height () > 0 && (colleftHeight + change_height) > jQuery ('.cms-index-noroute .cms_content').height ())
		{
			//alert (colleftHeight);
			jQuery ('.cms-index-noroute .cms_content').height(colleftHeight + change_height - 70);
		}		
				
		
		if (jQuery ('.col-2-left-layout .product-info-box').height () > 0 && (colleftHeight +300) > jQuery ('.col-2-left-layout .product-info-box').height ())		
		{
			jQuery ('.col-2-left-layout .product-info-box').height(colleftHeight + 300 -1 + change_height);
		}
		
		if (jQuery ('.wishlist-index-index .col-2-left-layout .col-left.side-col').height () > 0 && (colleftHeight + 300 + 1) > jQuery ('.wishlist-index-index .col-2-left-layout .col-left.side-col').height ())	
		{
			jQuery ('.col-2-left-layout .col-left.side-col').height (colleftHeight + 300 + 1  + change_height);
		}
		
		if (jQuery ('.customer-wishlist').height () > 0 && (colleftHeight + 300 + 1) > jQuery ('.customer-wishlist').height ())	
		{	
			change_height = 0;
			if ((colleftHeight + 300) >=  jQuery ('.col-2-left-layout .col-left.side-col').height ())
			{
				jQuery ('.customer-wishlist').height(colleftHeight + 300 -2 + change_height);
			}
			else
			{
				jQuery ('.customer-wishlist').height(jQuery ('.col-2-left-layout .col-left.side-col').height () -3);
			}
		}
		
		
		
		
		if (jQuery ('.customer-contact').height () > 0 && (colleftHeight + 300 + 1) > jQuery ('.customer-contact').height ())	
		{	
			jQuery ('.customer-contact').height(jQuery ('.col-left.side-col').height () + change_height);
		}		
		
		if (jQuery ('.customer-account').height () > 0 && (colleftHeight + 300 + 1) > jQuery ('.customer-account').height ())	
		{	
			change_height = 0;
			jQuery ('.customer-account').height(colleftHeight + 300 -2 + change_height);
		}	
		
		if (jQuery ('.customer-account').height () > 0 )
		{
			
			change_colleft = colleftHeight + 301;
			if (jQuery ('.checkout-onepage-success .customer-account').height () > 0)
				change_colleft = colleftHeight + 2;

			if (jQuery ('.col-2-left-layout .col-left.side-col').height () > 0 && change_colleft > jQuery ('.col-2-left-layout .col-left.side-col').height ())	
			{
				jQuery ('.col-2-left-layout .col-left.side-col').height (change_colleft);
			}
		}

		if (jQuery ('.checkout-onepage-success .customer-account').height () > 0)
		{
				jQuery ('.checkout-onepage-success .customer-account').height (jQuery ('.col-2-left-layout .col-left.side-col').height () + 298);
		}		
	
	jQuery ('.gallery_images .move_up').hover (
	function ()
	{
		jQuery ('.gallery_images .move_up').css ('opacity', 1.0);
	},
	function ()
	{
		jQuery ('.gallery_images .move_up').css ('opacity', 0.5);
	}
	);
	
	jQuery ('.gallery_images .move_down').hover (
	function ()
	{
		jQuery ('.gallery_images .move_down').css ('opacity', 1.0);
	},
	function ()
	{
		jQuery ('.gallery_images .move_down').css ('opacity', 0.5);
	}
	);	
		
	
	jQuery ('.gallery_images .move_up').click (function () {
		if ((gallery + move_images) <= 0)
		{
			gallery = gallery + move_images + 1;
			jQuery ('.gallery_images .more-views .inner_height').css ('top', gallery);
		}
	});
	
	jQuery ('.gallery_images .move_down').click (function () {
	
		var inner_hight = jQuery ('.gallery_images .more-views .inner_height').height ();
		var min_display = move_images * 2;
		
		var min_height = (inner_hight - min_display) * (-1);
		
		//alert (inner_hight +":"+ min_display);
		
		if (gallery - move_images > min_height)
		{
			gallery = gallery - move_images - 1;
			jQuery ('.gallery_images .more-views .inner_height').css ('top', gallery);
		}
	});
	
	
	jQuery ('.account-nav li').hover (function () {
		if (!jQuery(this).hasClass('on'))	
			jQuery(this).css('background-color', '#FFF7FA');

	}, function () {
		if (!jQuery(this).hasClass('on'))
			jQuery(this).css('background-color', '#F3DADF');

	} );
	
	
	
	
	jQuery ('.sitemap-main.shop-nav-spalte1').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	jQuery ('.sitemap-main.shop-nav-spalte2').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);	
	jQuery ('.sitemap-main.shop-nav-spalte3').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	jQuery ('.sitemap-main.shop-nav-spalte4').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);	
	
	
	
	
	
	jQuery ('.background-sitemap-nav .shop-nav-spalte1').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	jQuery ('.background-sitemap-nav .shop-nav-spalte2').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	jQuery ('.background-sitemap-nav .shop-nav-spalte3').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	jQuery ('.background-sitemap-nav .shop-nav-spalte4').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);			

	
	
	
		
	
	
	jQuery ('.header-nav .shop-nav-spalte1').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);	
	
	jQuery ('.header-nav .shop-nav-spalte2').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();		
	}
	);
	
	jQuery ('.header-nav .shop-nav-spalte4').hover (
	function ()
	{
		reset_backgrounds ();
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('background-color', '#E7B5C0');
		display_sitemap ();	
	},
	function ()
	{
		start_tracking ();		
	}
	);
	
	jQuery ('.header-nav .shop-nav-spalte3').hover (
	function ()
	{
		reset_backgrounds ();
		
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('opacity', 1.0);
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('background-color', '#E7B5C0');
		display_sitemap ();
	},
	function ()
	{
		start_tracking ();
	}
	);
	
	jQuery ('.header-nav .shop-nav-spalte0').hover (
	function ()
	{
		reset_backgrounds ();
		hide_sitemap ();
	},
	function ()
	{
		
	}
	);
	
	function start_tracking (change)
	{
		if (change == undefined)
		{
			miny = default_miny;
			maxy = default_maxy;		
		}

		change_active_coord = false;
		jQuery (document).bind ('mousemove', function (e) {
	
			if (e.pageY > maxy || e.pageY < miny)
			{
				miny = default_miny;
				maxy = default_maxy;					
				jQuery (document).unbind ('mousemove', function () {} );
				hide_sitemap ();
				reset_main_navi_cols ();
				
			}
		});
	}
	
	function stop_tracking ()
	{
		jQuery (document).unbind ('mousemove', function (e) {});
	}
		
	
	function display_sitemap ()
	{
		jQuery ('.background-sitemap-nav').show ();
		jQuery ('.sitemap-nav').show ();
	}
	
	function hide_sitemap ()
	{
		jQuery ('.background-sitemap-nav').hide ();
		jQuery ('.sitemap-nav').hide ();
	}
	
	function reset_backgrounds ()
	{
		reset_sitemap_cols ();
		reset_main_navi_cols ();
	}
	
	function reset_sitemap_cols ()
	{
		jQuery ('.background-sitemap-nav div').css ('opacity', 0.95);
		jQuery ('.background-sitemap-nav .shop-nav-spalte1').css ('background-color', '#D78396');
		jQuery ('.background-sitemap-nav .shop-nav-spalte2').css ('background-color', '#D78396');
		jQuery ('.background-sitemap-nav .shop-nav-spalte3').css ('background-color', '#D78396');
		jQuery ('.background-sitemap-nav .shop-nav-spalte4').css ('background-color', '#D78396');
	}
	function reset_main_navi_cols ()
	{
	}
	
	
	function change_col_opacity (column, opacity)
	{
		jQuery ('.background-sitemap-nav .' + column).css ('opacity', opacity);
	}
	
	
	if (jQuery ('.gallery_images .inner_height').height () > jQuery ('.gallery_images').height ())
	{
		jQuery ('.gallery_images .move_up').show ();
		jQuery ('.gallery_images .move_down').show ();		
		jQuery ('.gallery_images .move_up').css ('opacity', 0.5);
		jQuery ('.gallery_images .move_down').css ('opacity', 0.5);		
	}
	
});
