

	function confirmit(url) {
		var overlay = Builder.node('div', { id: 'box_overlay', style: 'width:100%;height:100%;position:fixed;background:#000;opacity:0.6;' });
		document.body.appendChild(overlay);
		if(confirm('The following information is for healthcare professionals only')) {
			window.location = url;
		}else{
			$('box_overlay').remove();
			return false;	
		}
	}




function show_pop(fil){
	if ($('box_overlay')){
		$('box_overlay').remove();
		$('box_wrapper').remove();
	}
	
	var overlay = Builder.node('div', { id: 'box_overlay',style: 'display:none' });
	var element = Builder.node('div', { id: 'box_wrapper'}, [
	  	
		Builder.node('div', { id: 'box_rep' }),
		
	  ]);
	  
	$('body').appendChild(overlay);
	$('body').appendChild(element);
	$('box_overlay').observe('click', (function() { $('box_overlay').remove();$('box_wrapper').remove() }));
	$('box_overlay').appear({ duration: 0.3, from: 0.0, to: 0.8 });
	
	new Ajax.Updater({ success: 'box_rep' }, fil, {});
}

/* Nytt popup script 31.08 */
var pop = {
 	init: function(file,type,width,title){
 		pop.destroy();
		pop.build_window(type,width,title);
		pop.update_content(file, type);
	},
	build_window: function(type,width,title){
		var overlay = Builder.node('div', { id: 'box_overlay', style: 'display:none' });
		
		/* Legg til nye type her hvis du vil bygge ut. */
		switch(type){
			case 1:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_login' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
			case 2:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_glemt' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
		    case 3:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_video' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
			case 4:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_tilbakemelding' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
			 case 5:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_vilkar' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
			case 6:
				var element = Builder.node('div', { id: 'box_wrapper', style: 'display:none;width:' + width + 'px;margin-left:-' + parseInt(width/2) + 'px;'}, [
				  	Builder.node('div', { id: 'box_top' }, title),
					Builder.node('div', { id: 'box_rep', className: 'box_rep_passordsendt' }),
					Builder.node('div', { id: 'box_close' })
				  ]);
				  break;
			break;
		}
		  
		document.body.appendChild(overlay);
		document.body.appendChild(element);
		
		$('box_overlay').observe('click', (function() { pop.destroy(); }));
		$('box_close').observe('click', (function() { pop.destroy(); }));
		$('box_overlay').appear({ duration: 0.3, from: 0.0, to: 0.5, queue: 'end' });
		$('box_wrapper').appear({ duration: 0.3, from: 0.0, to: 1.0, queue: 'end' });
	},
	update_content: function(file){
		new Ajax.Updater({ success: 'box_rep' }, file, {});
	},
	destroy: function(){
 		if ($('box_overlay')){
			$('box_overlay').remove();
			$('box_wrapper').remove();
		}
	}
};
/* ===== */





var functions = {

                init: function(){

                                functions.hide_all();

                                Event.observe(document, 'click', functions.click_handler.bindAsEventListener());

                },

                hide_all: function(){

                                $$('.dropdown_wrapper').each(function(s){ s.setStyle({display:'none'}); });

                },

                click_handler: function(e){

                                var tag = Event.element(e);

                                

                                if (tag.className == 'dropdown'){ functions.dropdown(tag); }

                },

                dropdown: function(obj){

                                obj.next(0).appear({duration:'0.5'});

                                

                                obj.next(0).select('a').each(function(s){

                                                Event.observe(s,'click',function(){

                                                                s.up('.dropdown_wrapper').previous(0).update(s.innerHTML);

                                                });

                                });

                                Event.observe(document,'click',function(){obj.next(0).hide()});

                }

}

//function page_leave(e){
		//var tag = Event.element(e);

		//if (tag.tagName == 'A') { 
			//if (!tag.href.include('kundeweb.aggressive.no') && !tag.href.include('algeta')){
				//if (!confirm("You are now leaving algeta. Links to sites outside of Algeta are provided as a resource to the viewer. Algeta accepts no responsibility for the content of linked sites.")) e.stop();
			//}
		//};
	//};
	
	//document.observe("dom:loaded", function() {
		//document.observe("click", page_leave.bindAsEventListener());
	//});




