function open_img_big(img, pic_width, pic_height, pic_path){
	//var pic_id = $(img).getProperty('id');
	//var pic_height = parseInt($(pic_id+'_height').getProperty('value')) + 0;
	//var pic_width = parseInt($(pic_id+'_width').getProperty('value')) + 0;
//	var pic_path = $(pic_id+'_path').getProperty('value');
	//alert(pic_path);
	var wraper = new Element('div', {id:'img_wraper', styles:{width:pic_width+'px', 'overflow':'hidden'}});
	var bilde = new Element('img', {src: pic_path, styles: { width:pic_width+"px"}});
	//var text_dic = new Element('div', {html:$(img).get('bilde_text'), styles:{height:'20px', 'overflow':'hidden'}});
	bilde.inject(wraper);
	//text_dic.inject(wraper);
	SqueezeBox.fromParams({handler:'div', size:{x:pic_width+0,y:pic_height}, div_cont:wraper, divOptions:{styles:{overflow:'hidden'}}, onClose:function(){
		var bilde_f = bilde;
		var wraper_f = wraper;
		delete bilde_f;
		delete wraper_f;
	}});
}
function flash_img_clicked1(img_ind){
	var img_flash = $('flash_holder');
	var pic_width = parseInt(img_flash.get_tag_property(img_ind, 'big_img_src', 'width'));
	var pic_height = parseInt(img_flash.get_tag_property(img_ind, 'big_img_src', 'height'));
	var pic_src = img_flash.get_tag_value(img_ind, 'big_img_src');
	var wraper = new Element('div', {id:'img_wraper', styles:{width:pic_width+'px', 'overflow':'hidden'}});
	var bilde = new Element('img', {src: pic_src, styles: { width:pic_width+"px"}});
	//var text_dic = new Element('div', {html:$(img).get('bilde_text'), styles:{height:'20px', 'overflow':'hidden'}});
	bilde.inject(wraper);
	//text_dic.inject(wraper);
	SqueezeBox.fromParams({handler:'div', size:{x:pic_width+0,y:pic_height}, div_cont:wraper, divOptions:{styles:{overflow:'hidden'}}, onClose:function(){
		var bilde_f = bilde;
		var wraper_f = wraper;
		delete bilde_f;
		delete wraper_f;
	}});
}

var Current_page = 0;
var Hide_time_out = 0;

function top_menu_mouseover($page_id){
	if (Current_page === $page_id) return;
	if (Current_page !== 0) $('page-sub-'+Current_page).setStyles({'display': 'none'});
	cancel_hide();
	Current_page = $page_id;
	$('page-sub-'+$page_id).setStyles({'display': 'block'});
}
function top_menu_mouseout($page_id){
	Current_page = 0;
	cancel_hide();
	Hide_time_out = $('page-sub-'+$page_id).setStyles.delay(1200, $('page-sub-'+$page_id), {'display': 'none'});
}
function cancel_hide(){
	$clear(Hide_time_out);
	Hide_time_out = 0;
}
function newWindow(link){ // forestilling spilerlist
	var win = window.open(link, "TrackHistoryData", "width=690,height=480,top=0,left=0,toolbars=no,scrollbars=yes,status=no,resizable=yes");
	win.focus();
}


var current_JS_img_ind = -1;
function picture_changed(ind){
	current_JS_img_ind = ind;
}

