<!--

/*
+ ----------------------------------------------------------------------------+
|     **************** SHILKA.net ****************
|     APPLICATION NAME: e107
|     APPLICATION SUBVERSION: e107 Plugin
|     APPLICATION DESCRIPTION: SHILKA.net Theme
+ ----------------------------------------------------------------------------+
|
+ ----------------------------------------------------------------------------+
|     user.js created on 06.01.2009 by S h i L K a
+ ----------------------------------------------------------------------------+
|
+ ----------------------------------------------------------------------------+
| Generated by SVN 
+ ----------------------------------------------------------------------------+
|     $HeadURL: svn://shilka-net-subversion/sn-repos/shilka.de/e107_files/user.js $
|     $Id: user.js 107 2009-10-01 07:15:44Z shilka $
|     $Revision: 107 $
|     $Date: 2009-10-01 09:15:44 +0200 (Do, 01 Okt 2009) $
|
|     $LastChangedDate: 2009-10-01 09:15:44 +0200 (Do, 01 Okt 2009) $
|     $LastChangedRevision: 107 $
|
|     $ Author: S h i L K a $
|     $ LastChangedBy: S h i L K a $
+----------------------------------------------------------------------------+
*/      
var http_request;



function MM_jumpMenu(targ,selObj,restore){ //v3.01
	if (selObj.options[selObj.selectedIndex].value != '0'){
		F1 = window.open("","Window1","width=1024,height=768,left=0,top=0");
		eval("F1.location='"+selObj.options[selObj.selectedIndex].value+"'");
		//if (restore) selObj.selectedIndex=0;
		selObj.selectedIndex=0;  //select the first entry again
	}
}




//function for shilka_theme plugin admin function
//{e_PLUGIN}shilka_theme/admin_config_2.php
function shilka_display_one_nav_conf_section(display_index){
	var z = '000';
	var hide_index = '';
	
	//UserClass edit
	var div_ucedit      = 'DIV_NAV_ID_';
	//URL edit
	var div_urledit     = 'DIV_NAVURL_ID_';
	//SubNAVI edit
	var div_subnaviedit = 'DIV_SUBNAVI_ID_';
	//Context edit
	var div_contextedit = 'DIV_CONTEXT_ID_';
	//dirs for section edit
	var div_dirssectionedit = 'DIV_DIRSSECTION_ID_';
	//hide ct edit
	var div_hidectedit = 'DIV_HIDE_CT_ID_';
	
	for (var i=1; i<11 ; i++) {
		//first hide all sections... 
		hide_index = right(z+i+'',3);
		document.getElementById( div_ucedit + hide_index          ).style.display  = 'none';
		document.getElementById( div_urledit + hide_index         ).style.display  = 'none'; 
		document.getElementById( div_subnaviedit + hide_index     ).style.display  = 'none';
		document.getElementById( div_contextedit + hide_index     ).style.display  = 'none';
		document.getElementById( div_dirssectionedit + hide_index ).style.display  = 'none';
		document.getElementById( div_hidectedit + hide_index      ).style.display  = 'none'; 
	}

	//then display only one section...
	document.getElementById( div_ucedit + display_index          ).style.display  = 'block';
	document.getElementById( div_urledit + display_index         ).style.display  = 'block'; 
	document.getElementById( div_subnaviedit + display_index     ).style.display  = 'block';
	document.getElementById( div_contextedit + display_index     ).style.display  = 'block';
	document.getElementById( div_dirssectionedit + display_index ).style.display  = 'block';
	document.getElementById( div_hidectedit + display_index      ).style.display  = 'block'; 
}


