// flash-include-workaround ie7 active-x-sperre
function flashInclude( flv, height, width ) {
// JS-Initialising and Activating
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+width+'" height="'+height+'" id="choe" align="middle"><param name="allowScriptAccess" value="sameDomain"><param name="movie" value="movies/'+flv+'"><param name="quality" value="high"><param name="bgcolor" value="#ffffff"><embed src="movies/'+flv+'" quality="high" wmode="transparent" bgcolor="#ffffff" width="'+width+'" height="'+height+'" name="choe" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></object>');
}


// Escaping JS-Errors
function oe()
{
 return true;
}

window.onerror = oe;

// JS Print
function print()
{
 window.print();
}

// Pop-Up-Maker
function winopen( site, width, height, resz, scrlb )
{
	var y = ( Math.round( ( screen.availHeight-height ) / 2) );
	var x = ( Math.round( ( screen.availWidth-width ) / 2) );

	showWin = open(site,"x","width="+width+",height="+height+",top="+y+",left="+x+",scrollbars="+scrlb+",status=0,resizable="+resz+",location=0,menubar=0,toolbar=0,fullscreen=0");
 showWin.focus();
}

// Find selected span within text-element
function findSelection ( w )
{
 var agt = navigator.userAgent.toLowerCase();
 var txt = document.forms[0].elements[w];

	// IE6 or MOZ
	if ( agt.indexOf('msie 6') != -1 ) 
 { 
  // Initial Variables
  var pattern = escape( w.document.selection.createRange().text );
  
  // Is selection made?
  if ( pattern )
   return ( pattern );
  else
   return ("");
 }
 // Gecko-Based
 else if ( typeof txt.selectionStart != 'undefined' )
 { 
  var selLength = txt.textLength;
		var selStart = txt.selectionStart;
		var selEnd = txt.selectionEnd;  
	
  if ( selEnd == 1 || selEnd == 2 )
   selEnd=selLength;
  
		var t = ( txt.value ).substring( selStart, selEnd );

  return ( t );
 }
 else
 {
  alert( "Der HTML-Editor arbeitet unter den gängigen Browsern: Internet Explorer, Mozilla sowie Firefox" );
 }
}

// Replace original Text
function replace( STR, SRCH, SUBST )
{
 Split = STR.split( SRCH );
 Out = Split[0];

	for ( c=1; c<Split.length; c++ )
 {
  Out += SUBST + Split[c];
 }
 
 return Out;
}

function linkman( k, b )
{
 var agt = navigator.userAgent.toLowerCase();

	box = b;

	// IE6
	if ( agt.indexOf('msie') != -1 ) 
 {
	 selectd = unescape( findSelection( self ) );
 }
 else
 {
  selectd = unescape( findSelection( b ) );
 }

		if ( selectd.length > 0 )
  {
		 if ( selectd.charAt( selectd.length - 1 ) == ' ' )
   {
    selectd = selectd.substring( 0, selectd.length-1 );
   }

			if ( k == 'extern' )
   {
    l = prompt('Bitte Verlinkung in folgender Form: http://www.cafehoegl.de', 'http://www.');
    createLink();
   }
			else if ( k == 'email' )
   {
    l = prompt( 'Bitte E-Mail in folgender Form: info@cafehoegl.de' );
    createEmail();
   }
			else if ( k == 'bolder')
   {
    createBold();
   }
		}
  else
  {
   alert( unescape('Bitte erst ein Wort ausw%E4hlen!') )
  };
	}

// Create HREF
function createLink()
{
 frm = document.forms[0];

	if ( l && l != '' && l != 'undefined' && l != 'http://www.' )
 {
		linked = '<a href=\''+l+'\'>'+selectd+'</a>';

		with ( frm )
  {
			obj = elements[''+box+''];
			obj.value = replace( obj.value, selectd, linked );
		}
	}
}

// Create E.Mail
function createEmail()
{
 frm = document.forms[0];

	if ( l && l != '' && l != 'undefined' )
 {
		linked = '<a href=\'mailto:'+l+'\'>'+selectd+'</a>';

		with ( frm )
  {
			obj = elements[''+box+''];
			obj.value = replace( obj.value, selectd, linked );
		}
	}
}

// Create <b>
function createBold()
{
	frm = document.forms[0];

	linked = '<b>'+selectd+'</b>';

	with ( frm )
 {
		obj = elements[''+box+''];
		obj.value = replace( obj.value, selectd,linked );
	}
}