/* ### Cabacos Default JS ### */

/* ### Glossar Funktionen ### */
var lastSelected;
var cab_lastGlossaryGUID;

function cab_gloss_delete(thisGUID) {
	if (thisGUID == undefined) { thisGUID = cab_lastGlossaryGUID; }
	window.open('/app/glossary/delGlossary.asp?guid=' + thisGUID, 'delGlossary', 'width=450,height=150,resizable=no,scrollbars=no,status=no');
}

function cab_gloss_edit(thisGUID) {
	if( thisGUID == undefined) { thisGUID = cab_lastGlossaryGUID; }
	window.open('/app/glossary/addGlossary.asp?guid=' + thisGUID, 'addGlossary', 'width=500,height=600,resizable=no,scrollbars=no,status=no');
}

function cab_isValidEmail(thisMailAddress) {
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(thisMailAddress)) { return true; } else { return false; }
}

function newGlossary() {
	window.open('/app/glossary/addGlossary.asp?addText=', 'addGlossary', 'width=500,height=600,resizable=no,scrollbars=no,status=no');
}

function checkGlossary() {
	try {
		aktSel = window.getSelection ? window.getSelection() : window.document.selection;
			
		try {
			if(aktSel.createRange().text.length > 0) {
				lastSelected = aktSel.createRange().text;
			} else {
				lastSelected = '';
			}
		} catch(e) {
			if(aktSel.toString().length > 0) {
				lastSelected = aktSel.toString()
			} else {
				lastSelected = '';
			}
		}
	} catch(ex) {  }
}

function resetAdminRights() {
	window.open('/admin/resetAdmin.asp', 'resetAdmin', 'width=450,height=180,resizable=no,scrollbars=no');
}

function openHelp(helpID) {
	if ((helpID != 0) && (helpID != "0")) { helpID = "?" + helpID; } else { helpID = ""; }
	window.open('/admin/Docs_Online/docs_de/index.html' + helpID, 'helpWindow', 'width=820,height=550,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no');
}

function openAbout() {
	window.open('/admin/about.asp', 'aboutWindow', 'width=550,height=380,status=no,toolbar=no,menubar=no,resizable=yes,scrollbars=no');
}

function checkWindow (Redakansicht) {
	var windowName = window.name;
	if (Redakansicht == 'false' && windowName.indexOf('RedakWindow') != -1) { OpenUserMode(-1); }
}

function OpenRedakMode(editor,newWindow) {
	if (newWindow == -1) {
		var windowName = window.name;
		if (windowName.indexOf('RedakWindow') == -1) {
			win1 = window.open(global_SessionMe + '?redak=1&editor=' + editor ,'RedakWindow' + global_SessionID,'width='+ (screen.availWidth-200) +',height=' + (screen.availheight - 200) + ',status=yes,resizable=yes');
			win1.moveTo(0,0);
			win1.resizeTo(screen.availWidth, screen.availheight);
			window.opener = null;
			window.close();
		} else {
			try {
				document.location.href = global_SessionMe + '?redak=1&editor=' + editor ;
			} catch(e) {  }
		}
	} else {
		try {
			document.location.href = global_SessionMe + '?redak=1&editor=' + editor ;
		} catch(e) {  }
	}
}

function OpenUserMode(newWindow) {
	if (newWindow == -1) {		
		win1 = window.open(global_SessionMe + '?redak=0','Userwindow' + global_SessionID,'');
		win1.moveTo(0,0);
		win1.resizeTo(screen.availWidth, screen.availheight);
		window.opener = null;
		top.frames.close();
	} else {
		try {
			document.location.href = global_SessionMe + '?redak=0';
		} catch(e) {  }
	}
}

