
function str_replace(search, replace, subject) {
	return subject.split(search).join(replace);
}

function preview(w,h,d)
{
	
	var ausgabe = new Array();
	boxname = eval("document.artikel.druckfarbe");
	if(boxname.name == undefined)
	{
		for (i = 0; i < boxname.length; i++)
		{
			if (boxname[i].checked)
			{
				farbe = boxname[i].value;
			}			 		
		}
	}
	else
	{
		farbe = $('druckfarbe').value;
	}
		
	for(var x = 0; x < $('zeilencounter').value; x++)
	{
		var bsptext = $('bspText' + x).value;
		bsptext = Base64.encode(bsptext);
		
										
		if($('bold' + x).checked == true)
		{
			var weight = $('bold' + x).value;
		}
		else
		{
			var weight = 'normal';
		}
		if($('italic' + x).checked == true)
		{
			var fontstyle = $('italic' + x).value;
		}
		else
		{
			var fontstyle = 'normal';
		}
		
		radioname = eval("document.artikel.ausrichtung" + x);
		
		for (i = 0; i < radioname.length; i++)
		{
			if (radioname[i].checked)
			{
				pos = radioname[i].value;
			}			 		
		}
		
		
		var schriftart = $('schrift' + x).value;
		var fontsize = $('size' + x).value;		
		
		ausgabe[x] = bsptext + "|||" + farbe + "|||" + weight + "|||" + fontstyle + "|||" + pos + "|||"  + schriftart + "|||" + fontsize + "|||" + w + "|||" + h + "|||" + d;
	}
	
	ausgabeString = ausgabe.join("~~~~");
	
	
	
	
	
	var showPrev =
	{
		method: 'post',
		postBody: 'param=' + ausgabeString,
		onCreate: function() 
		{
               
               $('vorschau').innerHTML = '<img src="images/ajax_loader.gif" width="32" height="32" style="margin:auto;">';
               new Effect.Appear($('vorschau'), {duration:0.1});                      
        	},
		onComplete: function(response)
		{
			
			eval("var div = "+ response.responseText);
			
			if(div[0] != '')
			{	
				
				$('vorschau').style.display = 'none';
				$('vorschau').innerHTML = div[0] + '<div style="clear:both;"></div>';
				new Effect.Appear($('vorschau'), {duration:0.2});
				var Ergebnis = div[0].search(/Ihr Textmuster/);
				
				if(Ergebnis != -1)
				{
					document.forms.artikel.meldung_laenge.value = 1;
				}
				else
				{
					document.forms.artikel.meldung_laenge.value = 0;
				}
				$('vorschau').style.height = div[1] + 'px';
				
			}			
		}
	};
	new Ajax.Request('ajax_actions/preview2.php', showPrev);
}
function selectResult ()
{
	if(document.suche.search[0].checked == true)
	{
		window.open('http://www.google.com/custom?q=' + document.forms.suche.searchText.value, '_blank');
	}
	else if(document.suche.search[1].checked == true)
	{
		document.forms.suche.setAttribute("action", 'suche.html');
	}

}

