
	
	var popupStatus = 0;  
		
		// jQuery ------------------------------------
		
		$(document).ready(
			
			function()
			{	
				
				
				sIFR.replace(kabel, {
					selector: 'h1',
					css: '.sIFR-root { color: #0f592d; font-size:30px;}',
					wmode: 'transparent'
				});	

				sIFR.replace(kabel, {
					selector: 'h3',
					css: '.sIFR-root { color: #0f592d; font-size:14px; }',
					wmode: 'transparent'
				});
				
				sIFR.replace(kabel, {
					selector: 'h4',
					css: '.sIFR-root { color: #0f592d; font-size:11px; }',
					wmode: 'transparent'
				});				

				
				// FADES ----------------------------------------

				if (!$.browser.msie){
					
					$('.fadeIn').css({
						"opacity": "0"
					});
					
					$('.fadeIn').delay(300).animate(
						{ opacity: 1 }, 500, 'easeOutQuad'
					 );
					
				}
				
				// CHECKBOXES -----------------------------------
				
				$(':checkbox').simpleImageCheck({
				  image: prefix+'images/checkbox_unchecked.png',
				  imageChecked: prefix+'images/checkbox_checked.png'
				});
				
				// SCROLL----------------------------------------
				
				$('#leftScrollPanel').jScrollPane(  );
								
				// LOGIN ----------------------------------------
				
				$('#login_input').focus(function() {
				  	$('#login_input').removeClass('showLabel');
					$('#login_input').addClass('noLabel');
				});
				
				$('#login_input').blur(function() {
					if( $('#login_input').val() == "" || $('#login_input').val() == " " ){
						$('#login_input').addClass('showLabel');
						$('#login_input').removeClass('noLabel');
					}
				});
				
				// DOCK -----------------------------------------	
				$('#dock').Fisheye(
					{
	
						maxWidth: 37,
						items: 'a',
						itemsText: 'span',
						container: '.dock-container',
						itemWidth: 40,
						proximity: 70,
						alignment : 'left',
						valign: 'bottom',
						halign : 'center'
						
					}
				);
				//----------------------------------------------
				
				// ORANGES -------------------------------------	
				
				var ww = $(window).width();
				$('.rightOranges').css({
					"left":ww-170
				});
				
				var h = $(window).height();
				$('#sun').height(h);
				
				// JUICE PRODUKT----------------------------------------------
					
					if (!$.browser.msie){
						
						$('#juice_rightImageContainer').css({
						
							"opacity": "0",
							"width": "0%"
						
						});
						
						$('#juice_rightImageContainer').animate({
						    opacity: 1,
						    width: '170px'
						}, 1000, 'easeInOutExpo' );
						
					}
					
				
				$('div#juice_fakta').hide();
				$('div#juice_rdi').hide();
				
				$('#juice_info_btn').click(function(){
					
					if( $("div#juice_fakta").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_fakta').hide();
							$('div#juice_info').show();
						}else{
							$('div#juice_fakta').fadeOut(50, function() {
							    $('div#juice_info').fadeIn(100);
							});
						}
					}else if( $("div#juice_rdi").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_rdi').hide();
							$('div#juice_info').show();
						}else{
							$('div#juice_rdi').fadeOut(50, function() {
							    $('div#juice_info').fadeIn(100);
							});
						}
					}
					
					$('#juice_info_btn').addClass('active');
					$('#juice_naringsfakta_btn').removeClass('active');
					$('#juice_rdi_btn').removeClass('active');


				});
				
				$('#juice_naringsfakta_btn').click(function(){
					
					
					if( $("div#juice_info").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_info').hide();
							$('div#juice_fakta').show();
						}else{
							$('div#juice_info').fadeOut(50, function() {
							    $('div#juice_fakta').fadeIn(100);
							});
						}
					}else if( $("div#juice_rdi").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_rdi').hide();
							$('div#juice_fakta').show();
						}else{
							$('div#juice_rdi').fadeOut(50, function() {
							    $('div#juice_fakta').fadeIn(100);
							});
						}
					}
					
					$('#juice_info_btn').removeClass('active');
					$('#juice_naringsfakta_btn').addClass('active');
					$('#juice_rdi_btn').removeClass('active');
					
					

				});
				
				$('#juice_rdi_btn').click(function(){
					
					
					if( $("div#juice_info").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_info').hide();
							$('div#juice_rdi').show();
						}else{
							$('div#juice_info').fadeOut(50, function() {
							    $('div#juice_rdi').fadeIn(100);
							});
						}
					}else if( $("div#juice_fakta").is(":visible") == true ){
						if ($.browser.msie){
							$('div#juice_fakta').hide();
							$('div#juice_rdi').show();
						}else{
							$('div#juice_fakta').fadeOut(50, function() {
							    $('div#juice_rdi').fadeIn(100);
							});
						}
					}
					
					$('#juice_info_btn').removeClass('active');
					$('#juice_naringsfakta_btn').removeClass('active');
					$('#juice_rdi_btn').addClass('active');

				});
				
				
				//  POPUP  -----------------------------------
				
				$("#memberDisclaimerButton").click(function(){  
					//centering with css  
					centerPopup();  
					//load popup  
					loadPopup();  
					
					sIFR.replace(kabel, {
						selector: 'div#popup h1',
						css: '.sIFR-root { color: #0f592d; font-size:20px;}',
						wmode: 'transparent'
					});	
					
					sIFR.replace(kabel, {
						selector: 'h3',
						css: '.sIFR-root { color: #0f592d; font-size:14px; }',
						wmode: 'transparent'
					});
					
				});
				
				$("#popupContactClose").click(function(){  
					disablePopup();  
				});  
				//Click out event!  
				$("#backgroundPopup").click(function(){  
					disablePopup();  
				});  
				//Press Escape event!  
				$(document).keypress(function(e){
					if(e.keyCode==27 && popupStatus==1){
						disablePopup();
					}
				});
				
				
				
				//  Om tropicana  -----------------------------------
				
				$('div#omtrop_post_2').hide();
				$('#omtrop_back_btn').hide();
				
				var omtrop_state = 1;
				
				$('#omtrop_next_btn, #omtrop_back_btn').click(function(){
					
					
					if( omtrop_state == 1 ){
						omtrop_state = 2;
						$('#omtrop_back_btn').show();
						$('#omtrop_next_btn').hide();
						if ($.browser.msie){
							$('div#omtrop_post_1').hide();
							$('div#omtrop_post_2').show();
						}else{
							$('div#omtrop_post_1').fadeOut(50, function() {
							    $('div#omtrop_post_2').fadeIn(100);
							});
						}
					}else{
						omtrop_state = 1;
						$('#omtrop_back_btn').hide();
						$('#omtrop_next_btn').show();
						if ($.browser.msie){
							$('div#omtrop_post_2').hide();
							$('div#omtrop_post_1').show();
						}else{
							$('div#omtrop_post_2').fadeOut(50, function() {
							    $('div#omtrop_post_1').fadeIn(100);
							});
						}
					}
					
					$('#juice_info_btn').removeClass('active');
					$('#juice_naringsfakta_btn').addClass('active');
					$('#juice_rdi_btn').removeClass('active');
					
				});
				
				
