var weekendDelivery, today;

function cal5_printSelection() {
    var sel = Calendar.selection.print("%Y-%m-%d", " ... ");
    if (sel.length == 0)
        sel = "No date selected";
    else
        sel = sel.join("\n");
    alert(sel);
};

$(function(){
	if($("#Field8_0 .TextInputField_Orderstep1").length > 0){
		$("#Field8_0 .TextInputField_Orderstep1").attr("id", "calenderInput");
		$("#calenderInput").css({"position" : "relative", "z-index" : "99999"});
		//$("#Field8_0 .TextInputField_Orderstep1").attr('disabled', true);
		$("#Field8_0 .TextInputField_Orderstep1").before('<div style="position:absolute;"><input type="hidden" id="calenderInputHidden"><input id="calendar-trigger" type="image" src="http://www.lavpriskoekken.dk/images/design/da/ordersteps/calenderIcon.jpg" style="position: relative; left: 198px;"></div>');
		if($.browser.msie){
			$("#calendar-trigger").css("left", "150px");
		}
		//$("#Field8_0 .TextInputField_Orderstep1").before('<div style="position:absolute;"><div id="calendar-trigger"></div></div>');
		$("#calendar-trigger").click(function(event){
			event.preventDefault();
		});
		if(readCookie("weekendDelivery") == "true"){
			weekendDelivery = true;
		} else {
			weekendDelivery = false;
		}
		today = new Date();
		Calendar.setup({
			align 	   : "bR",
   	    	//cont    : "calendar-trigger",
			trigger    : "calendar-trigger",
  	    	inputField : "calenderInputHidden",
			onSelect   : function() { 
				this.hide(); 
				tmp = $("#calenderInputHidden").val().split("-");
				$("#calenderInput").val(tmp[2]+"-"+tmp[1]+"-"+tmp[0])
			},
			onBlur 	   : function(){return false},
		    disabled: function(date) {
				
				if(weekendDelivery){
					if(date < today){
						return true;
			    	} else {
			    		if(today.getDay() == 5 && today.getHours() >= 12 && date.getDay() == 6 && date.getDate()-1 == today.getDate() || today.getDay() == 5 && today.getHours() >= 12 && date.getDay() == 0 && date.getDate()-2 == today.getDate() ){
							return true;
						} else {
				    		return false;
						}
					}
				} else {
					if (date < today || date.getDay() == 0 || date.getDay() == 6) {
						return true;
			    	} else {
			    		return false;
					}
				}				
			}
    	});
		Calendar.setup({
			align 	   : "bR",
   	    	//cont    : "calendar-trigger",
			trigger    : "calenderInput",
  	    	inputField : "calenderInputHidden",
			onSelect   : function() { 
				this.hide(); 
				tmp = $("#calenderInputHidden").val().split("-");
				$("#calenderInput").val(tmp[2]+"-"+tmp[1]+"-"+tmp[0])
			},
			onBlur 	   : function(){return false},
			disabled: function(date) {
				
				if(weekendDelivery){
					if (date < today) {
						return true;
			    	} else {
						if(today.getDay() == 5 && today.getHours() >= 12 && date.getDay() == 6 && date.getDate()-1 == today.getDate() || today.getDay() == 5 && today.getHours() >= 12 && date.getDay() == 0 && date.getDate()-2 == today.getDate() ){
							return true;
						} else {
				    		return false;
						}
					}
				} else {
					if (date < today || date.getDay() == 0 || date.getDay() == 6) {
						return true;
			    	} else {
			    		return false;
					}
				}				
			}
    	});
	}
	
	$(".Description_Productinfo iframe").each(function(){
		if($(this).attr("src").indexOf("youtube") != -1){
			$(this).wrap("<div class='youtubeVideo' style='position:Relative;'></div>");
			$(this).attr("width", "244px");
			$(this).attr("height", "154px");
		}
	});
	$(".youtubeVideo").append('<div style="width:244px;height:154px;position:absolute;z-index:999999;top:0;left:0px;background:url(\'http://www.lavpriskoekken.dk/includes/transparentBtn.png\');cursor:pointer" class="playVideo"></div>');
	
	$(".playVideo").each(function(){
		$(this).click(function(){
			var videoURL = $(this).parent().find("iframe").attr("src");
			playVideo(videoURL);
		});
	});
	if(location.hash = "#loginOK"){
		$("#calenderInput").val("");
	}
	
	//Product configurator
	if($("#ShopMainLayOutTable .OptionSelect_ProductInfo").length > 0){
		AjaxEncoding.init("/includes/");
		$("#ShopMainLayOutTable #prodConfig .OptionSelect_ProductInfo").each(function(){
			price = $(this).find("option:last").text().split("(")[1].split(")")[0];
			price = parseFloat($("#BaseProdPrice").val().replace(",", "."));
			if(price == 0){
				$("#Price_DIV").html('<table cellspacing="0" cellpadding="2" border="0" width="100%"><tbody><tr class="Price_ProductInfo_TR"><td width="0" class="PriceText_ProductInfo_TD"><span class="PriceText_ProductInfo_SPAN"><nobr>Din Pris</nobr> </span></td><td align="right" width="0" class="PriceAmount_ProductInfo_TD"><span class="PriceAmount_ProductInfo_SPAN"><nobr>1</nobr></span></td><td align="right" width="0" class="PriceUnit_ProductInfo_TD"><span class="PriceUnit_ProductInfo_SPAN"><nobr></nobr></span></td><td width="0" class="PriceBefore_ProductInfo_TD"> </td><td width="100%" class="Price_ProductInfo"><b><span class="Price_Productinfo">Ring for pris</span></b></td></tr><tr class="PriceDevider_ProductInfo_TR"><td colspan="5"><hr size="1" noshade="" class="TableLines_ProductInfo"></td></tr></tbody></table>');
				$(".UnitPriceBox:last").find("td:first").html('Din pris');
				$(".UnitPriceBox:last").find("td:last").html('<span class="Price_Productinfo">'+number_format(price, 2, ",", ".")+' DKK</span>')
				retailPrice = parseFloat($(".RetailPrice_Productinfo:last").text().replace(".", ""));
				saving = retailPrice-price;
				//alert(retailPrice+"-"+price)
			} else {
				$("#Price_DIV").html('<table cellspacing="0" cellpadding="2" border="0" width="100%"><tbody><tr class="Price_ProductInfo_TR"><td width="0" class="PriceText_ProductInfo_TD"><span class="PriceText_ProductInfo_SPAN"><nobr>Din Pris</nobr> </span></td><td align="right" width="0" class="PriceAmount_ProductInfo_TD"><span class="PriceAmount_ProductInfo_SPAN"><nobr>1</nobr></span></td><td align="right" width="0" class="PriceUnit_ProductInfo_TD"><span class="PriceUnit_ProductInfo_SPAN"><nobr></nobr></span></td><td width="0" class="PriceBefore_ProductInfo_TD"> </td><td width="100%" class="Price_ProductInfo"><b><span class="Price_Productinfo">'+number_format(price, 2, ",", ".")+' DKK</span></b></td></tr><tr class="PriceDevider_ProductInfo_TR"><td colspan="5"><hr size="1" noshade="" class="TableLines_ProductInfo"></td></tr></tbody></table>');
				$(".UnitPriceBox:last").find("td:first").html('Din pris');
				$(".UnitPriceBox:last").find("td:last").html('<span class="Price_Productinfo">'+number_format(price, 2, ",", ".")+' DKK</span>');
				retailPrice = parseFloat($(".RetailPrice_Productinfo:last").text().replace(".", ""));
				saving = retailPrice-price;
				//alert(retailPrice+"-"+price)
				$(".SavingsPriceBox").each(function(){
					$(this).find(".SavingsPrice_Productinfo:first").html('Spar');
					$(this).find(".SavingsPrice_Productinfo:last").html('<span class="Price_Productinfo">'+number_format(saving, 2, ",", ".")+'&nbsp;DKK</span>');
				});
			}
		});
		if($("#ShopMainLayOutTable #prodConfig .OptionSelect_ProductInfo").length > 0){
			var index = 0;
			
			$("body").append('<div id="loader" onclick="$(this).toggle();" style="left:0px;top:0px;border:2px solid #666666;width:250px;background:#FFFFFF;padding:10px;position:absolute;color:#000000;font-size:12px;">testetest</div>');
			var html = '<table cellspacing="0" cellpadding="0" border="0" width="100%" id="AddOn_TABLE"></tr><tr><td style="text-align:center;padding:0px 0px 10px 0px;"></td></tr><tr><td id="prodconfiguration"></td></tr></tbody></table>';
			$("#ShopMainLayOutTable .mBuyB").html('<input type="image" src="/images/design/source/koeb_btn_varekort.gif" id="newBuyBtn"/>');
//					var BASket = $("#ShopMainLayOutTable #ShopLayOut_Basket_TD").html();
//					$("#ShopMainLayOutTable #ShopLayOut_SpaceTop_TD").append('<div style="float:left;_float:none;width:135px;height:97px;_display: inline;">'+BASket+'</div>');
				$("#ShopMainLayOutTable #ShopLayOut_SpaceTop_TD>table:eq(0)").attr("style","float:left;_float:none;_display:inline");
				$("#ShopMainLayOutTable #basket").parent().removeAttr("style");
				//$("#ShopMainLayOutTable #prodconfiguration>table>tbody>tr>td").css('background','/includes/prodCard/prodConfBack.png');
		}
		$("#costumProdConfig").append(html);
		$("#ShopMainLayOutTable .OptionSelect_ProductInfo").each(function(){
			$(this).parent().next().next().find("img").attr("src", "/includes/newInfo.png");
			$(this).parent().next().next().find("img").css("vertical-align", "middle");
			if($.browser.msie){
				infobtn = '<span class="infoBtnAddOnSpan" style="float:right;cursor:pointer;position:relative;top:4px;"  id="infoBtn_'+index+'" class="infoBtn" onclick="getProductInfo('+index+')"></span>';
			} else {
				infobtn = '<span class="infoBtnAddOnSpan" style="float:right;cursor:pointer;"  id="infoBtn_'+index+'" class="infoBtn" onclick="getProductInfo('+index+')"></span>';
			}
			prodName = $(this).parent().parent().prev().find("td:first").text();
			price = $(this).find("option:last").text().split("(")[1].split(")")[0];
			if($.browser.msie){
				$("#prodconfiguration").append('<table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:10px;width:100%;height:46px;"><tr><td class="addOnBG1 pCback" style="width:20px;padding:5px 0px 0px 10px;"><input type="checkbox" style="" value="'+$(this).find("option:last").attr("value")+'" class="prodconfigOption" index="'+index+'" id="prodconfigOption_'+index+'"></td><td class="addOnBG2 pCback" style="width:220px;padding:8px 0px 0px 0px;"><div class="fontType2 fontColor11 upperCase">'+prodName+'</div><div class="fontType3 fontColor12 upperCase fontBold">'+price+' DKK </div></td><td class="infoBtnAddOn pCback">'+infobtn+'</td></tr></table>');
			} else {
				$("#prodconfiguration").append('<table cellspacing="0" cellpadding="0" border="0" style="margin-bottom:10px;width:100%;height:46px;"><tr><td class="addOnBG1 pCback" style="width:20px;padding:9px 0px 0px 10px;"><input type="checkbox" style="" value="'+$(this).find("option:last").attr("value")+'" class="prodconfigOption" index="'+index+'" id="prodconfigOption_'+index+'"></td><td class="addOnBG2 pCback" style="width:220px;padding:8px 0px 0px 0px;"><div class="fontType2 fontColor11 upperCase">'+prodName+'</div><div class="fontType3 fontColor12 upperCase fontBold">'+price+' DKK </div></td><td class="infoBtnAddOn pCback">'+infobtn+'</td></tr></table>');
			}
			//$("#prodconfiguration").append('<div style="overflow:hidden;height:50px;"><div style="float:left;height:25px;margin-right:2px;"></div><div style="float:left;height:50px;"></div><div style="float:right;height:50px;font-size:11px;"></div></div>')
			index++;
		});
		$(".prodconfigOption").click(function(){

			var checkMe = $(this).parent().next().find("div:eq(0)").text();
			if(checkMe == "Afhentning"){
				$("#prodconfiguration > table").each(function(){
					if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Weekend Levering"){
						if($(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").is(":checked")){
							var change = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("id");
							id = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("index");
							$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
							if($selectBox.find("option:selected").val() == "0"){
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:last").attr("selected", "true");
							} else {
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:first").attr("selected", "true");
								$("#"+change).attr("checked",false);
							}
							count = parseFloat(id)+1;
							pcComboSelected(count);
						}
					}
					if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Ø-levering"){
						if($(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").is(":checked")){
							var change = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("id");
							id = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("index");
							$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
							if($selectBox.find("option:selected").val() == "0"){
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:last").attr("selected", "true");
							} else {
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:first").attr("selected", "true");
								$("#"+change).attr("checked",false);
							}
							count = parseFloat(id)+1;
							pcComboSelected(count);
						}
					}
				});
			}
			if(checkMe == "Weekend Levering"){
				$("#prodconfiguration > table").each(function(){
					if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Afhentning"){
						if($(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").is(":checked")){
							//$(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").click();
							var change = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("id");
							id = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("index");
							$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
							if($selectBox.find("option:selected").val() == "0"){
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:last").attr("selected", "true");
							} else {
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:first").attr("selected", "true");
								$("#"+change).attr("checked",false);
							}
							count = parseFloat(id)+1;
							pcComboSelected(count);
						}
					}
				});
			}
			if(checkMe == "Ø-levering"){
				$("#prodconfiguration > table").each(function(){
					if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Afhentning"){
						if($(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").is(":checked")){
							//$(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").click();
							var change = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("id");
							id = $(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").attr("index");
							$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
							if($selectBox.find("option:selected").val() == "0"){
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:last").attr("selected", "true");
							} else {
								$selectBox.find("option").removeAttr("selected");
								$selectBox.find("option:first").attr("selected", "true");
								$("#"+change).attr("checked",false);
							}
							count = parseFloat(id)+1;
							pcComboSelected(count);
						}
					}
				});
			}
			var g1 = new Array("Afhentning","Opbæring","Opbæring og montering","Opbæring og bortskaffelse af gammel produkt","Opbæring montering og bortskaffelse af gammel produkt", "Ø-levering");
			var g2 = new Array("4 års fuld forsikring");
			var g1 = new Array("Kantstens Levering","Afhentning","Opbæring","Opbæring og montering", "Opbæring montering og bortskaffelse af gammelt produkt", "Ø-levering");
			//var g3 = new Array("Afhentning ","Afhentning 2 stk. ","Bortskaffelse ","Bortskaffelse 2 stk. ");
			
			//if ( checkMe == " Afhentning " || checkMe == " Afhentning 2 stk. "){
			//	var g1 = new Array("Afhentning ","Afhentning 2 stk. ","Gratis fragt ","Gratis fragt 2 stk. ","Ø-levering ","Ø-levering 2 stk. ","Opbæring ","Opbæring 2 stk. ","Opbæring & Montering ","Opbæring & montering 2 stk. ","Bortskaffelse ","Bortskaffelse 2 stk. ");
			//}
			id = $(this).attr("index");
			$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
			if($selectBox.find("option:selected").val() == "0"){
				$selectBox.find("option").removeAttr("selected");
				$selectBox.find("option:last").attr("selected", "true");
			} else {
				$selectBox.find("option").removeAttr("selected");
				$selectBox.find("option:first").attr("selected", "true");
			}
			count = parseFloat(id)+1
			pcComboSelected(count);
			for (var i = 1;i < 3;i++){
				var gToCheck = eval("g"+i);
				if (jQuery.inArray(checkMe,gToCheck) !== -1 ){
					var vPos = jQuery.inArray(checkMe,gToCheck);
					gToCheck[vPos] = " ";
					break;
				}
			}

			$(".prodconfigOption:checked").each(function(){
				if (jQuery.inArray($(this).parent().next().find("div:eq(0)").text(),gToCheck) >= 0){
					vPos = jQuery.inArray(checkMe,gToCheck);
					var change = $(this).attr("id");
					if ($(this).attr("id") == false){
						change = $(this).attr("Xid");
					}
					id = $(this).attr("index");
					$selectBox = $("#ShopMainLayOutTable .OptionSelect_ProductInfo:eq("+id+")");
					if($selectBox.find("option:selected").val() == "0"){
						$selectBox.find("option").removeAttr("selected");
						$selectBox.find("option:last").attr("selected", "true");
					} else {
						$selectBox.find("option").removeAttr("selected");
						$selectBox.find("option:first").attr("selected", "true");
						$("#"+change).attr("checked",false);
						var rPos = jQuery.inArray($(this).parent().next().find("div:eq(0)").text(),gToCheck);
						gToCheck[rPos] = " ";
					}
					count = parseFloat(id)+1;
					pcComboSelected(count);
					//return(false);
				}
			});

		});
			
		$("#loader").css({
			"display" : "none"
		});
	
		$("#newBuyBtn").click(function(event){
			event.preventDefault();
			$("#prodconfiguration > table").each(function(){
				if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Weekend Levering"){
					if(readCookie("weekendDelivery") != "true"){
						if($(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").is(":checked")){
							createCookie("weekendDelivery", "true", "0.2");
						} else {
							createCookie("weekendDelivery", "false", "0.2");
						}
					}
				}
			});
			
			$("#prodConfig #Total").prev().prev().click();
		});
		$("#prodconfiguration > table").each(function(){
			if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Kantstens Levering"){
				$(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").click();
			}
			if($(this).find("tbody:first > tr > td:eq(1) > div:eq(0)").text() == "Weekend Levering"){
				if(readCookie("weekendDelivery") == "true"){
					$(this).find("tbody:first > tr > td:eq(0) > .prodconfigOption").click();
				}
			}
		});
	}
	$("#ShopMainLayOutTable .ShowBasket_ChildProduct_SPAN").each(function(){

		var $this = $(this);
		var prodName = $this.text();
		var prodPrice = $this.parents(".prNameAddBasketWrap").next().text();
		var prodTotalPrice = $this.parents(".prNameAddBasketWrap").next().next().text();
		var prodAmount = $this.parents(".prNameAddBasketWrap").prev().prev().prev().prev().text();
		//$this.parent().text("<b>+"+prodName+"</b>");
		if($this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".ShowBasket_ChildProduct_SPAN").length < 1){
			var parentProd = $this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".prNameAddBasketWrap").html();
			var parentPrice = $this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(1)").html();
			var parentTotalPrice = $this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(2)").html();
			var parentAmount = $this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(0)").html();
			
			$this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".prNameAddBasketWrap").html(parentProd+"<br><br><b>+ "+prodName+"</b>");
			$this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(1)").html(parentPrice+prodPrice+"<br><br>");
			$this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(2)").html(parentTotalPrice+"<b>"+prodTotalPrice+"</b><br><br>");
			$this.parents(".BackgroundColor1_ShowBasket").parent().prev().find(".basketIndent:eq(0)").html(parentAmount+prodAmount+"<br><br>");
		}
		if($this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".ShowBasket_ChildProduct_SPAN").length < 1){
			var parentProd = $this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".prNameAddBasketWrap").html();
			var parentPrice = $this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(1)").html();
			var parentTotalPrice = $this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(2)").html();
			var parentAmount = $this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(0)").html();
			
			$this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".prNameAddBasketWrap").html(parentProd+"<br><br><b>+ "+prodName+"</b>");
			$this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(1)").html(parentPrice+prodPrice+"<br><br>");
			$this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(2)").html(parentTotalPrice+"<b>"+prodTotalPrice+"</b><br><br>");
			$this.parents(".BackgroundColor2_ShowBasket").parent().prev().find(".basketIndent:eq(0)").html(parentAmount+prodAmount+"<br><br>");
		}
		
		
		$this.parents(".BackgroundColor2_ShowBasket").parent().remove();
		$this.parents(".BackgroundColor1_ShowBasket").parent().remove();
		
	});
	
});