function printMe(printType,link) {
	if (printType == 'app') {
		if (link == 'pdf') {
			document.getElementById('out_Content_pdf').value = document.getElementById('appContent').innerHTML;
			document.getElementById('out_Title_pdf').value = document.title;
			try { document.getElementById('out_add_Content_pdf').value = document.getElementById('add_appContent').innerHTML; }
			catch(e) {  }
			try { document.getElementById('out_Site_Content_pdf').value = document.getElementById('add_SiteContent').innerHTML; }
			catch(e) {  }
			document.getElementById('pdf_submit').submit();
		}
		
		if (link == 'print') {
			window.open('','PrinterWindow','width=600,height=700,left=0,top=0,resizable=yes,scrollbars=yes');
			document.getElementById('out_Content_print').value = document.getElementById('appContent').innerHTML;
			document.getElementById('out_Title_print').value = document.title;
			try { document.getElementById('out_Site_Content_print').value = document.getElementById('add_SiteContent').innerHTML; }
			catch(e) {  }
			try { document.getElementById('out_add_Content_print').value = document.getElementById('add_appContent').innerHTML; }
			catch(e) {  }
			document.getElementById('print_submit').target = 'PrinterWindow';
			document.getElementById('print_submit').submit();
		}
	} else {
		window.open(link,'PrinterWindow','width=600,height=700,left=0,top=0,resizable=yes,scrollbars=yes');
	}
}

function forwardMe(_el, _opt) { return tellAFriend(_el, _opt); }

function tellAFriend(_el, _opt) {
	_el = $(_el);
	if ((_opt.toLowerCase()).indexOf("width=") == -1) { _opt += ", width=550"; }
	if ((_opt.toLowerCase()).indexOf("height=") == -1) { _opt += ", height=450"; }
	if ((_opt.toLowerCase()).indexOf("resizable=") == -1) { _opt += ", resizable=no"; }
	if ((_opt.toLowerCase()).indexOf("scrollbars=") == -1) { _opt += ", scrollbars=no"; }
	if ((_opt.toLowerCase()).indexOf("status=") == -1) { _opt += ", status=no"; }
	if ((_opt.toLowerCase()).indexOf("location=") == -1) { _opt += ", location=no"; }
	if ((_opt.toLowerCase()).indexOf("menubar=") == -1) { _opt += ", menubar=no"; }
	if (_opt.indexOf(", ") == 0) { _opt = _opt.sub(", ", "", 1); }
	var __win_taf = window.open(_el.readAttribute("href"), "tell_a_friend", _opt);
	__win_taf.focus();
	return false;
}

function findAndReplace(myText, find, replace) {
    var result = myText.split(find).join(replace);
    return result;
}

function setIFrameHeight(thisIFrame) { 
   thisIFrame.style.height = thisIFrame.document.body.scrollHeight;
}

function setIFrameWidth(thisIFrame) { 
   thisIFrame.style.width = thisIFrame.document.body.scrollWidth;
}

/* Image PopUp */
// Set autoclose true to have the window close automatically
// Set autoclose false to allow multiple popup windows
var AutoClose = false;
// Do not edit below this line...
// ================================
if (parseInt(navigator.appVersion.charAt(0)) >= 4) {
	var isIE=(navigator.appName.indexOf("Microsoft") != -1) ? 1 : 0;
}
var optWindow='resizable=yes,scrollbars=no,width=700,height=700,left=100,top=100';

function popImage(imageURL, imageTitle) {
	imgWin = window.open('about:blank','popup',optWindow);
	with (imgWin.document){
		writeln('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">')
		writeln('<html><head><title>Loading...</title><style>body{margin:0px;}</style>');writeln('<sc'+'ript>');
		writeln('var isIE;');
		writeln('if (parseInt(navigator.appVersion.charAt(0))>=4){isIE=(navigator.appName.indexOf("Microsoft")!=-1)?1:0;}');
		writeln('function reSizeToImage(){');
		
		writeln('width=(document.images[0].width );');
		writeln('height=(document.images[0].height);');
		
		writeln('if (isIE){');
		writeln('window.resizeTo(100,100)')
		writeln('window.resizeTo(width+ 10,height+100-document.documentElement.clientHeight);}');
		writeln('else{');       
		writeln('window.innerWidth=width;');
		writeln('window.innerHeight=height;}}');
		writeln('function doTitle(){document.title="'+imageTitle+'";}');
		writeln('</sc'+'ript>');
		if (!AutoClose) writeln('</head><body bgcolor=000000 scroll="no" onload="reSizeToImage();doTitle();self.focus()">')
		else writeln('</head><body bgcolor=FFFFFF scroll="no" onload="reSizeToImage();doTitle();self.focus()" onblur="self.close()">');
		writeln('<div id="imgContainer" style="height:auto;"><img name="George" src='+imageURL+' style="display:block"></div></body></html>');
		close();		
	}
}

