/*
 *PrintFriendly.js
 *externe JavaScript Datei f?????????uer die Erstellung von print friendly page
*/
function Druck(url,printTitle,printThisPage,topic_content_1,postAReply,submittedByLabel,topic_owner,topic_created,topic_content_2){
	
	var Druckfenster = window.open('','Test','width=570,height=500,menubar=yes,scrollbars=yes');
	
	//var content = decodeURIComponent(topic_content_2);
	var new_content = URLDecode(topic_content_2);
	/*for(var i=0;i<content.length;i++){
		new_content += content.replace("+"," ");
	}*/
	Druckfenster.document.open("text/html");
	Druckfenster.document.write('<title>'+printTitle+'</title>'+
								'<link href="css/site_style.css" rel="stylesheet" type="text/css">'+
								'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
								'<tr>'+
									'<td colspan="4"><img src="images/space_10_10.gif" width="10" height="5"></td>'+
								'</tr>'+
								'<tr>'+
									'<td class="heading">'+topic_content_1+'</td>'+
									'<td><div align="right"><a href="#sendReplyForm" class="link03">'+postAReply+'</a></div></td>'+
								'</tr>'+
								'<tr>'+
									'<td>&nbsp;</td>'+
								'</tr>'+
								'<tr>'+
									'<td><span class="text01">'+submittedByLabel+'</span>'+
									' <span class="text01">'+topic_owner+'</span>'+
									'</td>'+
									'<td colspan="3"><div align="right" class="date">'+topic_created+'</div></td>'+
								'</tr>'+
								'</table>'+
								'<p class="text01">'+new_content+'</p>'+
								'<br />'+
								'<a href="javascript:window.print();">'+printThisPage+'</a>'
								);
	Druckfenster.document.close();
	
}
function DruckmitBild(url,printTitle,printThisPage,topic_content_1,postAReply,submittedByLabel,topic_owner,topic_created,topic_content_2){
	
	var Druckfenster = window.open('','Test','width=570,height=500,menubar=yes,scrollbars=yes');
	
	//var content = decodeURIComponent(topic_content_2);
	var new_content = URLDecode(topic_content_2);
	/*for(var i=0;i<content.length;i++){
		new_content += content.replace("+"," ");
	}*/
	Druckfenster.document.open("text/html");
	Druckfenster.document.write('<title>'+printTitle+'</title>'+
								'<link href="css/site_style.css" rel="stylesheet" type="text/css">'+
								'<table width="100%" border="0" cellspacing="0" cellpadding="0">'+
								'<tr>'+
									'<td colspan="4"><img src="images/space_10_10.gif" width="10" height="5"></td>'+
								'</tr>'+
								'<tr>'+
									'<td class="heading">'+topic_content_1+'</td>'+
									'<td><div align="right"><a href="#sendReplyForm" class="link03">'+postAReply+'</a></div></td>'+
								'</tr>'+
								'<tr>'+
									'<td>&nbsp;</td>'+
								'</tr>'+
								'<tr>'+
									'<td>'+
										'<img src="'+url+'"  name="documentImage" hspace="1" vspace="1"><br>'+
									'</td>'+
								'</tr>'+
								'<tr>'+
									'<td><span class="text01">'+submittedByLabel+'</span>'+
									' <span class="text01">'+topic_owner+'</span>'+
									'</td>'+
									'<td colspan="3"><div align="right" class="date">'+topic_created+'</div></td>'+
								'</tr>'+
								'</table>'+
								'<p class="text01">'+new_content+'</p>'+
								'<br />'+
								'<a href="javascript:window.print();">'+printThisPage+'</a>'
								);
	Druckfenster.document.close();
}

function URLDecode(string_en)
{
   // Replace + with ' '
   // Replace %xx with equivalent character
   // Put [ERROR] in output if %xx is invalid.
   var HEXCHARS = "0123456789ABCDEFabcdef"; 
   var encoded = string_en;
   var plaintext = "";
   var i = 0;
   while (i < encoded.length) {
       var ch = encoded.charAt(i);
	   if (ch == "+") {
	       plaintext += " ";
		   i++;
	   } else if (ch == "%") {
			if (i < (encoded.length-2) 
					&& HEXCHARS.indexOf(encoded.charAt(i+1)) != -1 
					&& HEXCHARS.indexOf(encoded.charAt(i+2)) != -1 ) {
				plaintext += unescape( encoded.substr(i,3) );
				i += 3;
			} else {
				alert( 'Bad escape combination near ...' + encoded.substr(i) );
				plaintext += "%[ERROR]";
				i++;
			}
		} else {
		   plaintext += ch;
		   i++;
		}
	} // while
   //document.URLForm.F1.value = plaintext;
   return plaintext;
};

function showConfirm(basic_url,nid,parent,confirmText){
	if(confirm(confirmText))
		document.location.href=""+basic_url+"&id="+nid+"&action=delete&detail="+parent+"";
}
function pulldown_sections(url,value)
{
	var newvalue = escape(value);
	var replacedurl = url.replace(/\Wselectedcatid\W\d+/g,"");
	var replacedurl = replacedurl.replace(/\Wselectedcatid\Wallcat/g,"");
    window.location.href = ""+replacedurl+"&selectedcatid="+newvalue+"";  
}


function clickCategory(elem) {
  clearSections(document.advancedsearchform.section);
  //alert(document.advancedsearchform.category.selectedIndex-1);
  if (document.advancedsearchform.category.selectedIndex != 0)
  populateSection(document.advancedsearchform.category.selectedIndex-1);
  document.advancedsearchform.section.selectedIndex = 0;
  return true;
}
function clearSections(elem) {  
  var i;
  for (i = elem.options.length - 1; i > 0; i--) elem.options[i] = null;
  elem.selectedIndex = 0;
}
function clearSelectionboxes() {
  document.direkt_einstieg.seite.options[document.direkt_einstieg.seite.length] = null;
  document.direkt_einstieg.zielgruppe.options[document.direkt_einstieg.zielgruppe.length] = null;
  document.direkt_einstieg.seite.selectedIndex = 0;
  document.direkt_einstieg.zielgruppe.selectedIndex = 0;
}
function populateSection(index) {
  for (var i = 0; i <= level2[index].length; i= i + 1) {
    if(i < level2[index].length){
      document.advancedsearchform.section.options[document.advancedsearchform.section.length] = new Option(level2[index][i]);
    }
    if (document.advancedsearchform.section.options[i].value != "allsec")
    document.advancedsearchform.section.options[i].value = secids[index][i-1];
    //alert("url: "+secids[index][i-1]);
  }
}