var loopAction = true;
var popupWindow;
var pmsDefaultUri="index,templateId=Folder_2FrenderDefault.jsp.html";
/* Open new window in the window with name 'popup_name' */
function openPopup(popup_name,popup_url,popup_with,popup_height,popup_left,popup_top,noScrollbars) {
	 if(loopAction){
		loopAction = false;
		if (popupWindow != null) {
	    	if (popupWindow.closed) {
	    		popupWindow =null;
	    	} else {
	        	popupWindow.close();
	        }
	    }
	if (!noScrollbars) {
		myScrollbars = "scrollbars=yes";
	} else if (noScrollbars) {
		myScrollbars = "scrollbars=no";
	}
	popupWindow = window.open(popup_url ,popup_name,"width=" + popup_with + ",height=" + popup_height + ",left=" + popup_left + ",top=" + popup_top+"toolbar=no,location=no,status=no,menubar=no,resizable=yes,"+myScrollbars);
		popupWindow.focus();
		loopAction = true;
	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}
function submitForm(formName,method,docId,cmsPath){
	 if(loopAction){
		if(document.forms[formName]){
			loopAction = false;
			if(method != "null" && docId != "null"){
				action_string = document.forms[formName].action;
				action_array = action_string.split("/");
				document.forms[formName].action=pmsDefaultUri+"?method="+method+"&action=/"+action_array[action_array.length-1]+"&oid="+docId+"&cmspath="+cmsPath;
			}
			if(document.forms[formName].elements['method']){
				document.forms[formName].elements['method'].value = method;
			}
			if(document.forms[formName].elements['oid']){
				document.forms[formName].elements['oid'].value = docId;
			}
			document.forms[formName].submit();
		}
	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}
function confirmForm(formName,method,docId,cmsPath,confirmText){
	 if(loopAction){
		loopAction = false;
		check = confirm(confirmText);
		if(check != false) {

			if(document.forms[formName]){

				if(method != "null" && docId != "null"){
					action_string = document.forms[formName].action;
					action_array = action_string.split("/");
					document.forms[formName].action=pmsDefaultUri+"?method="+method+"&action=/"+action_array[action_array.length-1]+"&oid="+docId+"&cmspath="+cmsPath;
				}
				if(document.forms[formName].elements['method']){
					document.forms[formName].elements['method'].value = method;
				}
				if(document.forms[formName].elements['oid']){
					document.forms[formName].elements['oid'].value = docId;
				}
				document.forms[formName].submit();
			}

		} else {
			loopAction = true;
		}
	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}
function openUrl(url){
	 if(loopAction == true){
		loopAction = false;
		if(url.search(pmsDefaultUri) == -1){
			location.href=pmsDefaultUri + url;
		}else {	
			location.href= url;
		}

	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}
function openDirectUrl(url){
	 if(loopAction == true){
		loopAction = false;
		location.href= url;
		loopAction = true;
	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}

function resetForm(formName){
 	if(loopAction){

		if(document.forms[formName]){
			loopAction = false;
			document.forms[formName].reset();
			loopAction = true;
		}

	}else {
		alert('Bitte warten Sie auf die Beendigung der Aktion.');
	}
}