function encode(input) {
    hexOutput = "";
    for (i=0; i<input.length; i++) {
        hexOutput = hexOutput + Dec2Hex(input.charCodeAt(i));
    }
    return hexOutput;
}

function decode(input) {
    hexOutput = "";
    for (i=0; i<input.length; i=i+2) {
        hexOutput = hexOutput + String.fromCharCode(parseInt(input.slice(i,i+2),16));
    }
    return hexOutput;
}

function Dec2Hex(Decimal) {
    var hexChars = "0123456789ABCDEF";
    var a = Decimal % 16;
    var b = (Decimal - a)/16;
    hex = "" + hexChars.charAt(b) + hexChars.charAt(a);
    return hex;
}

//Funktionen fuer die Cabacos-Selectboxen Kategorien und Rubriken
var CabSelect_disMe;
function CabSelect_selectCats(myDiv) {
	if ($(myDiv).getStyle("visibility") == "visible") { CabSelect_hideMeReal(myDiv); } else {
		$(myDiv).setStyle({visibility: "visible", width: ($(myDiv.slice(0,myDiv.length-4) + "_Text").offsetWidth + "px")});
	}
	/*if(document.getElementById(myDiv).style.visibility == 'visible') {
		CabSelect_hideMeReal(myDiv);
	} else {
		document.getElementById(myDiv).style.visibility = 'visible';
		document.getElementById(myDiv).style.width = document.getElementById(myDiv.slice(0,myDiv.length-4) + '_Text').offsetWidth + 'px';
	}*/
}

function CabSelect_hideMe(myDiv) {
	CabSelect_disMe = window.setTimeout("CabSelect_hideMeReal('"+myDiv+"');",300);
}

function CabSelect_transferLangs(transferFrom) {
	transferFrom = transferFrom.slice(0,transferFrom.length-4)

	var CabSelect_inputStringRubs = new String;
	var CabSelect_inputStringRubsLong = new String;
	
	var cab_isHiddenField = '';
	try { cab_isHiddenField = document.getElementsByName(transferFrom)[0].type.toLowerCase(); }
	catch(e) { cab_isHiddenField = ''; }
	
	if (cab_isHiddenField == "hidden") {
		//wenn cab_selectbox_selectOnlyOne ausgewaehlt dann ist es ein hiddenfield und keine checkbox
		CabSelect_inputStringRubs = ',' + document.getElementsByName(transferFrom)[0].value;
		CabSelect_inputStringRubsLong = ', ' + document.getElementsByName(transferFrom)[0].title;
	} else {
		for (var i=0;i<document.getElementsByName(transferFrom).length;i++) {
			if (document.getElementsByName(transferFrom)[i].checked == true) {
				CabSelect_inputStringRubs = CabSelect_inputStringRubs + ',' + document.getElementsByName(transferFrom)[i].value;
				CabSelect_inputStringRubsLong = CabSelect_inputStringRubsLong + ', ' + document.getElementsByName(transferFrom)[i].title;
			}
		}
	}
    
	try {
		CabSelect_inputStringRubs = CabSelect_inputStringRubs.substring(1);
		CabSelect_inputStringRubsLong = CabSelect_inputStringRubsLong.substring(2);
	} catch(e) {  }
	/*document.getElementById(transferFrom + '_Text').value = CabSelect_inputStringRubsLong;
	document.getElementById(transferFrom + '_Value').value = CabSelect_inputStringRubs;*/
	$(transferFrom + "_Text").value = CabSelect_inputStringRubsLong;
	$(transferFrom + "_Value").value = CabSelect_inputStringRubs;
}

function CabSelect_hideMeReal(myDiv) {
	CabSelect_transferLangs(myDiv);
	/*document.getElementById(myDiv).style.visibility = 'hidden';*/
	$(myDiv).setStyle({visibility: "hidden"});
}

