//(c)2009 Finansieringhsportalen

//$('#myTable td').each(function() {
                //if ($(this).text() == 'bidrag')
                //$(this).parent().css('backgroundColor', '#ffaaaa');
  //          }); 

//Document Ready

function selectPhase(phase){
			
			$('.saddColumn li').each(function () {
			
			var $cell = $(this).css("opacity", 1);				
				
				if(this.className.indexOf(phase) > -1){
				
					//$cell.css("background-color", "red");
					
				}else{
				
					$cell.css("opacity", 0.3);
					$cell.filter = "alpha(opacity='30')"; 
				}					
				if(phase == 'isut'){
				
					$cell.css("opacity", 1);
					$cell.filter = "alpha(opacity='100')"; 				
				}			
			});
			
			//$('.saddColumn li').css('background-color', "#ff0000");			
}

$(document).ready(function() {

	alterRowColors();
	$("#myTable1").tablesorter();
	$("#myTable2").tablesorter();
	$("#myTable3").tablesorter();
	$("#myTable4").tablesorter(); 
	
	$('#actorinfo').hide("fast");

});

   $(document).ready(function() {
   		$('#slideleft .button').click(function() {
   		var $lefty = $('.inner');
   		$lefty.animate({
   		left: parseInt($lefty.css('left'),10) == 0 ?
-$lefty.outerWidth() :
  0
 });
 });
 
 //$("ul.more").quickPager({
//pageSize:3,
//currentPage:1});



//Tooltip

function tooltip(){	
	/* CONFIG */		
		xOffset = 10;
		yOffset = 20;		
		// these 2 variable determine popup's distance from the cursor
		// you might want to adjust to get the right result		
	/* END CONFIG */		
	$("a.tooltip, .glassbuttonFOOL").hover(function(e){		
	
		//alert($(this).attr(title))
											  
		this.t = this.title;
		this.title = "";									  
		$("body").append("<p id='tooltip'>"+ this.t +"</p>");
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px")
			.show();		
    },
	function(){
		this.title = this.t;		
		$("#tooltip").remove();
    });	
	$("a.tooltip, .glassbutton").mousemove(function(e){
		$("#tooltip")
			.css("top",(e.pageY - xOffset) + "px")
			.css("left",(e.pageX + yOffset) + "px");
	});			
};



// starting the script on page load
$(document).ready(function(){
	tooltip();
});

});

function closeActorinfo()
    {  
    	$('#actorinfo').slideUp("fast");
    	
    	
 		$('.saddColumn li, .attsoka_body tr').each(function () {
			
			var $cell = $(this).css("background-color", "transparent");
			var $cell = $(this).css("color", "#666");
		}); 
		
		alterRowColors();

    }

function setContent(oEvent,name,type,webbsite,email,contact,tel,mob,yo,conds)
    {    
    
    	$('.actor_name').html(name);
    	$('.actor_type').html(type);
    	//$('.actor_website').html("");  
    	$('.actor_website').attr('title',webbsite);
    	$('.actor_website').attr('href',webbsite);    
    	$('.actor_website').attr("target", "_blank"); 
    	$('.actor_email').html('E-post');
    	$('.actor_email').attr('href', 'mailto:' + email);
    	$('.actor_email').attr('title', email);
    	$('.actor_contact').html(contact);
    	$('.actor_tel').html(tel);
    	$('.actor_mob').html(mob);
    	
    	$('.conditions').html(conds); 
    	    	   	
    	$('.actorlogo').css('border-width', '1px');    	
     	
    	$('#actorinfo').slideDown("fast");
    	
    	if(yo.length > 0){    	
    		$('.actorlogo').attr('src', yo);
    		$('.actorlogo').css('border-color', '#aaa');
    	}else{
    		$('.actorlogo').attr('src', "../Styles/Images/logo_missing.jpg");
    		$('.actorlogo').css('border-color', '#164165');
    	}    	
    	
    	$('.attsoka_body tr').each(function () {
			
			$(this).css("background-color", "transparent");
		});
    	
    	$('.saddColumn li').each(function () {
			
			var $cell = $(this).css("background-color", "transparent");
			var $cell = $(this).css("color", "#666");
		});
		
		alterRowColors();  
				 	
    	if(oEvent.target != null){
    		
    		if(oEvent.target.nodeName == "LI"){
    			oEvent.target.style.backgroundColor = "#eda423";  	
    			oEvent.target.style.color = "#fff";  	
    		}
    		if(oEvent.target.parentNode.nodeName == "LI"){
    			oEvent.target.parentNode.style.backgroundColor = "#eda423";     
    			oEvent.target.parentNode.style.color = "#fff";   		
    		}
    		if(oEvent.target.parentNode.parentNode.nodeName == "TR"){
    			oEvent.target.parentNode.parentNode.style.backgroundColor = "#eda423";      		
    		}    	
    	}   	
    	
    	window.location.href = "#";
    	
    }
    