function flash_img_clicked(img_ind){
	var img_flash = $(flash_fade_id);
	current_img_ind = img_ind;
	current_JS_img_ind = img_ind;
	img_flash.stop_auto_play();
	var pic_width = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'width'));
	var pic_height = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'height'));
	//var total_pic = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'total_pic'));
	var pic_src = img_flash.get_tag_value(img_ind, 'big_img');
	var wraper = new Element('div', {id:'img_wraper', styles:{width:pic_width+'px', 'overflow':'hidden'}});
	var bilde = new Element('img', {src: pic_src, 'class':'hand_hover', styles: { width:pic_width+"px"}});
	//var pic_title = img_flash.get_tag_value(img_ind, 'img_title');
	var pic_title = img_flash.get_tag_value(img_ind, 'img_text');
	var pic_org_path = img_flash.get_tag_value(img_ind, 'org_img_path');
	var bilde_a = new Element('a', {'class':"hand_hover text", styles:{'background-color':'#EB6E1F', 'color':'#fff', 'float':'right', 'width': '70', 'line-height':'16px', 'padding':'2px 4px', 'margin-left':'5'}, href:EDIT_CORE.JSSiteRoot+'site/pages/download.php?filnavn='+pic_org_path+'&fc='+page_name+'('+(current_JS_img_ind + 1)+').jpg', target:"_blank"});
	bilde_a.set('html', 'Last ned');
	bilde.inject(wraper);
	var priev_pic = new Element('div', {id:'pr_img', 'class':"hand_hover text", styles:{'background-color':'#EB6E1F', 'color':'#fff', 'float':'left', 'width': '70', 'line-height':'16px', 'padding':'2px 4px'}});
	priev_pic.set('html', '&lt;&nbsp;Forrige');
	var next_pic = new Element('div', {id:'next_img', 'class':"hand_hover text", styles:{'background-color':'#EB6E1F', 'color':'#fff', 'float':'left', 'width': '70', 'line-height':'16px', 'padding':'2px 4px', 'margin-left':'5'}});
	next_pic.set('html', 'Neste&nbsp;&gt;');
	var pic_text_holder = new Element('span', {id:"img_text", 'class':'text', styles: {'color':'#fff', 'line-height':'16px', 'padding':'2px 4px'}});
	pic_text_holder.set('html', pic_title);
	var controls_cont = new Element('div', {id:'controls_cont', styles:{'background-color':'#EB6E1F', 'text-align': 'center', 'height': '20px', 'margin-top': '3', 'line-height':'20px'}});

	if (total_bildene > 1){
		var next_click = function(e){
			var img_flash = $(flash_fade_id);
			if (current_JS_img_ind != img_flash.get_currrent_img_ind()) return;
			var img_ind = img_flash.get_priev_img_ind();
			//current_JS_img_ind = img_ind;
			img_flash.pr_image();//next_image();
			var pic_width = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'width'));
			var pic_height = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'height'));
			//var total_pic = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'total_pic'));
			var pic_src = img_flash.get_tag_value(img_ind, 'big_img');
			var pic_text = img_flash.get_tag_value(img_ind, 'img_text');
			var pic_text_holder_p = pic_text_holder;
			pic_text_holder_p.set('html', pic_text);
			var bilde_last_ned = bilde_a;
			var pic_org_path = img_flash.get_tag_value(img_ind, 'org_img_path');
			bilde_last_ned.setProperty('href', EDIT_CORE.JSSiteRoot+'site/pages/download.php?filnavn='+pic_org_path+'&fc='+page_name+'('+(current_JS_img_ind + 1)+').jpg');
			var img_wraper = wraper;
			var img_hold = bilde;
			img_hold.setStyle('width', pic_width);
			img_hold.setStyle('height', pic_height);
			img_hold.setProperty('src', pic_src);
			img_wraper.setStyle('width', pic_width);
			SqueezeBox.resize({'x':pic_width + 0, 'y':pic_height + 24});
		};
		bilde.addEvent('click', next_click);
		priev_pic.addEvent('click', next_click);

		next_pic.addEvent('click', function(e){
			var img_flash = $(flash_fade_id);
			//alert(current_JS_img_ind + ' ' +img_flash.get_currrent_img_ind());
			if (current_JS_img_ind != img_flash.get_currrent_img_ind()) return;
			var img_ind = img_flash.get_next_img_ind();
			//current_JS_img_ind = img_ind;
			img_flash.next_image();
			var pic_width = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'width'));
			var pic_height = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'height'));

			//var total_pic = parseInt(img_flash.get_tag_property(img_ind, 'big_img', 'total_pic'));
			var pic_src = img_flash.get_tag_value(img_ind, 'big_img');
			var pic_text = img_flash.get_tag_value(img_ind, 'img_text');
			var pic_text_holder_p = pic_text_holder;
			pic_text_holder_p.set('html', pic_text);
			var bilde_last_ned = bilde_a;
			var pic_org_path = img_flash.get_tag_value(img_ind, 'org_img_path');
			bilde_last_ned.setProperty('href', EDIT_CORE.JSSiteRoot+'site/pages/download.php?filnavn='+pic_org_path+'&fc='+page_name+'('+(current_JS_img_ind + 1)+').jpg');
			var img_hold = bilde;
			var img_wraper = wraper;
			img_hold.setStyle('width', pic_width);
			img_hold.setStyle('height', pic_height);
			img_hold.setProperty('src', pic_src);
			img_wraper.setStyle('width', pic_width);
			SqueezeBox.resize({'x':pic_width + 0, 'y':pic_height + 24});
		});
		priev_pic.inject(controls_cont);
		next_pic.inject(controls_cont);
	}
	//var total_pic_text = new Element('span', {id:'total_img', styles:{'background-color':'#7bc6e2'}});
	//total_pic_text.set('html', '/'+total_pic);
	//var current_pic_text = new Element('span', {id:'current_img', styles:{'background-color':'#7bc6e2'}});
	//current_pic_text.set('html', (img_ind + 1));
	// assembling


	bilde_a.inject(controls_cont);
	pic_text_holder.inject(controls_cont);

	controls_cont.inject(wraper);
	SqueezeBox.fromParams({handler:'div', size:{x:pic_width + 0,y:pic_height + 24}, div_cont:wraper, divOptions:{styles:{overflow:'hidden'}}, onClose:function(){
		var bilde_f = bilde;
		var wraper_f = wraper;
		var c_img_flash = img_flash;
		delete bilde_f;
		delete wraper_f;
		//c_img_flash.start_auto_play();
	}});
}