function getWindowWidth() { 
	if (window.innerWidth) {
		return window.innerWidth;
	} else if (document.body && document.body.offsetWidth) {
		return document.body.offsetWidth;
	} else {
		return 0;
	}
}

function getWindowHeight() {
	if (window.innerHeight) {
		return window.innerHeight;
	} else if (document.body && document.body.offsetHeight) {
		return document.body.offsetHeight;
	} else {
		return 0;
	}
}

function cab_selectUsers(initUsers, selectionType, targetField, sql, group_sql) {
	var group_sql_query = "";
	if(group_sql != undefined ){
		if(group_sql.length > 0){
			group_sql_query = "&group_sql=" + encode(group_sql);
		}
	}
	window.open("/app/incs/dialogs/userlist/userlist.asp?sql=" + encode(sql) + "&ul=" + encode(selectionType) + "&target=" + encode(targetField) + "&init=" + encode(initUsers) + group_sql_query, "Cab_UserSelect","height=270,width=400,resizable=no,scrollbars=no,menubar=no,location=no,dependent=no");
}

function itd_getFrame(FrameName) {
	function getSubFrames(Frame) {
		for (var i=0;Frame.frames.length;i++) {
			if (Frame.frames[i].name.toLowerCase() == FrameName.toLowerCase()) {
				return Frame.frames[i];
			} else if (Frame.frames[i].frames.length > 0) { 
				subFrame = getSubFrames(Frame.frames[i])
				if (subFrame) { return subFrame; }
			}
		}
	}
	
	theFrame = getSubFrames(top);
	if (theFrame) {
		return theFrame;
		//wenn man Frames per Document.getElementById nen IFrame holt dann kann man bei FF mit 
		//document.getElementById(FrameName).contentDocument
	} else {
		return undefined;
	}
}

//left corner wieder verschwinden lassen... notwendig wenn custom menus da sind
var lcHide; //Variable muss f. LeftCorner Definiert werden
function clearLcMenu() {
	window.clearTimeout(lcHide);
}
function hideLcMenu() {
	window.clearTimeout(lcHide);
	lcHide = window.setTimeout('doHideLcMenu()',500);
}
function doHideLcMenu() {
	/*$('Cab_leftCornerDiv').style.visibility = "hidden";*/
	$("Cab_leftCornerDiv").setStyle({visibility: "hidden"});
	try {
		//wenn keine Submenus wirft es Fehler 
		Cab_LeftCorner.hideSubMenus(); //die submenus
	} catch(e) {  }
}

function showLcMenu() {
	/*$('Cab_leftCornerDiv').style.visibility = "visible"*/
	$("Cab_leftCornerDiv").setStyle({visibility: "visible"});
}

/* ### handleforms ### */
function handleForms_setSelectValue(theForm, theFieldName, theValue) {
	for (i=0;i < document.forms[theForm].elements[theFieldName].length;i++) {
		if (document.forms[theForm].elements[theFieldName].options[i].value == theValue) {
			document.forms[theForm].elements[theFieldName].options[i].selected = true;
		}
	}
}

function isValidEmailAddress(param_address) {
	var acceptableChars = "abcdefghijklmnopqrstuvwxyz.-_@";
	
	if (param_address.length == 0) { return false; }
	
	emailParts = param_address.split("@");
	if (emailParts.length != 2) {
		return false;
	} else {
		if ((emailParts[0].length < 1) || (emailParts[1].length < 4)) { return false; }
		if (emailParts[0].charAt(0) == ".") { return false; }
		if (emailParts[1].indexOf(".") == -1) { return false; }

		var last2Chars = emailParts[1].substr((emailParts[1].length - 2), 2);
		if (last2Chars.indexOf(".") != -1) { return false; }
		if (emailParts[1].indexOf("_") != -1) { return false; }
	}
	
	for (var iLoopCounter = 0; iLoopCounter < param_address.length; iLoopCounter++) {
		var emailChar = (param_address.charAt(iLoopCounter)).toLowerCase();
		if ((acceptableChars.indexOf(emailChar) == -1) && isNaN(emailChar)) { return false; }
	}
	
	if (param_address.indexOf("..") != -1) { return false; }
	if (param_address.indexOf("@.") != -1) { return false; }
	
	return true;
}

