/*	var c = readCookie('style');
	if (c=='switch_1024') {
		document.getElementById('styles-1024').disabled = false;
	}
*/
		document.getElementById('styles-1024').disabled = true;
	document.getElementsByTagName('HTML')[0].setAttribute("class",'jscript');

jQuery.noConflict();



(function($){
	initScrollPane = function()
	{
		//$('.blocks li').not('.blocks li li').filter(':last').css('margin-right',0);
		$('.blocks li.scroll-interval').filter(':last').css('margin-right',0);
		
		//lis = $('.blocks li').not('.blocks li li');
		var lis = $('.blocks li.scroll-interval');
			$('.blocks').css('width',(lis.outerWidth()+parseInt(lis.css('margin-right')))*lis.size()-parseInt(lis.css('margin-right'))+'px');//+44px
			if($('.blocks li.scroll-interval').length>1) {
				if($.browser.msie && parseInt($.browser.version)>=7) $('#scrollpane').css('overflow','visible');
				
				setTimeout(function(){
					$('#scrollpane').jScrollHorizontalPane({scrollbarHeight:18, scrollbarMargin:0, animateTo:false, animateInterval:50, animateStep:2});
				},$.browser.msie?5:0);
			}
	};
})(jQuery);		

	/*
	* Handy references
	*/
	window.viewport = 
	{
	    height: function() { 
	        return jQuery(window).height(); 
	    },
	    
	    width: function() {
	        return jQuery(window).width();
	    },
	    
	    scrollTop: function() {
	        return jQuery(window).scrollTop();
	    },
	    
	    scrollLeft: function() {
	        return jQuery(window).scrollLeft();
	    }
	};

	if(window.viewport.height()>600 && window.viewport.width()>1000)
	{
		//$.stylesheetSwitch('switch_1024');
		document.getElementById('styles-1024').disabled = false;
		document.getElementById('styles-1024').media = 'all';
	}


(function($){

jQuery(document).ready(function($){

	/*
	* Set pagesize stylesheet from cookie
	*/
	//$.stylesheetInit();

	//$("html").addClass('jscript');

	$('.notes_block:last').css('margin-left',(parseInt($('.notes_block').css('margin-left'))*2)+'px');
	/*
	* Remove left margin from the first thumb on every row
	*/
	$(".image_list_wrapper ul").fitFloats({childSelector:'li:not(.scroll-interval)'})
							   .bind('mouseup',function(){
							   		$(this).find('>li:not(.scroll-interval)').css('marginRight',null)
											   		   .end()
											   		   .fitFloats({childSelector:'li'});
							   		});


	sidemenu_title_height = $('.menublocks h2').height()+parseInt($('.menublocks h2').css('marginBottom'));
	sidemenu_containers = $('.menublocks, .menublock, .menu_block, .col_left .jScrollPaneContainer');
	if(sidemenu_containers.closest('li.menublock').length>1) sidemenu_containers.css('height',$('.menublocks ul').not('.menublocks ul ul').eq(0).outerHeight()+sidemenu_title_height+2+'px');

	if(window.viewport.height()>600 && window.viewport.width()>1000)
	{
		//$.stylesheetSwitch('switch_1024');
		//document.getElementById('styles-1024').disabled = false;
		
		$("body").addClass('resize_large');
		$('#scrollpane').css('overflow','hidden');
		//$('<link rel="stylesheet" type="text/css" media="all" />').load(setTimeout(initScrollPane,300)).attr('href','assets/css/styles-1024.css').insertAfter('#styles-1024');
		
		//setTimeout(initScrollPane,40);
		initScrollPane();

	} else
	{
		/*
		$('.menublocks ul').not('.menublocks ul ul').each(function(e){
			if($(this).height()>$(e).height())
				$('.menublocks, .menublock, .menu_block, .col_left .jScrollPaneContainer').css('height',$(this).height());
			});
		*/
		//$.stylesheetSwitch('');
		initScrollPane();
	}

	//$('#scrollmenu').jScrollHorizontalPane({resize:false,scrollbarHeight:0, scrollbarMargin:0, animateTo:true, animateInterval:50, animateStep:2});
			//console.log('dopne'+typeof($('#scrollpane').eq(0).scrollTo));

	/*if(location.href.indexOf('client:')>-1)
		$("#scrollmenu ul.menublocks").css('margin-left',-$(this).find("li.menublock:eq(1)").position().left);
		//$("#scrollmenu")[0].scrollTo("li.menublock:eq(1)");
	*/
	
/*
	$('.scroll-to').bind('click',function(){
		$('#pane1')[0].scrollTo(75);
		return false;
	});
*/		
	
	if($('#scrollpane li.scroll-interval').length>1){
		$('a.jumper').click(function(){
			var pos = parseInt($(this).attr('rel'));
			var c = $("#scrollpane").css({position:'relative'});
		if(jQuery.browser.msie)
		{
			c.stop().animate({left:-$("li.scroll-interval:eq("+pos+")").position().left});
		
		} else
		{
			c[0].scrollTo("li.scroll-interval:eq("+pos+")");
		}	
			/*
			$('#scrollpane object').each(function(i){
				this.id = 'player'+i;
				$(this).attr('name',this.id);
				//if(i==0) alert(typeof(this.sendEvent));
				///if(typeof(this.sendEvent)!='undefined') this.sendEvent('PLAY', 'false');
				});
			*/
			return false;
		});
	}
	
	$('a.menu_buttons').click(function(){
		var pos = parseInt($(this).attr('rel'));
		var c = $("#scrollmenu");//.menu_block
		if(1!=1&&!jQuery.browser.mozilla)
		{
			c[0].scrollTo("li.menublock:eq("+pos+")");
		} else
		{
			c.stop().animate({scrollLeft:pos==0?$("li.menublock:eq("+pos+")").position().left:$("li.menublock:eq(0)").outerWidth(true)});
		}
		var targetHeight = $("li.menublock:eq("+pos+") ul").not('.menublocks ul ul').outerHeight()+sidemenu_title_height+2+'px';
		$('.menublocks, .menublock, .menu_block, .col_left .jScrollPaneContainer').css('overflow','hidden')/*.filter('.menublock').css('height',targetHeight).end()*/.animate({height:targetHeight},{queue:false,duration:500},'swing');
		return false;
	});
	
	/*
	* Blink more buttons
	*/
	setInterval(function(){
		$('.jumper').eq(0).css({color:'black'}); 
		setTimeout(function(){
			$('.jumper').eq(0).css({color:'#666'});
			},600);
	},1200);

	/*
	* Add random class to menu links
	*/
	$('.menu_block li li a').each(function(){
		$(this).addClass('menu_edge_'+Math.ceil(Math.random()*5));
	});

	
	
	/*
	* Add overlays to certain work pieces
	*/
	/*
	if(!$.browser.msie) {
		$('.blocks .scroll-interval>p').each(function(){
			$this = $(this);
			if($this.html().indexOf('shot')!==-1) {
				$('<div class="overlay"></div>').appendTo($this.closest('.scroll-interval').find('.content'));
			}
		
		});
	}
	*/


});

})(jQuery);