function playVideo(videoURL){
	$overlay = $('<div id="videoOverlay"></div>');
	$overlay.css("height", $(document).height());
	$overlay.hide();
	$videoContainer = $('<div id="videContainer"></div>');
	$videoContainer.css("left", ($(document).width()-660)/2);
	$videoContainer.css("top", 100);
	$("body").append($overlay);
	$("body").append($videoContainer);
	menuYloc = parseInt($videoContainer.css("top").substring(0,$videoContainer.css("top").indexOf("px"))) ;
	var offset = menuYloc+$(document).scrollTop()+100+"px";  
	$videoContainer.animate({top:offset},{duration:500,queue:false});  
	$(window).scroll(function () {  
		var offset = menuYloc+$(document).scrollTop()+100+"px";  
		$videoContainer.animate({top:offset},{duration:500,queue:false});  
	}); 
	
	if($.browser.msie){
		$overlay.fadeTo(10, 0.50);
		$overlay.show();
		$.ajax({
			url: "/includes/video.asp?url="+videoURL,
			success: function(response){
				$videoContainer.append(response);
				$("#closeBtn").click(function(){
					if($.browser.msie){
						$("#videContainer, #videoOverlay").remove();
					} else {
						$("#videContainer, #videoOverlay").fadeOut("slow", function(){
							$("#videContainer, #videoOverlay").remove();
						});
					}
				});
			}
		});
	} else {
		$overlay.fadeTo("slow", 0.50, function(){
			$.ajax({
				url: "/includes/video.asp?url="+videoURL,
				success: function(response){
					$videoContainer.append(response);
					$("#closeBtn").click(function(){
						if($.browser.msie){
							$("#videContainer, #videoOverlay").remove();
						} else {
							$("#videContainer, #videoOverlay").fadeOut("slow", function(){
								$("#videContainer, #videoOverlay").remove();
							});
						}
					});
				}
			});
			
		});
	}
	$overlay.click(function(){
		if($.browser.msie){
			$("#videContainer, #videoOverlay").remove();
		} else {
			$("#videContainer, #videoOverlay").fadeOut("slow", function(){
				$("#videContainer, #videoOverlay").remove();
			});
		}
	});
	
	$(window).resize(function(){
		left = ($(window).width()-660)/2;
		topPos = ($(window).height()-225)/2;
		$("#videContainer").css({"left" : left});
		$("#videoOverlay").css({"height" : $(document).height(), "width" : $(window).width()})
		//menuYloc = parseInt($("#videContainer").css("top").substring(0,$("#videContainer").css("top").indexOf("px"))) ;
		//var offset = menuYloc+$(document).scrollTop()+100+"px";  
	    //$("#videContainer").animate({top:offset},{duration:500,queue:false});  
	});
}
function createCookie(name,value,days) {
	if (days) {
		var date = new Date();
		date.setTime(date.getTime()+(days*24*60*60*1000));
		var expires = "; expires="+date.toGMTString();
	}
	else {
		var expires = "";
	}
	document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
	var nameEQ = name + "=";
	var ca = document.cookie.split(';');
	for(var i=0;i < ca.length;i++) {
		var c = ca[i];
		while (c.charAt(0)==' ') c = c.substring(1,c.length);
		if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
	}
	return null;
}

