function as_bookmarkPage(){
	
	if( window.sidebar ) // firefox
		window.sidebar.addPanel( document.title, document.location.href, "" );
	else if( window.opera && window.print ) { // opera
		var elem = document.createElement('a');
			elem.setAttribute( 'href', document.location.href );
			elem.setAttribute( 'title', document.title );
			elem.setAttribute( 'rel', 'sidebar');
			elem.click();
	} 
	else if(document.all )// ie
		window.external.AddFavorite( document.location.href, document.title );
	else
		alert("Din webbläsare stödjer inte denna funktionalitet, var god välj \"lägg till bokmärke\" från bokmärkesmenyn");
}

function as_printPage() {

	window.print();

}

var boxHeight = 450;
var repeatHeight = $('highlights').scrollHeight;

$('highlights').innerHTML = $('highlights').innerHTML + $('highlights').innerHTML;

var stopScroll = 0;
var x;

function dp_project_scroll() {
	
	clearTimeout( x )
	
	if( stopScroll == 1)
		return;
		
	$('highlights').scrollTop = $('highlights').scrollTop + 1;
	
	if( $('highlights').scrollTop == repeatHeight )
		$('highlights').scrollTop = 0;
		
	x = setTimeout( "dp_project_scroll()", 40 );
}

x = setTimeout( "dp_project_scroll()", 1000 );


function dp_set_scrollerHeight() {
	
	if( $("column_1_1") ) {
		
		if( $("column_1_2") ) {
			var	highestCol = ( $("column_1_1").getHeight() > $("column_1_2").getHeight() ) ? $("column_1_1").getHeight() : $("column_1_2").getHeight();
				highestCol = highestCol - 35;
		}
		else
			highestCol = $("column_1_1").getHeight();
			
		var srollerHeight = ( highestCol > 500 ) ? highestCol : 500;
		
		if( srollerHeight > 1500 )
			srollerHeight = 1500;
		
		$("highlights").setStyle( { height: srollerHeight + "px" } );
		
		repeatHeight = $('highlights').scrollHeight;
	
	}
	
}

// Popup

function dp_init_popup( url ) {

	var parent_element = $( document.body );
	var page_element = $( "page_container" );
	var popup_height = 600;
	var popup_width = 800;
	
	
	var	cover_layer = new Element( "div", { id : "cover_layer" } );
		cover_layer.setStyle( { position : 'absolute' } );
		cover_layer.setStyle( { top : '0px' } );
		cover_layer.setStyle( { left : '0px' } );
		cover_layer.setStyle( { width : '100%' } );
		cover_layer.setStyle( { height : '100%' } );
		cover_layer.setStyle( { background : 'url(/static/site_mainGraphics/popup/background.png) no-repeat center center' } );
	
	var close_link = new Element( "a", { href : "#", onclick: "return dp_remove_popup()" } ).update("Stäng");
	
	var	iFrame = new Element( "iframe", { id : "popup_iframe" } );
		iFrame.writeAttribute( "frameBorder", "0" );
		iFrame.writeAttribute( "src", url );
		iFrame.writeAttribute( "scrolling", "auto" );
		iFrame.setStyle( { 'border' : 'none' } );
		iFrame.setStyle( { width : popup_width + 'px' } );
		iFrame.setStyle( { height : popup_height + 'px' } );
		iFrame.setStyle( { margin : dp_calculate_popup_y( popup_height ) + 'px ' + dp_calculate_popup_x( popup_width ) + 'px' } );
		iFrame.setStyle( { backgroundColor : '#000000' } );

		page_element.setOpacity(".3");
		
		//cover_layer.appendChild( close_link );
		cover_layer.appendChild( iFrame );
		
		parent_element.appendChild( cover_layer );
	
}

function dp_remove_popup() {

	$( "page_container" ).setOpacity("1.0");;
	$( "cover_layer" ).remove();
	
	return false;

}

function dp_calculate_popup_y( popup_height ) {
	
	 var offset_y = parseInt( ( document.viewport.getHeight() - popup_height ) / 2 );
	 offset_y = offset_y - 25; // compensate for drop shadow of the background;
	 
	 return offset_y

}

function dp_calculate_popup_x( popup_width ) {
	
	 var offset_x = parseInt( ( document.viewport.getWidth() - popup_width ) / 2 );
	 offset_x = offset_x - 26; // compensate for drop shadow of the background;
	 
	 return offset_x

}


// Google generated code

var google_simpleEncoding = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
 
function google_simpleEncode(valueArray,maxValue) {
	
	var chartData = ['s:'];
	for (var i = 0; i < valueArray.length; i++) {
		var currentValue = valueArray[i];
		if (!isNaN(currentValue) && currentValue >= 0) {
			chartData.push(simpleEncoding.charAt(Math.round((google_simpleEncoding.length-1) * currentValue / maxValue)));
		}
		else {
			chartData.push('_');
		}
	}
	return chartData.join('');
}


