/* GRAND PUBLIC - www.grandpublic.se */


// Cufon replacement
Cufon.replace('ul#topmenu a',{
	hover: true,
	hoverables: { a: true }
});
Cufon.replace('#showLongDescription a',{
	hover: true,
	hoverables: { a: true }
});

Cufon.replace('.n_date',{});
Cufon.replace('.n_type',{});
Cufon.replace('h2',{});
Cufon.replace('#productList h3',{});
Cufon.replace('#projectName',{});
Cufon.replace('#projectShortDescription span',{});
Cufon.replace('#allprojects h3',{});
Cufon.replace('.projectname',{});
Cufon.replace('.designername',{});
Cufon.replace('#product-group-header',{});
Cufon.replace('.mediaarchivelist li a',{});
Cufon.replace('#ctl00_Content_m_firstView h3',{});

Cufon.replace('.col-1 h3',{});
Cufon.replace('.col-2 h3',{});

Cufon.replace('.bx_pager',{});

Cufon.replace('#headerbarLinks a',{});

//Cufon.replace('#story .StoryHeadline p', { fontFamily: 'Rockwell Std' });
Cufon.replace('#story .StoryHeadline p', {});
Cufon.replace('#story .StoryDesigner p', {});

/*
// swfObjects - Front slide
var flashvars = {};
var params = {wmode:"window"};
var attributes = {};
swfobject.embedSWF("/ui/flash/me_banner.swf?clickTag=http://www.lammhults.se/modernessentials", "frontSlideFlash", "930", "420", "9.0.0", "/ui/js/expressInstall.swf", flashvars, params, attributes);
*/



