/**
 * @desc    kMagic JavaScript Library
 * @author  kubus media
 * @version 1.2
 * @package mnbs
 */

	/**
	 * @desc   Opens new window and set focus to it
	 * @param  url to open, name of window, options of windows
	 * @return void
	 */
	function openWindow( url, name, options) {
		var f = window.open( url, name, options);
		f.focus();
	}



	/**
	 * @desc   Opens addtional window for media player
	 * @param  url to open
	 * @return void
	 */
	function openInfo( url){
		openWindow( url, 'InfoWindow', 'scrollbars=1,resizable=1,menubar=0,toolbar=0,location=0,status=1,width=350,height=350');
	}



	/**
	 * @desc   Opens addtional window for picture preview
	 * @param  url to open
	 * @return void
	 */
	function openPicture( url){
		openWindow( url, 'picture', 'scrollbars=0,resizable=1,menubar=0,toolbar=0,location=0,status=0');
	}



	/**
	 * @desc   Updates preview in picture list
	 * @param  number of image, name of image, path of image
	 * @return void
	 */
	function updatePreviewIcon( num, name, path) {
		document.images['preview_' + num].src = path;
		document.forms['edit_form'].elements['listedit[pictures][' + num + ']'].value = name;

		var image_name = document.getElementById('image_name_' + num);
		image_name.innerHTML = name;
	}



	/**
	 * @desc   Updates preview in picture list from select menu
	 * @param  number of image, base_path of images
	 * @return void
	 */
	function updatePreviewIconSelect( num, base_path){
		var select_menu = document.forms['edit_form'].elements['listedit[pictures]'];

		if( select_menu.selectedIndex > -1){
			name = select_menu.options[select_menu.selectedIndex].value;
			updatePreviewIcon( num, name, base_path + name);
		}
	}