function eraseCookie(name) {
	createCookie(name,"",-1);
}


function number_format (number, decimals, dec_point, thousands_sep) { 
	var n = number, prec = decimals; 
	var toFixedFix = function (n,prec) { 
    	var k = Math.pow(10,prec); 
    	return (Math.round(n*k)/k).toString(); 
	}; 
 
	n = !isFinite(+n) ? 0 : +n; 
	prec = !isFinite(+prec) ? 0 : Math.abs(prec); 
	var sep = (typeof thousands_sep === 'undefined') ? ',' : thousands_sep; 
	var dec = (typeof dec_point === 'undefined') ? '.' : dec_point; 
 
	var s = (prec > 0) ? toFixedFix(n, prec) : toFixedFix(Math.round(n), prec); //fix for IE parseFloat(0.55).toFixed(0) = 0; 
 
	var abs = toFixedFix(Math.abs(n), prec); 
	var _, i; 
 
	if (abs >= 1000) { 
   		_ = abs.split(/\D/); 
    	i = _[0].length % 3 || 3; 
 
    	_[0] = s.slice(0,i + (n < 0)) + 
        _[0].slice(i).replace(/(\d{3})/g, sep+'$1'); 
    	s = _.join(dec); 
	} else { 
    	s = s.replace('.', dec); 
	} 
 
	var decPos = s.indexOf(dec); 
	if (prec >= 1 && decPos !== -1 && (s.length-decPos-1) < prec) { 
   		s += new Array(prec-(s.length-decPos-1)).join(0)+'0'; 
	} 
	else if (prec >= 1 && decPos === -1) { 
   		s += dec+new Array(prec).join(0)+'0'; 
	} 
	return s;
} 
var oldBut;