//function for shilka_theme plugin admin function
//{e_PLUGIN}shilka_theme/admin_config_2.php
function shilka_hide_all_nav_conf_sections(){
	var z = '000';
	var hide_index = '';
	
	//UserClass edit
	var div_ucedit      = 'DIV_NAV_ID_';
	//URL edit
	var div_urledit     = 'DIV_NAVURL_ID_';
	//SubNAVI edit
	var div_subnaviedit = 'DIV_SUBNAVI_ID_';
	//Context edit
	var div_contextedit = 'DIV_CONTEXT_ID_';
	//dirs for section edit
	var div_dirssectionedit = 'DIV_DIRSSECTION_ID_';
	//hide ct edit
	var div_hidectedit = 'DIV_HIDE_CT_ID_';
		
	for (var i=1; i<11 ; i++) {
		//first hide all sections... 
		hide_index = right(z+i+'',3);
		document.getElementById( div_ucedit + hide_index          ).style.display  = 'none';
		document.getElementById( div_urledit + hide_index         ).style.display  = 'none'; 
		document.getElementById( div_subnaviedit + hide_index     ).style.display  = 'none';
		document.getElementById( div_contextedit + hide_index     ).style.display  = 'none';
		document.getElementById( div_dirssectionedit + hide_index ).style.display  = 'none';
		document.getElementById( div_hidectedit + hide_index      ).style.display  = 'none'; 
	}
}


function shilka_restore_header_image(hi){
	var hID = 'ID_HEADER_BG_IMG' ;
	document.getElementById(hID).style.backgroundImage = 'url(' + hi + ')';
}


function shilka_set_header_image(hi){
	var hID = 'ID_HEADER_BG_IMG' ;
	document.getElementById(hID).style.backgroundImage = 'url(' + hi + ')';
}


function shilka_display_sub_navi(subnavi){
	var div_main    = 'DIV_SITE_SUB_NAVIGATION_';
	var div_default = 'DIV_SITE_SUB_NAVIGATION_DEFAULT';

	for (var i=1; i<11 ; i++) {
		document.getElementById( div_main + i ).style.display  = 'none';
	}
	
	document.getElementById( div_default        ).style.display  = 'none'; 
	document.getElementById( div_main + subnavi ).style.display  = 'block'; 
}


function shilka_show_sitetag(){
	var div_main    = 'DIV_SITE_SUB_NAVIGATION_';
	var div_default = 'DIV_SITE_SUB_NAVIGATION_DEFAULT';

	for (var i=1; i<11 ; i++) {
		document.getElementById( div_main + i ).style.display  = 'none';
	}
	document.getElementById( div_default  ).style.display  = 'block';
}


function na_change_img_src(name, nsdoc, rpath, preload){
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	if (name == '')
		return;
	if (img) {
		img.altsrc = img.src;
		img.src    = rpath;
	} 
}


function na_preload_img(){
	var img_list = na_preload_img.arguments;
	if (document.preloadlist == null) 
		document.preloadlist = new Array();
	var top = document.preloadlist.length;
	for (var i=0; i < img_list.length-1; i++) {
		document.preloadlist[top+i] = new Image;
		document.preloadlist[top+i].src = img_list[i+1];
	} 
}


function na_restore_img_src(name, nsdoc){
	var img = eval((navigator.appName.indexOf('Netscape', 0) != -1) ? nsdoc+'.'+name : 'document.all.'+name);
	if (name == '')
		return;
	if (img && img.altsrc) {
		img.src    = img.altsrc;
		img.altsrc = null;
	} 
}


/* SN WS RELATED SECTION */
function IDC(url, parameters){
	http_request = false;
  
    if (window.XMLHttpRequest) { // Mozilla, Safari,...
    	http_request = new XMLHttpRequest();
    	if (http_request.overrideMimeType){
    		// set type accordingly to anticipated content type
    		//http_request.overrideMimeType('text/xml');
    		http_request.overrideMimeType('text/html');
    	}
    } else if (window.ActiveXObject) { // IE
    	try {
    		http_request = new ActiveXObject('Msxml2.XMLHTTP');
    	} catch (e) {
    		try {
    			http_request = new ActiveXObject('Microsoft.XMLHTTP');
    		} catch (e) {}
    	}
    }
    
    if (!http_request){
    	alert('Cannot create XMLHTTP instance');
    	return false;
    }
    http_request.onreadystatechange = showIDC;
    http_request.open('GET', url + parameters, true);
    http_request.send(null);

    //ddrivetip(\"This DIV has a tip!\", \"none\")
}