//  Tävling old comp fix  -----------------------------------
				
				$('div#tavling_old_wrapper').hide();
				$('#comp_current_btn').hide();
				
				
				setTimeout("showPuff()", 2200);
				
				window.oldcomp_state = 1;

				//alert('oldcomp_state setting to 1 from start ' + oldcomp_state);
				
				//alert('maindoc ready');
				
				$('#comp_old_btn, #comp_current_btn').click(function(){
					
					//alert('oldcomp_state ' + oldcomp_state);
					
					//alert('click');
					if( oldcomp_state == 1 ){
						//alert('1');
						$('#comp_current_btn').show();
						$('#comp_old_btn').hide();
						
						
						
						//if ($.browser.msie){
						$('div#tavling_current_wrapper').hide();
						$('div#tavling_old_wrapper').show();
						
						
						sIFR.replace(kabel, {
							selector: 'h1',
							css: '.sIFR-root { color: #0f592d; font-size:30px;}',
							wmode: 'transparent'
						});
						
						oldcomp_state = 2;
						//alert('oldcomp_state setting to 2 from click ' + oldcomp_state);
						
					}
					else{
						
						//alert('2');
						
						$('#comp_current_btn').hide();
						$('#comp_old_btn').show();
						
						
						$('div#tavling_current_wrapper').show();
						$('div#tavling_old_wrapper').hide();
						
						
						sIFR.replace(kabel, {
							selector: 'h1',
							css: '.sIFR-root { color: #0f592d; font-size:30px;}',
							wmode: 'transparent'
						});
						
						oldcomp_state = 1;
						//alert('oldcomp_state setting to 1 from click ' + oldcomp_state);
					}
					
				});
				
				
				
			}
		);
		
		$(window).resize(
			
			function()
			{
				
				var ww = $(window).width();
				$('.rightOranges').css({
					"left":ww-170
				});
				
				var h = $(window).height();
				$('#sun').height(h);
				
			}
				
		);
		
		//----------------------------------
		
		var popupStatus = 0;  

		function loadPopup(){  
		//loads popup only if it is disabled  
		if(popupStatus==0){  
		$("#backgroundPopup").css({  
			"opacity": "0.4"  
		});  
		
		$("#backgroundPopup").fadeIn("fast");  
		$("#popupContact").fadeIn("fast");  
		popupStatus = 1;  
		}  
		}  

		function disablePopup(){  
		//disables popup only if it is enabled  
		if(popupStatus==1){  
		$("#backgroundPopup").fadeOut("fast");  
		$("#popupContact").fadeOut("fast");  
		popupStatus = 0;  
		}  
		}  


		function centerPopup(){  
		//request data for centering  
		var windowWidth = document.documentElement.clientWidth;  
		var windowHeight = document.documentElement.clientHeight;  
		var popupHeight = $("#popupContact").height();  
		var popupWidth = $("#popupContact").width();  
		//centering  
		$("#popupContact").css({  
		"position": "absolute",  
		"top": 140,  
		"left": windowWidth/2-popupWidth/2  
		});  
		//only need force for IE6  

		$("#backgroundPopup").css({  
		"height": windowHeight  
		});  

		}
		
		function showOldCompetition() {
			window.location.href = "./tavling";
			switchCompView();
		}
		
		function switchCompView() {
			//alert('switchCompView');
			
			$('#comp_current_btn').show();
			$('#comp_old_btn').hide();
			
			
			$('div#tavling_current_wrapper').hide();
			$('div#tavling_old_wrapper').show();
			
			sIFR.replace(kabel, {
				selector: 'h1',
				css: '.sIFR-root { color: #0f592d; font-size:30px;}',
				wmode: 'transparent'
			});
			
			window.oldcomp_state = 2;
			//alert('oldcomp_state setting to 2 from switch ' + oldcomp_state);
				
		}
		
		function showPuff() {
			if ($.browser.msie) {
				$('a#NYCpuff').show();
			} 
			else {
				$('a#NYCpuff').fadeIn(300);
			}
		}
		
