function $( objectId ) { return document.getElementById( objectId ); }

function imgOpen( imgPath, imgWidth, imgHeight, imgDescription ) {  // v4.01
  posLeft = (screen.width ) ? (screen.width -imgWidth )/2 : 0;
  posTop 	= (screen.height) ? (screen.height-imgHeight)/2 : 0;
	newWindow = window.open( "", "newWindow", "width=" + imgWidth + ",height=" + imgHeight + ",scrollbars=no,left=" + posLeft + ",top=" + posTop );
  newWindow.document.open();
  newWindow.document.write( '<html><title>' + imgDescription + '</title><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">' );
  newWindow.document.write( '<img src=\"' + imgPath + '\" width=' + imgWidth + ' height=' + imgHeight + ' border="0" alt=\"' + imgDescription + '\" title=\"' + imgDescription + '\" onClick="javascript:window.close()" style="cursor:pointer">' );
  newWindow.document.write( '</body></html>' );
  newWindow.document.close();
}

function imgSecured( imgPath, imgWidth, imgHeight, imgDescription ) {  // v4.01
	var margin = (document.all) ? 5 : 0;
	imgWidth  -= margin;
	imgHeight -= margin;
	posLeft    = (screen.width ) ? (screen.width -imgWidth )/2 : 0;
	posTop 		 = (screen.height) ? (screen.height-imgHeight)/2 : 0;
	newWindow  = window.open( "../lib/preview.php?image=" + imgPath + '&desc=' + imgDescription, "newWindow", "width=" + imgWidth + ",height=" + imgHeight + ",scrollbars=no,left=" + posLeft + ",top=" + posTop );
}

function libManager( Page, Ident, Width, Height ) {
	  posLeft 	 = (screen.width)  ? (screen.width -Width )/2 : 0;
	  posTop 		 = (screen.height) ? (screen.height-Height)/2 : 0;
	  newWindow  = window.open( Page + "?" + Ident, "Zarządzanie słownikiem", "width=" + Width + ",height=" + Height + ",scrollbars=yes,left=" + posLeft + ",top=" + posTop);
}

/**
 *
 * @access public
 * @return void
 **/
function rewriteSelect( SelectSrc, SelectDst ) {
	for ( i = SelectDst.options.length; i > 0; i-- )
		SelectDst.options[i] = null;
	var Text = "";
	for ( i = 1; i < SelectSrc.options.length; i++ ) {
		Text = SelectSrc.options[i].text;
		var p1 = Text.indexOf( '|' ) + 1;
		var p2 = Text.indexOf( '|', p1 ) - 1;
		Text = Text.substring( p1, p2 ) + "*";
		SelectDst.options[i] = new Option( Text, SelectSrc.options[i].value );
	}
	SelectDst.selectedIndex = SelectSrc.selectedIndex;
}

function aVoid( numer ){
}


function setCom( Value ) {
	document.getElementById( 'com' ).value = Value;
}

function doSubmit() {
	document.ctiform.submit();
}

function swfOpen( swfFile, swfWidth, swfHeight, swfMenu, swfTransparency ){
	posLeft = (screen.width ) ? (screen.width -swfWidth )/2 : 0;
  posTop 	= (screen.height) ? (screen.height-swfHeight)/2 : 0;

	newWindow = window.open( "", "newWindow", "width=" + swfWidth + ",height=" + swfHeight + ",scrollbars=no,left=" + posLeft + ",top=" + posTop );
  newWindow.document.open();
  newWindow.document.writeln( '<html><title>Podgląd animacji flash</title><script language="javascript" src="/skrypty/vx/scripts/flashobject.js" type="text/javascript"></script><body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.close()">' );
  newWindow.document.writeln( '<div id="flashObj"></div>' );
	newWindow.document.writeln( '<script language="javascript" type="text/javascript">' );
	newWindow.document.writeln( '// <![CDATA[' );
  newWindow.document.writeln( '   var flash = \'' + swfFile + '\';' );
  newWindow.document.writeln( '   var fo = new FlashObject( flash, "flashObj", "' + swfWidth + '", "' + swfHeight + '", "6", "#FFFFFF");' );
  newWindow.document.writeln( '   fo.addParam("menu", "' + swfMenu + '");' );
  newWindow.document.writeln( '   fo.addParam("wmode", "' + swfTransparency + '");' );
  newWindow.document.writeln( '   fo.write("flashObj");' );
	newWindow.document.writeln( '// ]]>' );
	newWindow.document.writeln( '</script>' );
  newWindow.document.write( '</body></html>' );
  newWindow.document.close();
}

function okno(url, imgWidth, imgHeight) {
	posLeft = (screen.width) ? (screen.width-imgWidth)/2 : 0;
	posTop = (screen.height) ? (screen.height-imgHeight)/2 : 0;
	var okno = window.open(url,'okno','width=' + imgWidth + ',height=' + imgHeight + ',resizable=no,scrollbars=yes,left='+posLeft+',top='+posTop);
}

function wndOpenNoScrollBars( Url, Width, Height) {
	posLeft = (screen.width ) ? (screen.width  - Width)/2 : 0;
	posTop  = (screen.height) ? (screen.height - Height)/2 : 0;
	var okno = window.open(Url, 'okno','width=' + Width + ',height=' + Height + ',resizable=no,scrollbars=no,left='+posLeft+',top='+posTop);
}

function BlurText(BoxName) { if (BoxName.value == '') { BoxName.value = BoxName.defaultValue; } }
function FocusText(BoxName){ if (BoxName.value == BoxName.defaultValue)	{	BoxName.value = '';	} }

function boxPanelHideShow() {
	if(document.getElementById("show1").style.display=='none') { document.getElementById("show1").style.display=''; }
	else { document.getElementById("show1").style.display='none'; }
}

function boxConfigHideShow() {
	if(document.getElementById("show2").style.display=='none') { document.getElementById("show2").style.display='';	}
	else { document.getElementById("show2").style.display='none'; }
}

function boxShowHide( id ) {
	if(document.getElementById( id ).style.display=='none') { document.getElementById( id ).style.display='';	}
	else { document.getElementById( id ).style.display='none'; }
}

function mcHideObject( objectId ) {
	var object = document.getElementById(objectId);
	if ( object == null ) return;
	object.style.display 		= 'none';
}

function mcShowObject( objectId ) {
	var object = document.getElementById(objectId);
	if ( object == null ) return;
	object.style.display 		= '';
}

function hideShowObject( objectId ) {
	var object = document.getElementById(objectId);
	if ( object == null ) return;
	if ( object.style.display == 'none' ) {
		mcShowObject( objectId );
	} else {
		mcHideObject( objectId );
	}
}

function changeState( objectId, parentObj ) {
	var object = document.getElementById(objectId);
	if ( object == null ) {
		alert( 'Nie ma takiego obiektu: ' + objectId );
		return;
	}
	if ( object.disabled == true ) return;
	object.checked = !object.checked;
}

function getSelectOption( select, option  ) {
	for ( iGSO = 0; iGSO < select.options.length; iGSO++ ) {
		if ( select.options[iGSO].value == option ) {
			return select.options[iGSO];
		}
	}
	return false;
}