function handleForms_refreshCaptcha(param_element) {
	var element = $(param_element);
	if (element == undefined) { return; }
	var now = new Date();
	var element_src = element.readAttribute("src");
	if (element_src.indexOf("?") == -1) { element_src = element_src + "?"; } else { element_src = element_src + "&"; }
	element.writeAttribute("src", (element_src + "x=" + now.toUTCString()));
}

function handleForms_checkForm(param_form) {
	var form_ok = true;

	$(param_form).getElements().each(function(param_element) {
				var splitted_name = param_element.readAttribute("name").split("_");
				var elements_value = param_element.getValue();
				if ((splitted_name.last()) && (splitted_name.first().toLowerCase() != "cabformcheck") && (splitted_name.first().toLowerCase() != "cabformorder")) {
					switch (splitted_name.last().toLowerCase()) {
						case "text":	if (elements_value == "") { form_ok = false; } break;
						case "datep":	if (!handleForms_isValidDate(elements_value)) { form_ok = false; } break;
						case "date":	if ((elements_value != "") && (!handleForms_isValidDate(elements_value))) { form_ok = false; } break;
						case "intp":	if ((elements_value == "") || isNaN(elements_value)) { form_ok = false; } break;
						case "int":		if ((elements_value != "") && (isNaN(elements_value))) { form_ok = false; } break;
						case "checked":	if (!param_element.checked) { form_ok = false; } break;
						case "emailp":	if (!isValidEmailAddress(elements_value)) { form_ok = false; } break;
						case "email":	if ((elements_value != "") && (!isValidEmailAddress(elements_value))) { form_ok = false; } break;
					}
					if (!form_ok) {
						var error_text = param_element.readAttribute("errortext");
						var error_element = $("CabFormCheck_" + param_element.identify());
						if (error_element) { error_text = error_element.getValue(); }
						if (error_text && (error_text != "")) { alert(error_text); }
						param_element.focus();
						param_element.select();
						throw $break;
					}
				} else if ((splitted_name.last()) && (splitted_name.first().toLowerCase() == "cabformcheck")) {
					var element_to_check = $(param_element.readAttribute("name").substring(13));
					if (element_to_check) {
						if(element_to_check.getValue() == "") {
							form_ok = false;
							if (param_element.getValue() != "") { alert(param_element.getValue()); }
							element_to_check.focus();
							element_to_check.select();
							throw $break;
						}
					}
				}
		  });
	
	return form_ok;
}

function handleForms_delFormfield(toDel) {
	$(toDel).value = '';
}
function HandleForms_leaveIt() {
	if(ChangeContent == true && justSaving == false) {
		event.returnValue = cls_166; //Achtung, ungespeicherte Änderungen gehen verloren!
	}
}

function handleForms_checkCheckbox(which, whichID) {
	try {
		if (which[whichID].disabled != true) {
			which[whichID].checked ? which[whichID].checked = false : which[whichID].checked = true;
		}
	} catch (e) {
		if (which[whichID].disabled != true) {
			which.checked ? which.checked = false : which.checked = true;
		}
	}
}

function handleForms_setReadOnly(whichForm) {
	for (i = 0; i < document.forms[whichForm].elements.length; i++) {
		if (document.forms[whichForm].elements[i].type == "text" || document.forms[whichForm].elements[i].type == "textarea") {
			document.forms[whichForm].elements[i].readonly = true;
		} else {
			document.forms[whichForm].elements[i].disabled = true;
		}
	}
}