/* show ID card */
function showIDC(){
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			result = http_request.responseText;
            //make sn custom alerts here...
			//alert(result);
			ddrivetip( result , 'none');
        
	        /*
	        if (trim(result+'') == 'sn_ws_send_tlpm_200') {
	        	//document.getElementById('sn_ws_status').value = '200';
	        	document.getElementById('sn_ws_status').innerHTML = '200';
	        	ddrivetip(\"This DIV has a tip!\", \"none\");
	        	alert('Tiny Little Private Message sent.');
	        	global_status = '200';
	        	//clear text input field
	        	document.getElementById('id_input_tlpm').value = '';
	        	
	        } else if (trim(result+'') == 'sn_ws_detach_200') {
	        	//document.getElementById('sn_ws_status').value = '200';
	        	document.getElementById('sn_ws_status').innerHTML = '200';
	        	alert('Community Center no longer detached.');
	        	global_status = '200';
	        	
	        } else {
	        	//general error ???
	        	//document.getElementById('sn_ws_status').value = '500';
	        	document.getElementById('sn_ws_status').innerHTML = '500';
	        	//alert('Could not dock in Community Center.');
	        	//global_status = '500';
	        }
	        */
        
	     } else {
	    	 //http ready state was not 200
	    	 document.getElementById('sn_ws_status').value = '500';
	    	 alert('There was a problem with the request.');
	     }
    }
}


/* Submit Tiny Little Private Message */
function Submit_TLPM(wsurl,from){
	var msg='';
	var parameters='';
	var x='';
	var from2 = '';
	from2 = from;
	
	msg = document.getElementById('id_input_tlpm').value;
	sendto = document.getElementById('id_select_user').value;
	//check whether a user has been selected
	if (trim(msg) != '') {
		if (sendto != '00'){
			msg = msg.replace(/\\?/g, '');
			msg = msg.replace(/=/g, '');
			// msg = msg.replace(/\\//g, '');
			// msg = msg.replace(/\\//g, '');
			msg = msg.replace(/\\/g, '');
			//from2 = from2.replace(/\\ö/g, '&ouml;');
				   			   		
			parameters = from + '&m=' + msg + '&t=' + sendto;
	   		//TODO: make this alert only visible to admins
	   		//alert(parameters);
			//send message
		   	makeRequest(wsurl, parameters);
		   	
		} else {
			//silence is golden
			//alert ('Ooops! No user selected.');
		}
	} else {
		//silence is golden
		//alert('Ooops! Message is empty.');
	}
}


function makeRequest(url, parameters) {
	http_request = false;
  
    if (window.XMLHttpRequest){ // Mozilla, Safari,...
    	http_request = new XMLHttpRequest();
    	if (http_request.overrideMimeType) {
    		// set type accordingly to anticipated content type
    		//http_request.overrideMimeType('text/xml');
    		http_request.overrideMimeType('text/html');
    	}
    } else if (window.ActiveXObject) { // IE
    	try {
    		http_request = new ActiveXObject('Msxml2.XMLHTTP');
    	} catch (e) {
    		try {
    			http_request = new ActiveXObject('Microsoft.XMLHTTP');
    		} catch (e) {}
    	}
    }
    if (!http_request) {
    	alert('Cannot create XMLHTTP instance');
    	return false;
    }
    http_request.onreadystatechange = alertContents;
  
	/*
	if (http_request.readyState == 4) {
		if (http_request.status == 200) {
	    	result = http_request.responseText;
	        document.getElementById('sn_ws_status').value = '200';
	        //alert(result);            
	     } else {
	     	document.getElementById('sn_ws_status').value = '500';
	        //alert('There was a problem with the request.');
	     }
	}
	*/
	  
	http_request.open('GET', url + parameters, true);
	http_request.send(null);
  
    //return global_status;
    //setTimeout('makeRequest(url, parameters)', 1000);
} 
   

