Cufon.replace('.boxThird .setup,.boxThird h2,.greenBack,#overlayContainer .helper,#overlayContainer h1');
Cufon.replace('#mainNavigation a',{hover:true});
Cufon.replace('.popUpBox h2,.productTotal',{
	fontFamily:'ITCAMd'
});
Cufon.replace('.addToCart,#cart a,.buttonLinkBlue,.addToCartLarge',{
	fontFamily:'ITCAMd',
	textShadow:'0 1px 0 rgba(0,0,0,.41)'
});
Cufon.replace('#cartTotal,#helper',{
	fontFamily:'ITCAMd',
	textShadow:'0 1px 0 #fff'
});
Cufon.replace('#homeGallery h1,#homeGallery .small',{
	textShadow:'0 1px 0 rgba(255,255,255,.55)'
});
Cufon.replace('#homeGallery .body, #legend, #pageTitle',{
	textShadow:'0 1px 0 rgba(255,255,255,.33)'
});
Cufon.replace('.fauxCols3 .box h2, .fauxCols2 .box h1, .fauxCols2 .teaser, .fauxCols3 .teaser, #checkout h2',{
	textShadow:'0 1px 0 rgba(0,0,0,.8)'
});
//slideshow plugin
(function($){
	/*
	#		TODO
	#		-set up in view option for other effect than fade
	#		-non-full loops has unwanted behavior
	*/
	$.fn.contentSlider = function(options){
		var settings = {
			'slideSpeed'		:10000,	 		// Time between slides in milliseconds, if 0 only slide on user request
			'showNumbers'		:false, 		// Show slide counter true|false
			'showMarkers'		:false, 		// Show bullet navigation true|false
			'showNavigation'	:false, 		// Show prev/next navigation true|false
			'transition'		:'fade', 		// Transition between objects up|down|left|right|fade
			'inView'			:1,				// Number of slides to show in view
			'loop'				:true,			// Loop slides at end true|false
			'contentOutCall'	:function(){},	// Callback executed on slide out complete
			'contentInCall'		:function(){}	// Callback executed on slide in complete
		};
		return this.each(function(){
			if ( options ) { 
				$.extend( settings, options );
			}
			var elmCount = $('li',this).length;	
			//If no elements are found exit
			if(elmCount < settings.inView+1){
				return;
			}
			var $this = $(this);
			$this.append('<span class="nextArrow"></span><span class="previousArrow"></span>');
			var next = $('.nextArrow',this),
			previous = $('.previousArrow',this),
			//back = options.leftArrow ? $(options.leftArrow) : $("<span class='leftArrow'><</span>");
			//next = options.rightArrow ? $(options.rightArrow) : $("<span class='rightArrow'>></span>");
			elmHeight = $('li:first',this).outerHeight(true),
			startPos,
			pointer = 0,
			prev = 0,
			displayWidth = $('li:first',this).outerWidth(true)*settings.inView,
			elmWidth = $('li:first',this).outerWidth(true),
			elmCount = Math.ceil(elmCount/settings.inView);
			$('ul:first',$this).css({
				'position':'relative',
				'height':elmHeight,
				'width':displayWidth,
				'overflow':'hidden'
			});

			switch(settings.transition){
				case 'fade':
					startPos =[0,0];
					thisIn ={opacity:1};
					thisOut ={opacity:0};
					break;
				case 'up':
					startPos =[0,elmHeight];
					thisIn ={'top':0};
					thisOut ={'top':-elmHeight};
					break;
				case 'down':
					startPos =[0,-elmHeight];
					thisIn ={top:0};
					thisOut ={top:elmHeight};
					break;
				case 'left':
					startPos =[elmWidth,0];
					thisIn ={left:0};
					thisOut ={left:-elmWidth};
					break;
				case 'right':
					startPos =[-elmWidth,0];
					thisIn ={left:0};
					thisOut ={left:elmWidth};
					break;
			};
			$('li',this).each(function(){
				$(this).css({
					'position':'absolute',
					'left':(settings.inView>1)?startPos[0]+elmWidth*($(this).index()%settings.inView):startPos[0],
					'top':startPos[1]
				});
			});
			$('li',this).slice(0,settings.inView).css('z-index','999').addClass('current');
			if(settings.transition==='fade'){
				$("li",this).slice(settings.inView).css({
					'opacity':0,
					'z-index':998
				});
			}
			else{
				$('li:first',this).css({
					'left':0,
					'top':0
				})
			}
			if(settings.slideSpeed!=0) {//start the slides
				var startLoop = setTimeout(function() {
					next.click();
					if(settings.loop!=false || (settings.loop===false && pointer!=elmCount-1)){
						setTimeout(arguments.callee,settings.slideSpeed);
					}
				},settings.slideSpeed);
			}
			//add markers if requested
			if(settings.showMarkers===true){
				var str = '';
				for (var i=1, il=elmCount; i<=il; i++) {
					if(settings.showNumbers===true){
						str = str+'<li><span>'+i+'</span></li>';
					}
					else{
						str = str+'<li><span></span></li>';
					}
				};
				$('.nextArrow',$this).after('<ul class="markers"></ul>');
				$('.markers',this).append(str);
				$('.markers li:first',this).addClass('current');
				$('.markers li',this).click(function(){
					pointer=$('.markers li',$this).index(this)-1;
					next.click();
				});
			}

			next.click(function(event){
				event.stopPropagation();
				if(pointer+1===elmCount){
					pointer=0;
				}
				else{
					pointer++;
				}
				$('ul:first li.current',$this).animate(thisOut,600,'swing',function(){
					if(settings.transition!='fade'){
						$(this).css({
							'left':startPos[0],
							'top':startPos[1]
						});
					};
					settings.contentOutCall.call(this);
				}).css('z-index','998').removeClass('current');
				$('.markers li',$this).removeClass('current');
				$('.markers li:eq('+pointer+')',$this).addClass('current');
				$('ul:first li',$this).slice(pointer,pointer+settings.inView).animate(thisIn,600,'swing',function(){
					settings.contentInCall.call(this);
				}).css('z-index','999').addClass('current');
			});
			previous.click(function(event){
				event.stopPropagation();
				if(pointer===0){
					pointer=elmCount-1;
				}
				else{
					pointer--;
				}
				$('ul:first li.current',$this).animate(thisOut,600,'swing',function(){
					if(settings.transition!='fade'){
						$(this).css({
							'left':startPos[0],
							'top':startPos[1]
						});
					};
					settings.contentOutCall.call(this);
				}).css('z-index','998').removeClass('current');
				$('.markers li',$this).removeClass('current');
				$('.markers li:eq('+pointer+')',$this).addClass('current');
				$('ul:first li',$this).slice(pointer,pointer+settings.inView).animate(thisIn,600,'swing',function(){
					settings.contentInCall.call(this);
				}).css('z-index','999').addClass('current');
			});
		});
	};
})( jQuery );
function getModalContent(url,caller){
	var path = url.split('.'),
	href = escape(path[0])+'.'+path[1]+'?ajax=true #content';
	jQuery('#overlayContainer').html('');
	jQuery('#overlayContainer').load(href,function(){
		jQuery('#'+caller+' .dropDown').clone().prependTo('#overlayContainer .selector');
		jQuery('#overlayContainer a.addToCartLarge').attr('href',jQuery('#'+caller+' a.addToCart').attr('href'));
		/*jQuery('#overlayContainer select').removeAttr('name').removeAttr('id').bind('change',function(){
			jQuery('#'+caller+' select').val(jQuery('#overlayContainer select').val());	
		});*/
		runMods();
		Cufon.refresh();
		jQuery('#overlayContainer').dialog({
			width:'660px',
			modal:true
		});
	});
}
function runMods(){
	jQuery('.mod2').each(function(){
		var $this = jQuery(this);
		$this.is('table')?$this.children().children(':odd').addClass('even'):$this.children(':odd').addClass('even');
	});
}
function setQuantity(elm,val,caller){
	var $this = jQuery(caller).parent().parent().parent();
	jQuery('#'+elm).val(val);
	jQuery('.dropText',$this).text(jQuery(caller).text());
	jQuery('body').trigger('click');
}
(function($){
	$(document).ready(function(){
		$('#homeGallery .wrapper').contentSlider({
			showMarkers:true
		});
		$('.newsletterName input').val('Navn');
		$('.newsletterEmail input').val('Email');
		$('.newsletterEmail input').bind({
			focus: function(){
				if($(this).val()==='Email'){
					$(this).val('');
				}
			},
			blur: function(){
				if($(this).val()===''){
					$(this).val('Email');
				}
			}
		});
		$('.newsletterName input').bind({
			focus: function(){
				if($(this).val()==='Navn'){
					$(this).val('');
				}
			},
			blur: function(){
				if($(this).val()===''){
					$(this).val('Navn');
				}
			}
		});
		$('.switchSignup').click(function(){
			$('.signup').toggle();
		});
		$('#maincontent_0_chkUseShippingAddress').bind('change',function(){
			$('#alternateDelivery').slideToggle('slow');
		});
		if($('#cartTotalItems').val()==0){
			$('#goToCart').hide();
		}
		//IE select fix, delete on new dropdown implemantation
		if(navigator.userAgent.indexOf('MSIE')!==-1){
			$("#products select").bind('mouseenter',function(){
				$(this).addClass('widen');
			})
			.blur(function(){
				$(this).removeClass('widen');
			});
		}
	
		//Drop down
		$('.dropDown span').live('click',function(event){
			var $this =$(this).siblings('ul'),
			$parent = $(this).parent();
			//console.log($parent.live('click',function(){$(this).attr('class')}));
			if($parent.hasClass('active')===true){
				$('body').trigger('click');
				return;
			}
			$this.show();
			$parent.addClass('active');
			$this.click(function(event){
				event.stopPropagation();
				$this.hide();
				$parent.removeClass('active');
			});
			event.stopPropagation();
			$('body').one('click',function(){
				$this.hide();
				$parent.removeClass('active');
			});
		});
	});
})(this.jQuery);