function handleForms_isValidDate(dateStr) {
	
	//01. davorsetzen falls nur 5 Stellen (mm.jj) angegeben wurden
	if (dateStr.length == 7) { dateStr = '01.' + dateStr; }
	
	// Checks for the following valid date formats:
	// MM/YY
	// MM/DD/YY   MM/DD/YYYY   MM-DD-YY   MM-DD-YYYY
	// Also separates date into month, day, and year variables
	var datePat = /^(\d{1,2})(\/|.)(\d{1,2})\2(\d{4})$/;
	
	// To require a 4 digit year entry, use this line instead:
	// var datePat = /^(\d{1,2})(\/|-)(\d{1,2})\2(\d{4})$/;
	var matchArray = dateStr.match(datePat); // is the format ok?
	if (matchArray == null) {
		alert(cls_138); //Das Datum liegt nicht im Format tt.mm.jjjj vor
		return false;
	}
	day = matchArray[1]; // parse date into variables
	month = matchArray[3];
	year = matchArray[4];
	if (month < 1 || month > 12) { // check month range
		alert(cls_139); //Der Monat muß zwischen 1 und 12 liegen.
		return false;
	}
	if (day < 1 || day > 31) {
		alert(cls_140); //Der Tag muß zwischen 1 und 31 liegen.
		return false;
	}
	if ((month==4 || month==6 || month==9 || month==11) && day==31) {
		alert( cls_141 + " " + month+" " + cls_142); //Der Monat xy hat keine 31 Tage!
		return false;
	}
	if (month == 2) { // check for february 29th
		var isleap = (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0));
		if (day>29 || (day==29 && !isleap)) {
			alert(cls_143 + " " + year + " " + cls_144 + " " + day + " " + cls_145); //februar im Jahr xy hat keine 29 Tage
			return false;
		}
	}
	return true;  // date is valid
}

/*	SWFObject v2.0 <http://code.google.com/p/swfobject/>
	Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
	This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
*/
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();


/*
* Oeffnet Uploaddialog und liefert ein Array welches an der Position 0 den Pfad hat, unter welchem die Dateien abgespeichert wurden,
* und in den restlichen Positionen die GUIDs der Dateien.
* @param int maxFiles		maximale Anzahl von hochzuladenen Dateien
* @param string	destination Pfad, in welchem die Dateien gespeichert werden (falls leer dann const_MediaPfadAbsolut)
* @param boolean isRelative true falls relative Pfadangabe (nur relevant falls destination <> leer)
* @param boolean saveToDB	true falls Dateieninfos in Datenbank gespeichert werden sollen
* @param boolean doZipDialog true falls gefragt werden soll ob zip-dateien automatisch entpackt werden sollen
* @param string fileTypes	"|"-getrennte Dateiendungen, die zugelassen werden sollen
* @param int height			Fensterhoehe
* @param int width			Fensterbreite
* @param bool closeWindow	wenn true dann wird fenster nach upload geschlossen
* @return Array welches an der Position 0 den Pfad hat, unter welchem die Dateien abgespeichert wurden,
*		  und in den restlichen die Dateinamen (also GUIDs)
* @author -
*/
function cab_open_CabUploadDialog(maxFiles, destination, isRelative, saveToDB, doZipDialog, fileTypes, height, width, closeWindow) {
	//defaults setzen
	var local_maxFiles = 1;
	var local_destination = "";
	var local_isRelative = 0;
	var local_saveToDB = 0;
	var local_doZipDialog = 0;
	var local_fileTypes = "";
	var local_height = 250;
	var local_width = 450;
	var local_closeWindow = 0;
	//parameter checken
	if (maxFiles != undefined && maxFiles != "") {
		local_maxFiles = maxFiles;
	}
	if (destination != undefined && destination != "") {
		local_destination = destination;
	}
	if (isRelative != undefined && isRelative != "") {
		if (isRelative) { local_isRelative = 1 }
	}
	if (saveToDB != undefined && saveToDB != "") {
		local_saveToDB = saveToDB;
	}
	if (doZipDialog != undefined && doZipDialog != "") {
		if (doZipDialog) { local_doZipDialog = 1 }
	}
	if (fileTypes != undefined && fileTypes != "") {
		local_fileTypes = fileTypes;
	}
	if (height != undefined && height != "" && !isNaN(height)) {
		local_height = height;
	}
	if (width != undefined && width != "" && !isNaN(width)) {
		local_width = width;
	}
	if (closeWindow != undefined && closeWindow != "") {
		if (closeWindow) { local_closeWindow = 1 }
	}
	//window oeffnen
	var returnValue = eval(openDialog('/app/incs/dialogs/upload/default.asp?maxFile=' + local_maxFiles +
		'&dest=' + encode(local_destination) +
		'&isrel=' + local_isRelative +
		'&toDB=' + encode(local_saveToDB) +
		'&zip=' + local_doZipDialog +
		'&closeWindow=' + local_closeWindow +
		'&types=' + encode(local_fileTypes), local_width, local_height, '', '', cls_48654));
		
	//returnValue validieren
	if (typeof (returnValue) == typeof (Array())) {//geht bei ie - nich bei ff also try/catch
		try {
			returnValue.length;
		}
		catch (istWohlDochKeinArrayException) {
			return new Array();
		}
		return returnValue;
	}
	else {
		return new Array();
	}
}