function setContent2(trash,name,type,webbsite,email,contact,tel,mob,yo)
    {    
    	$('.actor_name').html(name);
    	$('.actor_type').html(type);
    	$('.actor_website').html("<a href=" + webbsite +">" + webbsite + "</a>");
    	$('.actor_website').attr("href", website);  
    	$('.actor_website').attr("target", "_blank");  
    	$('.actor_email').html(email);
    	$('.actor_contact').html(contact);
    	$('.actor_tel').html(tel);
    	$('.actor_mob').html(mob);    	    	
    	
    	$('.actorlogo').css('border-width', '1px');    	
     	
    	$('#actorinfo').slideDown("fast");
    	
    	if(yo.length > 0){    	
    		$('.actorlogo').attr('src', yo);
    		$('.actorlogo').css('border-color', '#aaa');
    	}else{    	
    		$('.actorlogo').attr('src', "../Styles/Images/logo_missing.jpg");
    		$('.actorlogo').css('border-color', '#164165');
    	}
    	
    }


function PrintContent()
    {
        var DocumentContainer = document.getElementByClassName('block_2');
        var WindowObject = window.open('', "TrackHistoryData", "width=740,height=325,top=200,left=250,toolbars=no,scrollbars=yes,status=no,resizable=no");
        WindowObject.document.writeln(DocumentContainer.innerHTML);
        WindowObject.document.close();
        WindowObject.focus();
        WindowObject.print();
        WindowObject.close();
    }


function changeContent(content) {

	switch(content){
	
		case 'attsoka': 
			$('.attsoka_body').slideUp("fast");
  			$('#attsoka').slideDown("fast");
  			$('#actorinfo').slideUp("fast");
		break;
		
		case 'TableIde':
			$('.attsoka_body').slideUp("fast");
  			$('#TableIde').slideDown("fast");
  			alterRowColors(); 
  		break;
		case 'TableStart':
			$('.attsoka_body').slideUp("fast");
  			$('#TableStart').slideDown("fast");
  			alterRowColors();
  		break;
		case 'TableUtveckling': 
		
			$('.attsoka_body').slideUp("fast");
  			$('#TableUtveckling').slideDown("fast");
  			alterRowColors();
  		break;
  		case 'TableTillvaxt': 
  		$('.attsoka_body').slideUp("fast");
  			$('#TableTillvaxt').slideDown("fast");
  			alterRowColors();
  					break;
	}
	
	alterRowColors(); 

	
}

function togglePhase(dw) {
	
	switch(dw){
	
		case 'ide': 
			var $lefty = $('#inner0');
			changeContent('TableIde');
			$('#linkchain_phase').html("<a style='font-weight:bold;' class='Breadcrumb'> - id&eacute;</a>");	
		break;
		
		case 'start': 
			var $lefty = $('#inner1');
			changeContent('TableStart');
			$('#linkchain_phase').html("<a style='font-weight:bold;' class='Breadcrumb'> - start</a>");	
		break;
		
		case 'utveckling': 
			var $lefty = $('#inner2');
			changeContent('TableUtveckling');
			$('#linkchain_phase').html("<a style='font-weight:bold;' class='Breadcrumb'> - utveckling</a>");	
		break;
		
		case 'tillvaxt': 
			var $lefty = $('#inner3');
			changeContent('TableTillvaxt');
			$('#linkchain_phase').html("<a style='font-weight:bold;' class='Breadcrumb'> - tillv&auml;xt</a>");	
		break;		
		
	}
	
	$lefty.animate({
   		left: parseInt($lefty.css('left'),10) == 0 ? -$lefty.outerWidth() : 0
 	},'fast');

	
}

