/* parse the entered query String */
function parseSearchQuery(theForm, message) {
	var queryValue = theForm.elements["query2"].value;
	var testValue = queryValue.replace(/ /g, "");
	if (testValue.length < 3) {
		alert(message);
		return (false);
	}
	theForm.elements["query"].value = queryValue;
	return (true);
}

/* print for forms */
function submitPrintForms() {
	if( document.forms.length > 0 ) {
		for( var i=0; i < document.forms.length; i++ ) {
			if( document.forms[i].enctype.indexOf('multipart') == -1 ) {
			var orgTarget = document.forms[i].target;
			var orgAction = document.forms[i].action;
			/* var orgEnctype = document.forms[i].enctype; */
			document.forms[i].target = 'submitFrame';
			document.forms[i].action = '/system/modules/de.scandio.phoenix.frontend.template.form/elements/remindFormData.jsp';
			/* document.forms[i].enctype = 'application/x-www-form-urlencoded'; */
			document.forms[i].submit();
			document.forms[i].target = orgTarget;
			document.forms[i].action = orgAction;
			/* document.forms[i].enctype = orgEnctype; */
			}
		}
	}
}

/* open the print version popup window */
function openPrintVersion() {
	var params = "print=true";
	submitPrintForms();
	if (document.location.search != "") {
		params = document.location.search + "&" + params;		
	} else {
		params = "?" + params;
	}
	window.open(document.location.pathname + params, "print", "width=700,height=750,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes");
	return;
}

/* open the imprint popup window */
function openImprint(imprintUri, pageUri, theLocale, site) {
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(imprintUri + pageUri, "imprint", "width=670,height=550,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

/* open the recommend page form popup window */
function openRecommendForm(recommendUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(recommendUri + pageUri, "recommend", "width=700,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
	return undefined;
}

/* open the recommend page form popup window */
function openLetterForm(letterUri, pageUri, theLocale, site) {	
	if (window.location.search != "") {
		pageUri += window.location.search;		
	}
	pageUri = encodeURIComponent(pageUri); 
	pageUri = "?__locale=" + theLocale + "&uri=" + pageUri + "&site=" + site;
	window.open(letterUri + pageUri, "contact", "width=670,height=700,dependent=yes,status=no,toolbar=no,location=no,scrollbars=yes,resizable=yes");
}

function openImgView(img, title, width, height) {

   var padding = (navigator.appName=="Microsoft Internet Explorer"?10:0);   
   var screenw = screen.availWidth;
   var screenh = screen.availHeight;
   var winw = (width + 15 + padding);
   var winh = (height + 15 + padding);
   var posx = (screenw / 2) - (winw / 2);
   var posy = (screenh / 2) - (winh / 2); 

   imgWin = window.open('', title, 'top='+posy+',left='+posx+',width='+width+',height='+height+',dependent=yes,status=no,toolbar=no,location=no,scrollbars=no,resizable=no');

   with (imgWin.document) {
      open();
      write('<HTML>');
      write(' <HEAD>');
      write(' <title>'+title+'</title>');
      write(' </HEAD>');
      write(' <BODY style="margin: 0px;" onLoad="self.focus();">');
      write(' <a href="" onClick="JavaScript:self.close()">');
      write(' <img src="' + img + '" alt="'+title+'" title="'+title+'" border="0"></a>');
      write(' </BODY>');
      write('</HTML>');
      close();
   }
} 