$(function(){


		$('.thumbSlides').slides({
			//preload: true,
			//preloadImage: '/ui/img/framework/loader.gif',
			effect: 'slide',
			slideSpeed: 500,
			fadeSpeed: 800,
			generateNextPrev: true,
			generatePagination: true
		});




$("#newsletter-form").validate({
	submitHandler: function(form) {
	form.submit();
	$("#newsletter-submit").hide();
	$("#newsletter-message").text("Thank you!").fadeIn(1000);
	$("#input_email").val("");
	}
});

	$(".eqcol").equalHeights();
	$(".box-list li").equalHeights();


	//DROP DOWN - Projects, Not used right now	
    $(".dropdown dt a").click(function() {
        $(".dropdown dd ul").toggle();
        return false;
    });
                
    $(".dropdown dd ul li a").click(function() {
        var text = $(this).html();
        $(".dropdown dt a span").html(text);
        $(".dropdown dd ul").hide();
        //$('#source').quicksand( $('#destination li') );        
        //$("#result").html("Selected value is: " + getSelectedValue("drop-project-category"));
    });
                
    function getSelectedValue(id) {
        return $("#" + id).find("dt a span.value").html();
    }

    $(document).bind('click', function(e) {
        var $clicked = $(e.target);
        if (! $clicked.parents().hasClass("dropdown"))
            $(".dropdown dd ul").hide();
    });
	



	//ThreeDots
	if($.browser.msie)
	{
		$('.n_intro').ThreeDots({ max_rows: 4 });

		//if($.browser.version<8) { }
	}
	else
	{
		$('.n_intro').ThreeDots({ max_rows: 6 });	
	}


/*
	$('.n_long_intro').ThreeDots({
		max_rows: 14
	});
*/
	$('.article-name').ThreeDots({
		max_rows: 1
	});
	

	//Columizer
	$('#productList').columnize({width:250});
	$('#allprojects').columnize({width:300,lastNeverTallest:true});
	$('#ctl00_Content_m_firstView').columnize({width:220,lastNeverTallest:true});


	//Content slider, bxSlider. (front)
	$('#slides').bxSlider({
		alignment: 'horizontal',
		prev_image: '/ui/img/framework/nav-prev.png',
		next_image: '/ui/img/framework/nav-next.png',
		wrapper_class: 'slides_wrap',
		margin: 0,
		pause: 13000,
		auto: true	});
		
		/*Slider settings		
		alignment: 'horizontal',        // 'horizontal', 'vertical' - direction in which slides will move
		controls: true,                 // determines if default 'next'/'prev' controls are displayed
		speed: 500,                     // amount of time slide transition lasts (in milliseconds)
		pager: true,                    // determines if a numeric pager is displayed (1 2 3 4...)
		pager_short: false,             // determines if a 'short' numeric pager is displayed (1/4)
		pager_short_separator: ' / ',   // text to be used to separate the short pager
		margin: 0,                      // if 'horizontal', applies a right margin to each slide, if 'vertical' a
		                                // bottom margin is applied. example: margin: 50
		next_text: 'next',              // text to be displayed for the 'next' control
		next_image: '',                 // image to be used for the 'next' control
		prev_text: 'prev',              // text to be displayed for the 'prev' control
		prev_image: '',                 // image to be used for the 'prev' control
		auto: false,                    // determines if slides will move automatically
		pause: 3500,                    // time between each slide transition (auto mode only)
		auto_direction: 'next',         // order in which slides will transition (auto mode only)
		auto_hover: true,               // determines if slideshow will pause while mouse is hovering over slideshow
		auto_controls: false,           // determines if 'start'/'stop' controls are displayed (auto mode only)
		ticker: false,                  // determines if slideshow will behave as a constant ticker
		ticker_controls: false,         // determines if 'start'/'stop' ticker controls are displayed (ticker mode only)
		ticker_direction: 'next',       // order in which slides will transition (ticker mode only)
		ticker_hover: true,             // determines if slideshow will pause while mouse is hovering over slideshow
		stop_text: 'stop',              // text to be displayed for the 'stop' control
		start_text: 'start',            // text to be displayed for the 'start' control
		wrapper_class: 'bxslider_wrap'  // class name to be used for the outer wrapper of the slideshow
		*/		
		$('.bx_pager').hide();
		$('.slides_wrap .prev').hide();
		$('.slides_wrap .next').hide();

		$("#projectLongDescription").hide();
		
		$("#showLongDescription a.less").hide();
		$("#showLongDescription a.less").click(function () {
		
				$("#showLongDescription a.less").hide();
				$("#showLongDescription a.more").show();
				$("#projectLongDescription").slideToggle("fast");

		});
		$("#showLongDescription a.more").click(function () {

				$("#showLongDescription a.more").hide();		
				$("#showLongDescription a.less").show();
				$("#projectLongDescription").slideToggle("fast");

		});

		
		$("#bigFeature").hover(
		  function () {
			$(".slides_wrap .prev").stop().fadeTo("fast", 1);
			$(".slides_wrap .next").stop().fadeTo("fast", 1);
			$(".bx_pager").stop().fadeTo("fast", 1);

		  }, 
		  function () {
			$(".slides_wrap .prev").stop().fadeTo("slow", 0);
			$(".slides_wrap .next").stop().fadeTo("slow", 0);
			$(".bx_pager").stop().fadeTo("slow", 0);			
		  }
		);

		//Live filter, Projects
        $('.filterme').liveFilter('slide');

function formatTitle(title, currentArray, currentIndex, currentOpts) {
    return '<div class="fancybox-counter">' + (currentIndex + 1) + ' of ' + currentArray.length + '</div>';
}



		//FancyBox
		$("a.preview").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	200, 
			'overlayShow'	:	true,
			'titleShow'		:	true,
			'titlePosition'	:	'inside',
			'type'			:	'image',
			'titleFormat'	:	formatTitle
		});

		$("#images li a").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	200, 
			'overlayShow'	:	true,
			'titleShow'		:	true,
			'titlePosition'	:	'inside',
			'type'			:	'image'
		});

		$(".image-list a.image").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	200, 
			'overlayShow'	:	true,
			'titleShow'		:	true,
			'titlePosition'	:	'inside',
			'type'			:	'image'
		});

		$("#story .StoryImage a").fancybox({
			'transitionIn'	:	'elastic',
			'transitionOut'	:	'elastic',
			'speedIn'		:	400, 
			'speedOut'		:	200, 
			'overlayShow'	:	true,
			'titleShow'		:	true,
			'titlePosition'	:	'inside',
			'type'			:	'image'
		});


		$(".topImageVideo").click(function() {
			$.fancybox({
					'padding'		: 0,
					'autoScale'		: false,
					'transitionIn'	: 'none',
					'transitionOut'	: 'none',
					'title'			: this.title,
					'width'		: 680,
					'height'		: 495,
					'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
					'type'			: 'swf',
					'swf'			: {
					   	 'wmode'		: 'transparent',
						'allowfullscreen'	: 'true'
					}
				});
		
			return false;
		});


		//SlideJS, Products, thumbs, news
		$('#sld').slides({
			play: '6000',
			//preload: true,
			//preloadImage: '/ui/img/framework/loader.gif',
			effect: 'slide',
			crossfade: true,
			slideSpeed: 800,
			fadeSpeed: 1500,
			generateNextPrev: true,
			generatePagination: false
		});

		$('#newsImage').slides({
			effect: 'fade',
			crossfade: true,
			slideSpeed: 800,
			fadeSpeed: 500,
			generateNextPrev: true,
			generatePagination: true
		});	

			
		setTimeout(function(){
		      $('#facebook-like-box').fadeIn(1500);
		},1000);	

			$("#sld .prev").hide();
			$("#sld .next").hide();

			
		$("#product-group-top").hover(
		  function () {
			$(".prev").stop().fadeTo("fast", 1);
			$(".next").stop().fadeTo("fast", 1);
		  }, 
		  function () {
			$(".prev").stop().fadeTo("slow", 0);
			$(".next").stop().fadeTo("slow", 0);
		  }
		);

			$("#newsImage .prev").hide();
			$("#newsImage .next").hide();

			
		$("#newsImage").hover(
		  function () {
			$(".prev").stop().fadeTo("fast", 1);
			$(".next").stop().fadeTo("fast", 1);
		  }, 
		  function () {
			$(".prev").stop().fadeTo("slow", 0);
			$(".next").stop().fadeTo("slow", 0);
		  }
		);

			$(".thumbSlides .prev").hide();
			$(".thumbSlides .next").hide();


		$(".product-group-item").hover(
		  function () {
			$(this).find(".prev").show();
			$(this).find(".next").show();
		  }, 
		  function () {
			$(this).find(".prev").hide();
			$(this).find(".next").hide();
		  }
		);
		

		//URL rewrite on product links		
		function urlProducts () {
		
			$('#family li a').each(function(index) {
			    var url = $(this).attr('href').replace("-pc", "");
			    $(this).attr('href',url)
			});

			$('#designer-product-images li a').each(function(index) {
			    var url = $(this).attr('href').replace("-pc", "");
			    $(this).attr('href',url)
			});

		}
		urlProducts();
		
		$( "#tabs" ).tabs();	


		/*		
		function nameProducts () {
		
			$('.product-groupname').each(function(index) {
			    var groupname = $(this).text();			    
			});
		}
		nameProducts();
		*/







});
