$(document).ready(function(){
	

// JUL
	$('.top'+ RealRoot).show();
	$('.rightpic').remove();
	$('.spacetop_td').css('background-image','none');
// JUL





	if ($('#RootCatagory').val() == 372)	{$('#ShopMainLayOutTable .NewMenu a').eq(0).css('background-image','url(/design/menu/BN-1.png)')}
	if ($('#RootCatagory').val() == 112)	{$('#ShopMainLayOutTable .NewMenu a').eq(1).css('background-image','url(/design/menu/BN-2.png)')}
	if ($('#RootCatagory').val() == 320)	{$('#ShopMainLayOutTable .NewMenu a').eq(2).css('background-image','url(/design/menu/BN-3.png)')}
	if ($('#RootCatagory').val() == 392)	{$('#ShopMainLayOutTable .NewMenu a').eq(3).css('background-image','url(/design/menu/BN-6.png)')}
	if ($('#RootCatagory').val() == 250)	{$('#ShopMainLayOutTable .NewMenu a').eq(4).css('background-image','url(/design/menu/BN-4.png)')}
	if ($('#RootCatagory').val() == 292)	{$('#ShopMainLayOutTable .NewMenu a').eq(5).css('background-image','url(/design/menu/BN-5.png)')}
	if ($('#RootCatagory').val() == 586)	{$('#ShopMainLayOutTable .NewMenu a').eq(6).css('background-image','url(/design/menu/BN-7.png)')}
	if ($('#RootCatagory').val() == 9)		{$('#ShopMainLayOutTable .NewMenu a').eq(7).css('background-image','url(/design/menu/BN-8.png)')}




	if (location.href.indexOf('p.html') != -1){
/*	
		$.get('/flash/player/check.asp?file='+ ProductNumber, function(data) {
			$('body').append('<div style="display:none" id="FlvFileState">'+ data +'</div>');
			if($('#FlvFileState').text()=='200'){
				if (location.href.indexOf('lingeributikken.no') != -1){
					$('#ShopMainLayOutTable .ProductInfo_TD .videotag').append('<br><script type="text/javascript" src="/flash/player/flowplayer-3.2.6.min.js"></script><a style="width: 296px; display: block; height: 188px" id="player" href="http://video.lingeributikken.dk/'+ ProductNumber +'.flv"></a><script>flowplayer("player", "/flash/player/flowplayer-3.2.7.swf");</script>');
				}else{
					$('#ShopMainLayOutTable .ProductInfo_TD .Description1').after('<br><script type="text/javascript" src="/flash/player/flowplayer-3.2.6.min.js"></script><a style="width: 296px; display: block; height: 188px" id="player" href="http://video.lingeributikken.dk/'+ ProductNumber +'.flv"></a><script>flowplayer("player", "/flash/player/flowplayer-3.2.7.swf");</script>');
				}
			}
		});
*/

		if($('#IFRAMEprod').length!=0){
			$('#IFRAMEprod').attr('src','/frame/ask.asp?number='+ ProductNumber);
		}
		
//		$f("huluPlayer", "http://www.lingeributikken.dk/flash/player/flowplayer-3.2.7.swf", {clip: {autoPlay: false,autoBuffering: false,scaling: 'orig' ,image: "http://www.lingeributikken.dk/design/1/background-logo-lingerie.jpg"}}).controls("hulu", {duration: 25});



		$('#tabsSPAN .tablink a:eq(0)').click(function() {
	        _gaq.push(['_trackEvent', 'Tabs', 'Size', ProductNumber]);
			$('#tabsSPAN .tablink a').css('border','1px solid #333333');
			$(this).css('border-bottom','1px solid #000000');
			$('#tabsSPAN .BoxComm').hide();
			$('#tabsSPAN .boxC1').show();
		});

		$('#tabsSPAN .tablink a:eq(1)').click(function() {
			_gaq.push(['_trackEvent', 'Tabs', 'Ask', ProductNumber]);													   
			$('#tabsSPAN .tablink a').css('border','1px solid #333333');
			$(this).css('border-bottom','1px solid #000000');
			$('#tabsSPAN .BoxComm').hide();
			$('#tabsSPAN .boxC2').show();
		});

		$('#tabsSPAN .tablink a:eq(2)').click(function() {
			_gaq.push(['_trackEvent', 'Tabs', 'Video', ProductNumber]);
			$('#tabsSPAN .tablink a').css('border','1px solid #333333');
			$(this).css('border-bottom','1px solid #000000');
			$('#tabsSPAN .BoxComm').hide();
			$('#tabsSPAN .boxC3').show();
		});




	}









	if ($('#ShopMainLayOutTable #VendorNumber').text().length != 0){
		if (location.href.indexOf('lingeributikken.no') != -1){
			$('#ShopMainLayOutTable #ManufactorsNew').html('<a href="/shop/cms-36.html?hideinterface=1#'+ $('#ShopMainLayOutTable #VendorNumber').text() +'" class="facebox1">Størrelsesskema for denne vare</a>');
		}else{
			$('#ShopMainLayOutTable #ManufactorsNew').html('<a href="/shop/cms-stroerrelsesskema.html?hideinterface=1#'+ $('#ShopMainLayOutTable #VendorNumber').text() +'" class="facebox1">Størrelsesskema for denne vare</a>');
		}
	}
	
	
	
	if ($('.Related_Custom_TBL').length != 0 && $('#colors').length == 0){
		$('.Related_Custom_TBL').before('<h6>Relaterede varer</h5>');
	}

	if ($('.Manufactors a').length != 0){
		$('.Manufactors a').removeAttr('target');

		$('.Manufactors a').each(function(){
			$(this).attr('class','facebox');
			$(this).attr('href',$(this).attr('href') +'?hideinterface=1');
		});
	}








if (location.href.indexOf('cms-stroerrelsesskema.html') != -1){
	$('body').css('overflow-y','hidden');
}
	
//if (location.href.indexOf('?cn') != -1){
	$('#ShopMainLayOutTable #ProductMenu_Table a').each(function(){
		if ($(this).text().length==0){
			$(this).hide();
		}
	});
//}
	
	$('.DressTBLRelated a').removeAttr('href')

/*
	if (location.href.indexOf('?cn') != -1){
	
	old_alert($('.facebox').length);
	
	};
*/
	
	if ($('.facebox').length != 0){
		$(".facebox").fancybox({
			'width'			: '50%',
			'height'		: '50%',
			'autoScale'		: false,
			'overlayShow'	: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'overlayOpacity': '0.8',
			'overlayShow'	: true,
			'overlayColor'	: '#333',
			'type'			: 'iframe'
		});	
	}

	RealfancyboxWidth = 800;
	Realfancyboxheight = 500;
	
	if(fancyboxWidth.length != 0){RealfancyboxWidth = fancyboxWidth;}
	if(fancyboxHeight.length != 0){Realfancyboxheight = fancyboxHeight;}

	if ($('.facebox1').length != 0){
		$(".facebox1").fancybox({
			'width'			: RealfancyboxWidth,
			'height'		: Realfancyboxheight,
			'autoScale'		: false,
			'overlayShow'	: false,
			'transitionIn'	: 'elastic',
			'transitionOut'	: 'elastic',
			'overlayOpacity': '0.8',
			'overlayShow'	: true,
			'overlayColor'	: '#333',
			'type'			: 'iframe',
			'scrolling'		: 'no'
		});	
	}



	$('.BackGroundColor1_OrderStep3 table table table table a').removeAttr('href')
	$('.CustomerInfo_OrderStep3 br').hide();
	$('.CustomerInfo_OrderStep3 table br').show();






/////////////////////////////////////////////////////////////////

	if ($('#LB_Size').length!=0){

		$("#LB_Size td.LB-RemoveBG").hover(
			function () {
				$(this).parent().find('td.LB-RemoveBG').css('background','#212121');
				var numTD = $(this).parent().children().index($(this))-1;
				
				$('#LB_Size tr:eq(0) td:eq('+ $(this).parent().children().index($(this)) +')').css('background','#908f8f').css('color','#000000');
				$(this).parent().find('td.LB_CupSize').css('background','#908f8f').css('color','#000000');
				
				$('#LB_Size tr').each(function(){
					$(this).find('td.LB-RemoveBG:eq('+ numTD +')').css('background','#212121');
				});
				if ($(this).attr('class')=='LB-RemoveBG'){
					$(this).css('background','#d49714');
				}
			}, 
			function () {
				$('.LB-RemoveBG, .LB_CupSize').css('background','none');
				$('.LB_CupSize').css('color','#FFFFFF');
			}
		);

	}
	
	$('#ProductMenu_Table strong').parent().removeAttr('href');
	$('#ProductMenu_Table strong').parent().parent().removeAttr('href');
	
	if (location.href.indexOf('lingeriebutikken.dk') != -1 && location.href.indexOf('hideinterface') == -1){
		$('#ShopLayOut_SpaceTop_TD').css('background-image',$('#ShopLayOut_SpaceTop_TD').css('background-image').replace("background-logo.jpg","background-logo-lingerie.jpg"))
	}

	if (location.href.indexOf('lingeriebutikken.dk') != -1){$('.rightpic').css('background-image','url(../design/background-top-right-lingerie.jpg)');}






	if ($('#ShopMainLayOutTable ##SIMPLELIST_RED .SubCats_Prodlink').length >= 1){

		$('##SIMPLELIST_RED .SubCats_Prodlink').each(function(){
			
			ThisSavedValue = '';
			
			var ThisValue = $(this).text().split(" - ");
			
			for(i = 0; i < ThisValue.length; i++){
				if (i==0){
					ThisSavedValue = ThisSavedValue +'<div class="no1">'+ ThisValue[i] +'</div>';
				}else{
					ThisSavedValue = ThisSavedValue +'<div class="no2">'+ ThisValue[i] +'</div>';
				}
			}
			
			$(this).html(ThisSavedValue);
			
		});

	}




	// PNGFIX LAVEDE MØG I VORES CHECKMARKS, DERFOR DENNE
	$('#ContentContainer_TBL .box2 li').each(function(){
	
		$(document.createElement('img'))
			.css('position', 'absolute')
			.css('left', parseInt($(this).offset().left + 7) + 'px')
			.css('top', parseInt($(this).offset().top + 3) + 'px')
			.css('width', '18px')
			.css('height', '21px')
			.attr('src', '../design/ckeck.png')
			.prependTo('body');
	
	})
	

	// KØR PNGFIX
	$(function(){$(document).pngFix();});

/*
if (location.href.indexOf('lingeriebutikken.dk') == -1){
	// REBIND ALERT BOXES
	window.alert = function(txt){

		// SPECIFIKT FOR LAGT I KURVEN ALERT
		if (txt.indexOf('Varen er nu tilføjet til kurven') != -1){
//		if (txt == 'Varen er nu tilføjet til kurven.') {
			window.scrollTo(1, 1);
			$('#basketid img').attr({src : '/design/gaa-til-kurven-animation.gif'});
		}
	
		// VIS ALERTS I FACEBOX
		$.facebox(txt);
	
	}
}
*/

	// NO RIGHTCLICK
	$('#Canvas').noContext();
	$('#Selector').noContext();
	$('.ProductImage img').noContext();
	//$.facebox('Copyright 2009 - Lingeributikken.dk');


	// FJERN <br>'S I MENU
	$('.RootCategory_Productmenu br').css('display', 'none');
//	$('#Table50 tr:first-child').css('display', 'none');

	if ($('#ShopMainLayOutTable .TotalProductsNew').text() != 0){$('.BasketTBL').css('background-image','url(/design/background-basket-gold.png)');$('.BasketHideSection').show();}
	
	if ($('#ShopMainLayOutTable .Fee0').text().length == 0){$('.Fee0').text('0,00')};

	if (location.href.indexOf('.no') != -1){
		if ($('#ShopMainLayOutTable .Fee1').text().length == 0){$('.Fee1').text('45,00 NOK')};
	}else{
		if ($('#ShopMainLayOutTable .Fee1').text().length == 0){$('.Fee1').text('45,00 DKK')};
	}

	var Fee1 = $('.Fee1').text().replace('DKK','').replace('NOK','').replace('.','').replace(',','.');
	var Fee2 = $('.Fee2').text().replace('.','').replace(',','.')
/*	
	if (location.href.indexOf('.no') != -1){
		if (Fee2-Fee1>=1000){$('.Fee1').text('65,00 NOK')};
	}else{
		if (Fee2-Fee1>=1000){$('.Fee1').text('65,00 DKK')};
	}
		
	var Fee1 = $('.Fee1').text().replace('DKK','').replace('NOK','').replace('.','').replace(',','.');
*/
	$('.Fee0').text((Fee2-Fee1).toFixed(2).replace('.',','));
	
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	if (location.href.indexOf('/shop/order1.html') != -1){

		if ($('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL #profileid').length==0){
			ShowLoad = false
		}else{
			ShowLoad = true
		}
		
		contentTBL = '<br><br><br><table class="LoadProfile_Orderstep1_TBL" cellspacing="0" cellpadding="0" width="168" style="margin-left:8px;">'+ $('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL').html() +'</table>'
		
		$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL').hide();

		$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL').prev('table').hide();
		$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL').next('table').hide();

		if (contentTBL.indexOf('logout=1') == -1){
		
		$('#ShopMainLayOutTable #ShopLayOut_ProductMenu_TD').append(contentTBL)
		$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL table').remove();
		
			if (ShowLoad){
				if (location.href.indexOf('lingeributikken.no') != -1) {
					$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL td:eq(0)').append('<form method="POST" name="loadprofile" id="FormLoad" action="/shop/order1.html"><input type="hidden" value="1" name="loadprofile"><input type="text" class="FiledTLF" name="profileid" onblur="if (this.value==\'\') this.value=\'Tast inn din e-post adresse\'" onFocus="if (this.value==\'Tast inn din e-post adresse\') this.value=\'\'" value="Tast inn din e-post adresse"><br><input type="submit" class="SubmitButtonLOADP" value="Hent"></form>');
				}else{
					$('#ShopMainLayOutTable .LoadProfile_Orderstep1_TBL td:eq(0)').append('<form method="POST" name="loadprofile" id="FormLoad" action="/shop/order1.html"><input type="hidden" value="1" name="loadprofile"><input type="text" class="FiledTLF" name="profileid" onblur="if (this.value==\'\') this.value=\'Indtast din e-mail\'" onFocus="if (this.value==\'Indtast din e-mail\') this.value=\'\'" value="Indtast din e-mail"><br><input type="submit" class="SubmitButtonLOADP" value="Hent"></form>');
				}
			}
			
		}
		
		
	if (location.href.indexOf('order1.html') != -1 || location.href.indexOf('order2.html') != -1 || location.href.indexOf('order3.html') != -1 || location.href.indexOf('order4.html') != -1){
		$('#ShopLayOut_Search_TD').parent().hide();
	}
		
	}


///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////


	// INDKØBSKURV
	var basket		= document.createElement('div');
		basket.id	= 'basketid';
	
	$(basket).html($('.NumberProduct_Basket span')
		.html())
		.css('margin-left', '620px')
		.css('margin-top', '-16px')
		.css('cursor', 'pointer')
		.css('height', '40px')
		.css('width', '300px')
		.appendTo('.cards');

	$('#basketid').click(function(){
		location.href = '/shop/showbasket.html';
	});
	
	
	// DESVÆRRE TJEK PÅ USERAGENT :(
	if ($.browser.name == 'chrome')
	{
		$('#ContentContainer_TBL .box2 li img').each(function(){
			$(this).css('top', parseInt($(this).offset().top + 16) + 'px')
		});
	}
/*
	if ($.browser.name == 'safari' || $.browser.name == 'chrome')
	{
		$('#ShopLayOut_ProductMenu_TD').css('padding-top', '10px');
	}

	if ($.browser.name == 'msie' || $.browser.name == 'firefox')
	{
		$('#ShopLayOut_ProductMenu_TD').css('padding-top', '26px');
	}
*/

	// TOPMENU
	$('#topmenu a').mouseout(function(){
		classname = $(this).attr('class');
	
		switch(classname.toLowerCase()) {
			case 'lingeri':
				if (getCookie('RootCat') != 372) $(this).css('background-image', 'none')
				break;

			case 'xxlingeri':
				if (getCookie('RootCat') != 112) $(this).css('background-image', 'none')
				break;

			case 'kostumer':
				if (getCookie('RootCat') != 320) $(this).css('background-image', 'none')
				break;	

			case 'herre':
				if (getCookie('RootCat') != 250) $(this).css('background-image', 'none')
				break;

			case 'kjoler':
				if (getCookie('RootCat') != 292) $(this).css('background-image', 'none')
				break;	

			case 'sexlegetoej':
				if (getCookie('RootCat') != 392) $(this).css('background-image', 'none')
				break;	

			case 'smykker':
				if (getCookie('RootCat') != 506) $(this).css('background-image', 'none')
				break;	

			case 'tasker':
				if (getCookie('RootCat') != 585) $(this).css('background-image', 'none')
				break;	

			default:
		}
	})

	$('#topmenu a').mouseover(function(){
		classname = $(this).attr('class');
	
		switch(classname.toLowerCase()) {
			case 'lingeri':
				$(this).css('background-image', 'url(../design/1/background_menu.gif)')
				break;

			case 'xxlingeri':
				$(this).css('background-image', 'url(../design/2/background_menu.gif)')
				break;

			case 'kostumer':
				$(this).css('background-image', 'url(../design/3/background_menu.gif)')
				break;	

			case 'herre':
				$(this).css('background-image', 'url(../design/4/background_menu.gif)')
				break;

			case 'kjoler':
				$(this).css('background-image', 'url(../design/6/background_menu.gif)')
				break;	

			case 'sexlegetoej':
				$(this).css('background-image', 'url(../design/5/background_menu.gif)')
				break;	

			case 'smykker':
				$(this).css('background-image', 'url(../design/7/background_menu.gif)')
				break;	

			case 'tasker':
				$(this).css('background-image', 'url(../design/7/background_menu.gif)')
				break;	

			default:
		}
	})


});