function openDialog(URL, width, height,param1,param2,ModalTitle) {
        var t = this, ua = navigator.userAgent, i, nl, n, base;

		// Browser checks
		t.isOpera = window.opera && opera.buildNumber;
		t.isWebKit = /WebKit/.test(ua);
		t.isOldWebKit = t.isWebKit && !window.getSelection().getRangeAt;
		t.isIE = !t.isWebKit && !t.isOpera && (/MSIE/gi).test(ua) && (/Explorer/gi).test(navigator.appName);
		t.isIE6 = t.isIE && /MSIE [56]/.test(ua);
		t.isGecko = !t.isWebKit && /Gecko/.test(ua);
		t.isMac = ua.indexOf('Mac') != -1;
		t.win = window
		if (t.isIE6)
		{
			height = height + 40
			width = width + 5
		}
		return window.showModalDialog("/app/incs/modal/modal.asp?ModalTitle=" + ModalTitle + "&URL=" + encode(URL) ,window,"dialogHeight: " + height + "px; dialogWidth: " + width + "px; help: No; resizable:yes; scroll:yes; status: No;");		
}

function openDialogNoResize(URL, width, height,param1,param2,ModalTitle) {
	return showModalDialog("/app/incs/modal/modal.asp?ModalTitle=" + ModalTitle + "&URL=" + encode(URL) ,window,"dialogHeight: " + height + "px; dialogWidth: " + width + "px; dialogTop: ; dialogLeft: px; center: Yes; help: No; resizable:no; scroll:no; status: No;");
}

function cab_HTMLEncode(cab_tmpstr) {
	var cab_result = cab_sub_htmlEncode(cab_tmpstr,false,0);
	return cab_result;
}

function cab_sub_htmlEncode(source, display, tabs) {
	function special(source) 	{
		var result = '';
		for (var i = 0; i < source.length; i++) {
			var c = source.charAt(i);
			if (c < ' ' || c > '~') {
				c = '&#' + c.charCodeAt() + ';';
			}
			result += c;
		}
		return result;
	}
	
	function format(source) {
		// Use only integer part of tabs, and default to 4
		tabs = (tabs >= 0) ? Math.floor(tabs) : 4;
		
		// split along line breaks
		var lines = source.split(/\r\n|\r|\n/);
		
		// expand tabs
		for (var i = 0; i < lines.length; i++) {
			var line = lines[i];
			var newLine = '';
			for (var p = 0; p < line.length; p++) {
				var c = line.charAt(p);
				if (c === '\t') {
					var spaces = tabs - (newLine.length % tabs);
					for (var s = 0; s < spaces; s++) {
						newLine += ' ';
					}
				} else {
					newLine += c;
				}
			}
			// If a line starts or ends with a space, it evaporates in html
			// unless it's an nbsp.
			newLine = newLine.replace(/(^ )|( $)/g, '&nbsp;');
			lines[i] = newLine;
		}
		
		// re-join lines
		var result = lines.join('<br />');
		
		// break up contiguous blocks of spaces with non-breaking spaces
		result = result.replace(/  /g, ' &nbsp;');
		
		// tada!
		return result;
	}

	var result = source;
	// ampersands (&)
	result = result.replace(/\&/g,'&amp;');
	// less-thans (<)
	result = result.replace(/\</g,'&lt;');
	// greater-thans (>)
	result = result.replace(/\>/g,'&gt;');
	
	if (display) {
		// format for display
		result = format(result);
	} else {
		// Replace quotes if it isn't for display,
		// since it's probably going in an html attribute.
		result = result.replace(new RegExp('"','g'), '&quot;');
	}
	// special characters
	result = special(result);
	// tada!
	return result;
}