function getProductInfo(input){
	xid = $("#prodconfigOption_"+input).val();
	xid = replace(escape(xid),"+","%2B");
	var position = $("#infoBtn_"+input).position();
	
	if (xid != 0){
		var side = "/shop/productinfo.asp?PrintThisSite=1&id="+xid;
		//alert(side)
		$("#loader").html('<center><img src="/includes/89.gif"></center>');
		$("#loader").css({
			"left" : position.left-250,
			"top" : position.top+16
		});
		if ($("#loader").css("display") != "block" || oldBut == input){
			$("#loader").toggle();
		}
		AjaxEncoding.load({
			url: side,
			success: function(xmlStr) {
				var $html = $(xmlStr);
				$("#loader").html($html.find(".Description_Productinfo:eq(4)"));
			}
		});
		oldBut = input;
	}
}

function hideMe(){
	$("#loader").css({
		"display" : "none"
	});
}

function danishCharacters(txt){
	txt = txt.replace(/Ãƒâ€¦/g,"&Aring;");
	txt = txt.replace(/Ãƒâ€ /g,"&AElig;");
	txt = txt.replace(/ÃƒËœ/g,"&Oslash;");
	txt = txt.replace(/ÃƒÂ¥/g,"&aring;");
	txt = txt.replace(/ÃƒÂ¦/g,"&aelig;");
	txt = txt.replace(/ÃƒÂ¸/g,"&oslash;");
	return txt;
}