function toggle2Phase(dw) {
	
	switch(dw){
	
		case 'ide': 
			var $lefty = $('#inner0');
			$('#inner1').css('left', -598);
			$('#inner2').css('left', -598);
			$('#inner3').css('left', -598);
		break;
		
		case 'start': 
			var $lefty = $('#inner1');
			$('#inner0').css('left', -598);
			$('#inner2').css('left', -598);
			$('#inner3').css('left', -598);
		break;
		
		case 'utveckling': 
			var $lefty = $('#inner2');
			$('#inner1').css('left', -598);
			$('#inner0').css('left', -598);
			$('#inner3').css('left', -598);
		break;
		
		case 'tillvaxt': 
			var $lefty = $('#inner3')
			$('#inner1').css('left', -598);
			$('#inner2').css('left', -598);
			$('#inner0').css('left', -598);
		break;
		
		
		
	}
	
	
	$lefty.animate({
   		left: parseInt($lefty.css('left'),10) == 0 ? -$lefty.outerWidth() : 0
 	});

	
}

function toggleClosePhase(dw) {
	
	$('#linkchain_phase').html("");	
	
	switch(dw){
	
		case 'ide': 
			var $lefty = $('#inner0');
		break;
		
		case 'start': 
			var $lefty = $('#inner1');
		break;
		
		case 'utveckling': 
			var $lefty = $('#inner2');
		break;
		
		case 'tillvaxt': 
			var $lefty = $('#inner3');
		break;
		
		
	}
	
	changeContent('attsoka');
	
	$lefty.animate({
   		left: parseInt($lefty.css('left'),10) == 0 ? -$lefty.outerWidth() : 0
 	});
 	}

function alterRowColors(){
	$("tr:even").css("background-color", "#e4e4e4");
	$("tr:odd").css("background-color", "#ededed");
}

$(document).ready(function() {

 //hide the all div except first one
$('.attsoka_body:not(:first)').hide();
$('.attsoka_body::nth-child(2)').show();
//when the anchor is clicked content gets faded

var introdiff = 150 - $(".intro").height();

$("#text").columnize({columns: 2});
$(".column:first-child").css("margin-left","0");
//$(".column:first-child").css("margin-top",-introdiff + 30);



$('#navigation li:first-child span').css('opacity', 1);

        if ($.browser.msie && $.browser.version < 7) return;
        
        $('#navigation li')
            .removeClass('highlight')
            .find('a')
            .append('<span class="hover" />').each(function () {
                    var $span = $('> span.hover', this).css('opacity', 0);
                    $(this).hover(function () {
                        // on hover
                        $('#navigation li:first-child span').stop().fadeTo(500, 0);  
                        $span.stop().fadeTo(500, 1);                                            
                        //$.first.stop().fadeTo(500, 0);
                    }, function () {
                        // off hover
                        $span.stop().fadeTo(500, 0);
                        $('#navigation li:first-child span').stop().fadeTo(500, 1);  
                        
                        
                       //$.first.stop().fadeTo(500, 1);
                    });
                });
                

$('#navigation li:first-child span').stop().css('opacity', 1);  
 
$(".WebContent").children(":last-child").height($.myvariable);


$('.block_2_top').prepend('<div style="float:right;"><a class="print" onclick="PrintContent()" href="javascript:void(0)"><img src="../Styles/Images/icon_print.gif"></a></div>');
$('.block_2_top .print').click(function() {
	window.print();
	return false;
});



//Slidein Info
$(document).ready(function(){
                $("#faslink").click(function(){
                    if ($("#fas_overlay").is(":hidden")){
                        $("#fas_overlay").hide('slide', {direction: 'left'}, 1000);

                    }
                    else{
                        $("#fas_overlay").show('slide', {direction: 'right'}, 1000);
                    }
                });
            });
            function closeForm(){
                $("#messageSent").show("slow");
                setTimeout('$("#messageSent").hide();$("#contactForm").slideUp("slow")', 2000);
           }
});

