/* multiple onload events */
window.addOnloadEvent = function(addToOnload) {var oldOnload;if (window.onload) {oldOnload = window.onload;window.onload = function(){oldOnload();addToOnload();};} else {window.onload = addToOnload;}}
function hpm_toggle_ban_form(){
subject = document.getElementById('ban_subject');
mail = document.getElementById('ban_reason');
div = document.getElementById('ban_email_div');
check = document.getElementById('notifyUser');
if(mail.disabled == true){mail.disabled = false;subject.disabled = false;div.style.opacity='1';check.checked=true;}
else{mail.disabled = true;subject.disabled = true;div.style.opacity='0.5';check.checked=false;}
}
function hpm_spoiler(obj) {
var st = obj.getElementsByTagName('div')[2].style;
st.display = (st.display == 'none' || st.display == '') ? 'block' : 'none';
/*var stb = obj.getElementsByTagName('div')[0].style;
stb.borderWidth = (stb.borderWidth == '1px 1px 1px 1px' || stb.borderWidth == '') ? '1px 1px 0px 1px' : '1px 1px 1px 1px';*/
var sti = obj.getElementsByTagName('input')[0].getAttribute("class");
if(sti==null){
/*this means we are using the IE which doesn't know getAttribute("class")*/
sti = obj.getElementsByTagName('input')[0].getAttribute("className");
if(sti == 'hpm_spoiler_headinput hpm_spoiler_open') {obj.getElementsByTagName('input')[0].setAttribute("className", "hpm_spoiler_headinput hpm_spoiler_closed");};
if(sti == 'hpm_spoiler_headinput hpm_spoiler_closed') {obj.getElementsByTagName('input')[0].setAttribute("className", "hpm_spoiler_headinput hpm_spoiler_open");};
}
else{
if(sti == 'hpm_spoiler_headinput hpm_spoiler_open') {obj.getElementsByTagName('input')[0].setAttribute("class", "hpm_spoiler_headinput hpm_spoiler_closed");};
if(sti == 'hpm_spoiler_headinput hpm_spoiler_closed') {obj.getElementsByTagName('input')[0].setAttribute("class", "hpm_spoiler_headinput hpm_spoiler_open");};
}
}
var miranus_iconbar_textarea = new Array();
function miranus_add_iconbar_textarea(textid) {
miranus_iconbar_textarea.push(textid);
}
function togSub(element,link) {
try {
var timer;
var pagewidth = document.getElementById('pagewidth').offsetWidth;
var navheight = document.getElementById(element).offsetHeight;
var listleft = document.getElementById(element).offsetLeft;
var allEl = document.getElementById(element).getElementsByTagName("ul");
var el = document.getElementById(element);
if (allEl.length > 0)
{
var actEl = allEl[0];
if(actEl.className=='nav_open')
{ actEl.className='nav_close'; el.onclick = "window.location='"+link+"'; return false;"; }
else
{ actEl.className='nav_open';
el.onclick = "";
var actElWidth = actEl.offsetWidth;
var topstring = parseInt(navheight)+'px';
actEl.style.top = topstring;
actEl.style.zIndex = '99999';
if (listleft + actElWidth >= pagewidth)
{ actEl.style.right = '-1px'; }
else
{ actEl.style.left = '-1px';}
}
}
}
catch(err) {}
}
function insertVideoTag(){
vid = prompt('Enter the URL for the video. i.e \nMyVideo:\n\"http://www.myvideo.de/watch/6446450/Ball_Platzer_lol\" \n or Youtube\n\"http://www.youtube.com/watch?v=-3hWIplHVeE\"', "http://www.");
return returnTag('[Video]'+vid+'[/Video]');}
function miranus_current_iconbar_textarea() {
for(var i=0; i < miranus_iconbar_textarea.length; i++) {
if(document.getElementById(miranus_iconbar_textarea[i])) {
return document.getElementById(miranus_iconbar_textarea[i]);
}
}
return false;
}
function returnTag(inTag) {
insert(inTag,'');
}
function insert(aTag, eTag) {
/* Thanks to http://aktuell.de.selfhtml.org/tippstricks/javascript/bbcode/ */
var input = miranus_current_iconbar_textarea();
if(input==false) {
alert('No Textarea defined. Use this Javascript: miranus_add_iconbar_textarea(\'textarea_id\'); ');
return false;
}
var scrollTop = input.scrollTop;
var scrollLeft = input.scrollLeft;
input.focus();
if(typeof document.selection != 'undefined') {
var range = document.selection.createRange();
var insText = range.text;
range.text = aTag + insText + eTag;
range = document.selection.createRange();
if (insText.length == 0) {
range.move('character', -eTag.length);
} else {
range.moveStart('character', aTag.length + insText.length + eTag.length);
}
range.select();
} else if(typeof input.selectionStart != 'undefined') {
var start = input.selectionStart;
var end = input.selectionEnd;
var insText = input.value.substring(start, end);
input.value = input.value.substr(0, start) + aTag + insText + eTag + input.value.substr(end);
var pos;
if (insText.length == 0) {
pos = start + aTag.length;
} else {
pos = start + aTag.length + insText.length + eTag.length;
}
input.selectionStart = pos;
input.selectionEnd = pos;
} else {
input.value = input.value + aTag + eTag;
input.focus();
}
input.scrollTop = scrollTop;
input.scrollLeft = scrollLeft;
}
var hpm_loaded_js = new Array();
function miranus_load_js(jsuri, infooter) { /* Dynamisch weitere Javascript-Dateien zur Laufzeit nachladen */
if(!hpm_loaded_js[jsuri]) {
if(infooter) {
var appendto = document.getElementsByTagName("body")[0];
} else {
var appendto = document.getElementsByTagName("head")[0];
}
script = document.createElement('script');
script.type = 'text/javascript';
script.src = jsuri;
appendto.appendChild(script);
//alert(jsuri + ' wird jetzt geladen');
}
hpm_loaded_js[jsuri] = true;
return true;
}
function miranus_add_js(node,m_name) { /* Dynamisch Javascript zu einem Node hinzufügen */
var nodeid = node.getAttribute('id');
if( typeof nodeid != "string" || nodeid=="" ) {
nodeid = parseInt(Math.random()*10000);
node.setAttribute('id',nodeid);
}
//alert('node: ' + nodeid + ' mit funktion ' + m_name);
if(m_name=='search_username') {
if(miranus_load_js('/script_user.js')) {
setTimeout('miranus_add_js_search_username(\'' + nodeid + '\')', 100)
}
}
else return false;
}
function hpm_newDialog(url,width,height, formName){
if(width.indexOf('px')==-1 && width.indexOf('%')==-1){width= width+'px';}
hpm_dialogwidth = width;
return hpm_openDialog(url, formName);
}
function hpm_handleResponse() { /** Ajax Dialog anzeigen **/
if(hpm_request.readyState == 4){
/** disable page scrolling **/
if(document.documentElement && document.documentElement.scrollTop){
var oTop = document.documentElement.scrollTop;
document.documentElement.scroll = "no";
document.documentElement.style.overflow = "hidden";
document.documentElement.scrollTop = oTop;
}
else if(document.body){
var oTop = document.body.scrollTop;
document.body.scroll = "no";
document.body.style.overflow = "hidden";
document.body.scrollTop = oTop;
}
/** Get & Show Response **/
var response = hpm_request.responseText;
var hpm_dialogDiv = document.createElement("div");
hpm_dialogDiv.setAttribute('id','hpm_dialog_div');
document.body.appendChild(hpm_dialogDiv);
window.scrollTo(0, 0)
hpm_dialogDiv.innerHTML = response;
if(hpm_dialogwidth.indexOf('%') != -1){if(parseInt(hpm_dialogwidth) > 60){hpm_dialogwidth='60%';}}
document.getElementById('hpm_pagebody').style.width= hpm_dialogwidth;
if (navigator.appName != 'Microsoft Internet Explorer') {
document.getElementById('hpm_pagebody').style.maxHeight= getHeightMargin()+"px";
} else{
document.getElementById('hpm_pagebody').style.height= getHeightMargin()+"px";
}
document.getElementById('hpm_pagebody').style.overflow= "auto";
/* If Trigger some javascript - no active javascript in ajax-dialog */
if(document.getElementById('miranus_loadGMapScript')) {
setTimeout("miranus_loadGMapScript(document.getElementById('miranus_loadGMapScript').value, document.getElementById('miranus_loadGMapScript_api').value, document.getElementById('miranus_loadGMapScript_startX').value, document.getElementById('miranus_loadGMapScript_startY').value, parseInt(document.getElementById('miranus_loadGMapScript_startZoom').value) )",100);
}
}
}
function hpm_openDialog(url, formName) { /* Laden von url innerhalb eines Ajax Dialogs */
var params = '';
if(formName && document.forms[formName].elements) {
var formdata = miranus_getFormFields(formName);
params = '&' + miranus_js2post(formdata);
}
var params = 'openDialogRequest=true&last_location= ' + encodeURIComponent(location.href) + '&next_location=' + encodeURIComponent(url) + params;
hpm_closeDialog();
hpm_request.open('POST', url);
hpm_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
hpm_request.setRequestHeader("Content-length", params.length);
hpm_request.setRequestHeader("Connection", "close");
hpm_request.onreadystatechange = hpm_handleResponse;
hpm_request.send(params);
if(navigator.appName == "Microsoft Internet Explorer"){
event.returnValue = false
}
return false;
}
function hpm_closeDialog() {
if(document.getElementById('hpm_dialog_div')) {
document.body.removeChild(document.getElementById('hpm_dialog_div'));
}
/** Enable scrolling **/
if(document.documentElement) { /* && document.documentElement.scrollTop){ */
document.documentElement.scroll = "";
document.documentElement.style.overflow = "";
}
if(document.body){
document.body.scroll = "";
document.body.style.overflow = "";
}
}
var callback_flag = false;
var callback_function = '';
var hpm_upload_progress_link = '';
var hpm_upload_progress_show_elem = '';
var hpm_upload_http;
function hpm_upload_start_progress(progress_link, show_elem,callback) {
/* alert('init progress'); */
try{if(show_gallery){gallery_flag = true;}}catch(e){}
try{if(callback){callback_flag = true;callback_function=callback;}}catch(e){}
hpm_upload_progress_link = progress_link;
hpm_upload_progress_show_elem = show_elem;
hpm_upload_refresh_progress();
}
function hpm_upload_refresh_progress() {
/* gpm_request = null; */
/* hpm_request = hpm_createHttpRequestObject(); */
hpm_request.open('get', hpm_upload_progress_link);
hpm_request.onreadystatechange = hpm_upload_handle_progress_response;
hpm_request.send(null);
/* alert('request send: ' + hpm_upload_progress_link); */
}
function hpm_upload_handle_progress_response() {
if(hpm_request==null) {
alert('hpm_request = null');
return;
}
if(hpm_request.readyState == 4) {
var response = hpm_request.responseText;
/*alert('got response:' + response); */
if(response.length>0) {
var resp = eval('(' + response + ')');
var current = parseInt(resp['current']/1024) ;
var total = parseInt(resp['total']/1024);
var cur_percent = 100 * current / total;
if(total>0 && current>0) {
if(callback_flag){eval(callback_function+'('+cur_percent+');');}
else{document.getElementById(hpm_upload_progress_show_elem).innerHTML = '<img src="http://www.homepagemodules.de/img/blackline.gif" height=10 width="' + cur_percent + '" style="border:1px solid;padding-right:' + (100 - cur_percent) + 'px"><br>Status: ' + current + ' of' + total + ' KByte uploaded';}
}
if(total>20480){ document.getElementById(hpm_upload_progress_show_elem).innerHTML = document.getElementById(hpm_upload_progress_show_elem).innerHTML + '<br><br><br><b>Attention:</b> You have choose too many or too large images. There is a good chance we cannot upload all selected pictures at once. If you get an error message please check which pictures have been uploaded and retry the rest. Also note that uploading 20 MB will take up to 10 minutes - even with a fast DSL connection.';}
}
window.setTimeout("hpm_upload_refresh_progress()",600);
}
}
function getHeightMargin(){
if(window.innerHeight){
h = window.innerHeight;
b = (h - (h*0.2))
}
else if(document.body || navigator.appName == 'Microsoft Internet Explorer'){
h = document.body.clientHeight
b = (h -(h*0.3))
}
else {
h = document.documentElement.clientHeight;
b = (h - (h*0.2))
}
return parseInt(b);
}
function miranus_getFormFields(formName) {
/* Alle Formularfelder im Formular formName in ein Javascript Array holen */
var val = new Array();
var el = document.forms[formName].elements;
for(i=0;i<el.length;i++){
//checkbox,radiobox
if(el[i].type=="checkbox" || el[i].type=="radio"){
if(el[i].checked) val.push(new Array(el[i].name, el[i].value));
} else if(el[i].type=="text" && el[i].value!=""){
val.push(new Array(el[i].name, el[i].value));
} else if(el[i].type=="hidden" && el[i].value!=""){
val.push(new Array(el[i].name, el[i].value));
}//Sollte es weitere input typen geben, weiter mit else if
else {
// alert(el[i].name + "-Typ:" + el[i].type + " @ " + el[i].value + "\r\n");
}
}
return val;
}
function miranus_js2post(obj) {
var post_str = [];
if (typeof(obj) == 'array' || typeof(obj) == 'object') {
for (var n in obj) {
if(typeof(n) == 'array' || typeof(obj) == 'object') {
post_str.push(obj[n][0] + '=' + encodeURI(obj[n][1]));
// alert('new ' + obj[n][0] + ' equal ' + obj[n][1]);
}
}
}
return post_str.join('&');
}
/* OLD & bad
function miranus_js2post(obj,path,new_path) {
if (typeof(path) == 'undefined') var path=[];
if (typeof(new_path) != 'undefined') path.push(new_path);
var post_str = [];
if (typeof(obj) == 'array' || typeof(obj) == 'object') {
for (var n in obj) {
post_str.push(miranus_js2post(obj[n],path,n));
}
}
else if (typeof(obj) != 'function') {
var base = path.shift();
post_str.push(base + (path.length > 0 ? '[' + path.join('][') + ']' : '') + '=' + encodeURI(obj));
path.unshift(base);
}
path.pop();
return post_str.join('&');
}
*/
function hpm_createHttpRequestObject() {
var ro;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
ro = new ActiveXObject("Microsoft.XMLHTTP");
}else{
ro = new XMLHttpRequest();
}
return ro;
}
var hpm_request = hpm_createHttpRequestObject();
var hpm_dialogwidth = 800;
//var hpm_dialogheight = getHeightMargin();
function miranus_delete_integration(i_id,target_id){
miranus_load_js('/js/jquery.js');
var ich_will = window.confirm("Do you really want to delete this Tag?");
if(ich_will){
if(i_id > 0){
if(typeof(target_id) == 'undefined') {
var target_id = false;
}
$.ajax({
type: "POST",
url: '../integration_select.php',
data: {del:true,target_id:target_id,i_id:i_id},
success: function(result){
window.location.reload();
}
});
}
else {
alert('Cannot delete the Element with '+i_id);
}
}
}
function miranus_confirm_tag(name,redirect){
var c = window.confirm(name+" an dieser Stelle verlinken ?");
if(c){
document.UserForm.submit();
}
else {
document.UserForm.onsubmit() = false;
}
}
function chkName(name){
if(name==""){
$("#UserError").html("Bitte Name eingeben");
return false;
}
else {
$.ajax({
type:"POST",
url: "../listUser.php",
data: {chkUser:true,uname:name},
success: function(resp){
var user = eval('(' + resp + ')');
if(user['userid']>0){
return true;
erg = true;
//window.location.reload();
}
else {
$("#UserError").html("Name "+name+" nicht gefunden");
return false;
}
}
});
}
}
function showDivById(id){
document.getElementById(id).style.display='block';
}
function hideDivById(id){
document.getElementById(id).style.display='none';
}
function ValideEmail(email){
var lookup = "^[a-zA-Z0-9_\.\-]+@([a-zA-Z0-9\.\-]+)\.[a-z]{2,4}$";
var regexp = new RegExp(lookup);
return (regexp.test(email));
}
function conf_ban(){
var ok = window.confirm("Are you sure banning this user?");
return ok;
}