window.addEvent('load', initPage);

function initPage(){
	var anim_delay = 4000;
	var _$YEAR_1975 = $$('#year-1975 div');
	_$YEAR_1975.setStyle('opacity', '1');
	_$YEAR_1975.set('tween', {duration: '3000', transition : 'sine:out'});
	_$YEAR_1975.tween.delay(anim_delay, _$YEAR_1975, ['opacity', '0']);
	var _$YEAR_2011 = $$('#year-2011 div');
	_$YEAR_2011.setStyle('opacity', '0');
	_$YEAR_2011.set('tween', {duration: '1200', transition : 'sine:in'});
	_$YEAR_2011.tween.delay(parseInt(anim_delay) + anim_delay/4, _$YEAR_2011, ['opacity', '1']);
}

/* anstat modul js */
var current_person_id = 0;
var pic_person_page_id = 0;
var visible_list = {};

function show_detailed_info($detail_dom, $person_id){
    var _person_details = null;
    if ((_person_details = $detail_dom.retrieve('detailed-info')) == null) $detail_dom.store('detailed-info', _person_details = $('person-details-'+ $person_id));
    if (current_person_id > 0){
        $('person-info-'+ current_person_id).store.delay(200, $('person-info-'+ current_person_id), ['visible', false]);
        $('person-details-'+ current_person_id).set('tween', {'duration': 200}).tween('height', '0');
        current_person_id = 0;
    }
    var _current_el_status = $detail_dom.retrieve('visible');
    if (!_current_el_status){
        if (_current_el_status == undefined){
            $('person-details-'+ $person_id).setStyle('display', 'block');
            _person_details.setStyle('height', 'auto');
            _person_details.store('org-height', _person_details.getSize().y);
            _person_details.setStyle('height', '0');
        }
        $detail_dom.store('visible', true);
        _person_details.set('tween', {'duration': 400}).tween('height', _person_details.retrieve('org-height')+'px');
        current_person_id = $person_id;
    }
}

function pick_arkiv_pic($person_page_id){
    pic_person_page_id = $person_page_id;
    var myIFrame = new IFrame({
        src: '../../site/arkiv/arkiv_gui.php?page_id='+EDIT_CORE.page_id,
        id: 'ark-pic-pick',
        width: 1,
        height: 1,
        styles: {
            visibility:'hidden',
            border:'none'
        },
        events: {
            mouseenter: function(){
                //alert('Welcome aboard.');
            },
            mouseleave: function(){
                //alert('Goodbye!');
            },
            load: function(){
                var ifr = $(this);
                var loader = $('loading_img');
                ifr.setProperty('width', 937);
                ifr.setProperty('height', 600);
                ifr.setStyle('height', 600);
                ifr.setStyle('overflow-y', 'scroll');
                //alert(ifr.setStyle);
                //ifr.setStyle('width', 912);
                ifr.setStyle('opacity', '0');
                ifr.setStyle('visibility', 'visible');
                ifr.fade('in');
                loader.dispose();
                $('div_wraper').setStyle('text-align', 'left');
                ifr.removeEvents('load');
                ARKIV_EVENTS.clearCallBacks();
                ARKIV_EVENTS.addCallback(save_new_pic);
            }
        }

    });
    var wraper = new Element('div', {id:'div_wraper', styles:{width:'937px', 'text-align':'center', 'overflow':'hidden'}});
    var bilde = new Element('img', {id:'loading_img', src: '../../site/pages/js_dialogs/images/circle_64x64.gif', styles: { width:"64px"}});
    myIFrame.inject(wraper);
    bilde.inject(wraper);
    SqueezeBox.fromParams({handler:'div', size:{x:960,y:610}, div_cont:wraper, divOptions:{styles:{overflow:'hidden'}}, onClose:function(){
        try{
        var bilde_f = bilde;
        var wraper_f = wraper;
        var ifr = myIFrame;
        delete ifr;
        delete bilde_f;
        delete wraper_f;
        }
        catch(e){
            console.log("catched..");
        }
    }});
}