function fixheights(){

	$.box1 = $("#block_1").outerHeight(true);
	$.box2 = $(".block_2").outerHeight(true);

	//alert($.box2);
	//alert($.box2);
	$.firstpadding = $("#block_1").outerHeight() - $("#block_1").height();
	$.lastpadding = $(".block_1_last").outerHeight() - $(".block_1_last").height();

	$(".block_1_full").height($.box2 - 101);
	$(".block_1_last").height($.box2 - $.box1 - 7);
}






$(document).ready(function() {



//Enabla alla javascript-element 
$("#markbox").show();

//Funktion fšr att assigna popupfunktionalitet pŚ popuplŠnkarna
$(".SupportTypeHeader a").each(function () {
			
	var $myDiv = "." + $(this).attr("id").replace(" ","");
	//alert($myDiv);
	$(this).click(function(){
		$($myDiv).modal();	
	});
});



$.box1 = $("#block_1").outerHeight(true);
$.box2 = $(".block_2").outerHeight(true);

//alert($.box2);
//alert($.box2);
$.firstpadding = $("#block_1").outerHeight() - $("#block_1").height();
$.lastpadding = $(".block_1_last").outerHeight() - $(".block_1_last").height();

//$(".block_1_full").height($.box2 - 101);
//$(".block_1_last").height($.box2 - $.box1 - 7);

});




// SHAREIT JQUERY

$(document).ready(function() {

	//grab all the anchor tag with rel set to shareit
	$('a[rel=shareit]').mouseenter(function() {		
		
		//get the height, top and calculate the left value for the sharebox
		var height = $(this).height();
		var top = $(this).offset().top;
		
		//get the left and find the center value
		var left = $(this).offset().left + ($(this).width() /2) - ($('#shareit-box').width() / 2);		
		
		//grab the href value and explode the bar symbol to grab the url and title
		//the content should be in this format url|title
		var value = $(this).attr('href').split('|');
		
		//assign the value to variables and encode it to url friendly
		var field = value[0];
		var url = encodeURIComponent(value[0]);
		var title = encodeURIComponent(value[1]);
		
		//assign the height for the header, so that the link is cover
		$('#shareit-header').height(height);
		
		//display the box
		$('#shareit-box').show();
		
		//set the position, the box should appear under the link and centered
		$('#shareit-box').css({'top':top, 'left':left});
			
		//assign the url to the textfield
		$('#shareit-field').val(field);
		
		//make the bookmark media open in new tab/window
		$('a.shareit-sm').attr('target','_blank');
		
		//Setup the bookmark media url and title
		$('a[rel=shareit-mail]').attr('href', 'mailto:?subject=' + title + '&body=' + url);
		$('a[rel=shareit-delicious]').attr('href', 'http://del.icio.us/post?v=4&amp;noui&amp;jump=close&amp;url=' + url + '&title=' + title);
		$('a[rel=shareit-digg]').attr('href', 'http://digg.com/submit?phase=2&amp;url=' + url + '&amp;title=' + title);
		$('a[rel=shareit-stumbleupon]').attr('href', 'http://www.stumbleupon.com/submit?url=' + url + '&title=' + title);
		$('a[rel=shareit-twitter]').attr('href', 'http://twitter.com/home?status=' + title + '%20-%20' + title);
		$('a[rel=shareit-facebook]').attr('href', 'http://www.facebook.com/share.php?u=' + url + '&amp;title=' + title);
		$('a[rel=shareit-linkedin]').attr('href', 'http://www.linkedin.com/shareArticle?mini=true&url=' + url + '&amp;title=' + title + '&amp;source=' + title + '&amp;summary=' + title);
		});
		
	//onmouse out hide the shareit box
	$('#shareit-box').mouseleave(function () {
		$('#shareit-field').val('');
		$(this).hide();
	});
	
	//hightlight the textfield on click event
	$('#shareit-field').click(function () {
		$(this).select();
	});
});


//EMAIL FIX
$(document).ready(function(){

	el = $('.email');
		el.each(function(){
		el.attr('href','mailto:' + el.attr('href').replace('|','@').replace('/','').replace(':','.'));
		el.attr('title',el.attr('href').replace('|','@').replace('/','').replace(':','.').replace('mailto.','Epost: '));
	});

});



