function open_img_big(img, pic_width, pic_height, pic_path, org_path, title){	
	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"}});		
	bilde.inject(wraper);		
		
	var pic_title = new Element('div', {id:'img_text', 'class':'text', styles:{'color':'#fff', 'padding': '0px 3px;'}})
	pic_title.set('html', title);	
		
	var bilde_a = new Element('a', {'class':"hand_hover text", styles:{'background-color':'#980505', 'color':'#fff', 'float':'right', 'width': '70', 'line-height':'16px', 'padding':'2px 4px', 'margin-left':'5'}, href:EDIT_CORE.JSSiteRoot+'site/pages/download.php?filnavn='+org_path+'&fc='+title+'.jpg', target:"_blank"});		
	bilde_a.set('html', 'Last ned');
	
	var controls_cont = new Element('div', {id:'controls_cont', styles:{'background-color':'#640a01', 'text-align': 'left', 'height': '40', 'margin-top': '3', 'line-height':'20px'}});	
	controls_cont.inject(wraper);		
	bilde_a.inject(controls_cont);
	pic_title.inject(controls_cont);
	
	
	
	
	SqueezeBox.fromParams({handler:'div', size:{x:pic_width+0,y:pic_height+44}, 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;		
	}});
}


/*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;		
	}});	
}        */
var current_JS_img_ind = -1;
var flash_fade_id = 'flash_holder';
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':'#980505', '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':'#980505', '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':'#980505', '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 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});
	});
	
	//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
	var controls_cont = new Element('div', {id:'controls_cont', styles:{'background-color':'#640a01', 'text-align': 'center', 'height': '20', 'margin-top': '3', 'line-height':'20px'}});	
	priev_pic.inject(controls_cont);	
	//current_pic_text.inject(controls_cont);
	//total_pic_text.inject(controls_cont);       
	next_pic.inject(controls_cont);       
	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();
	}});
}