//main function for ws calling and error handling
function alertContents(){
	
	if (http_request.readyState == 4){
		if (http_request.status == 200){
			result = http_request.responseText;
			//make sn custom alerts here...
			//alert(result);
			//sn_ws_send_tlpm_200
    
			//TLPM handling
			if (trim(result+'') == 'sn_ws_send_tlpm_200') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	//alert(result);
		    	alert('Tiny Little Private Message sent. :-)');
		    	global_status = '200';
		    	//clear text input field
		    	document.getElementById('id_input_tlpm').value = '';
		    
			} else if (trim(result+'') == 'sn_ws_send_tlpm_500') {
		        	//document.getElementById('sn_ws_status').value = '200';
		        	//document.getElementById('sn_ws_status').innerHTML = '200';
		        	//alert(result);
		        	alert('Error: Could not send Tiny Little Private Message. :-(');
		        	global_status = '500';
		        	//clear text input field
		        	document.getElementById('id_input_tlpm').value = '';
		    	
		    //SN WS RESET Community Center
		    } else if (trim(result+'') == 'sn_ws_communitycenter_reset_200') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	l = document.getElementById('id_hidden_e_CORE').value;
		    	lt = document.getElementById('id_hidden_e_CORE_link_text').value;
		    	
		    	document.getElementById('id_sn_ws_reset_OK').innerHTML = '<br />' + create_a_href(l,lt);
		    	alert('Community Center reset successful. :-)');
		    	global_status = '200';
		    	
		    } else if (trim(result+'') == 'sn_ws_communitycenter_reset_500') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	alert('Error: Community Center could no be reset. :-(');
		    	global_status = '500';
		    
		    //SN WS Detach Community Center
		    } else if (trim(result+'') == 'sn_ws_communitycenter_detach_200') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	alert('Community Center detached.');
		    	global_status = '200';
		    
		    } else if (trim(result+'') == 'sn_ws_communitycenter_detach_500') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	alert('Error: Community Center could not be detached. :-(');
		    	global_status = '500';
		    
		    } else if (trim(result+'') == 'sn_ws_enable_sn_pm_notification_500') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	alert('Error: PM notification could not be enabled. :-(');
		    	global_status = '500';

		    } else if (trim(result+'') == 'sn_ws_enable_sn_pm_notification_200') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	//('PM notification enabled.');
		    	global_status = '200';
		    	
		    } else if (trim(result+'') == 'sn_ws_disable_sn_pm_notification_500') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	alert('Error: PM notification could not be disabled. :-(');
		    	global_status = '500';
		    	
		    } else if (trim(result+'') == 'sn_ws_disable_sn_pm_notification_200') {
		    	//document.getElementById('sn_ws_status').value = '200';
		    	//document.getElementById('sn_ws_status').innerHTML = '200';
		    	//alert('PM notification disabled.');
		    	global_status = '200';
		    
		    } else {
		    	alert('Ooops! Something went wrong. :-(');
		    	global_status = '500';
		    	
		    	//general error ???
		    	//document.getElementById('sn_ws_status').value = '500';
		    	//document.getElementById('sn_ws_status').innerHTML = '500';
		    	//alert('Could not dock in Community Center.');
		    	//global_status = '500';
		    }
			
		} else {
			//general sn ws error occured
			document.getElementById('sn_ws_status').value = '500';
		    alert('Sorry. There was a problem with the request. :-(');
        }
	}
}  //end of function alertContents


function trim (x){
	return x.replace (/^\s+/, '').replace (/\s+$/, '');
}


function reloadOpener(){
	self.opener.location.reload();
   	setTimeout('reloadOpener()',1500);
}
   

function closePopup(){
	self.close();
   	setTimeout('self.close()',1000);
}


function check_sn_ws_status(){
	alert('field = ' + document.getElementById('sn_ws_status').value);
}  


function create_a_href(l,lt){
	return '<a class="button" alt="' + lt + '" title="' + lt + '" href="' + l + '">' + lt + '</a>';
}


function left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}


function right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}


// -->