// Check validity
//------------------------------------------------------------------------------------------------------------------------------------------#	
function check_form(form)
{
	return_boolean = true	
 obj = eval(form)
 for(i=0;i<obj.length;i++) {
  obj.elements[i].style.color = "black";
  field_name = obj.elements[i].name;
  if (field_name.indexOf("_ck") != -1) {
    if (obj.elements[i].value == "") {
      obj.elements[i].style.backgroundColor = "#FFCC00";
	  obj.elements[i].style.color = "black";
      return_boolean = false	  
    }
    else
    {
      obj.elements[i].style.backgroundColor = "white";
    }
  }
}
return return_boolean;
}

// Disable Errors
//------------------------------------------------------------------------------------------------------------------------------------------#	
var msg = "";
function killErrors(des,url,line) {
window.status=msg;
return true;
}

window.onerror = killErrors;

// Disable Copy
//------------------------------------------------------------------------------------------------------------------------------------------#	

//function disabletext(e){
//return false
//}

//function reEnable(){
//return true
//}


//document.onselectstart=new Function ("return false")


//if (window.sidebar){
//document.onmousedown=disabletext
//document.onclick=reEnable
//}

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      oldonload();
      func();
    }
  }
}

// Post request  AJAX
//------------------------------------------------------------------------------------------------------------------------------------------#	
  var http_request = false;
   function makePOSTRequest(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;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('status').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }

 
// submitOnce
//------------------------------------------------------------------------------------------------------------------------------------------#
function submitOnce() {

	document.registerform.submit.disabled=true;
}

// Messaging System Layer
//------------------------------------------------------------------------------------------------------------------------------------------#	
function displayMessage(url)
{
	messageObj.setSource(url);
	messageObj.setCssClassMessageBox(false);
	messageObj.setSize(350,180);
	messageObj.setShadowDivVisible(false);	// Enable shadow for these boxes
	messageObj.display();
}

function displayStaticMessage(messageContent,cssClass)
{
	messageObj.setHtmlContent(messageContent);
	messageObj.setSize(300,150);
	messageObj.setCssClassMessageBox(cssClass);
	messageObj.setSource(false);	// no html source since we want to use a static message here.
	messageObj.setShadowDivVisible(false);	// Disable shadow for these boxes	
	messageObj.display();
}

function closeMessage()
{
	messageObj.close();	
}

// Open Comentar Layer - News
//------------------------------------------------------------------------------------------------------------------------------------------#	
function openLayer1()
     {
     document.getElementById("layer1").style.display="block";
     }
function closeLayer1()
     {
     document.getElementById("layer1").style.display="none";
     }
	 
	 function openLayer2()
     {
     document.getElementById("layer2").style.display="block";
     }
function closeLayer2()
     {
     document.getElementById("layer2").style.display="none";
     }
	 
function closeMsgLayer()
     {
     document.getElementById("alertLayer").style.display="none";
     }
	 
// AJAX GET Form
//------------------------------------------------------------------------------------------------------------------------------------------#	
function init () {
	$('submit').onclick = function () {
		sendData();
	}
}
function showLoad () {
	$('load').style.display = 'block';
}
function showResponse (originalRequest) {
	var newData = originalRequest.responseText;
	$('load').style.display = 'none';
	
	$('status').innerHTML = newData;
	document.komentarform.kommentar_ck.value ='';
	show(false,'CommentLayer');
}

// Menu Funktionen
//------------------------------------------------------------------------------------------------------------------------------------------#	
function SwitchMenu(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

function SwitchMenu3(obj){
	if(document.getElementById){
	var el = document.getElementById(obj);
	var ar = document.getElementById("masterdiv3").getElementsByTagName("span"); 
		if(el.style.display != "block"){ 
			for (var i=0; i<ar.length; i++){
				if (ar[i].className=="submenu3")
				ar[i].style.display = "none";
			}
			el.style.display = "block";
		}else{
			el.style.display = "none";
		}
	}
}

// Check form
//------------------------------------------------------------------------------------------------------------------------------------------#	
function check_form(form)
{
	return_boolean = true	
 obj = eval(form)
 for(i=0;i<obj.length;i++) {
  obj.elements[i].style.color = "black";
  field_name = obj.elements[i].name;
  if (field_name.indexOf("_ck") != -1) {
    if (obj.elements[i].value == "") {
      obj.elements[i].style.backgroundColor = "#FFCC00";
	  obj.elements[i].style.color = "black";
      return_boolean = false	  
    }
    else
    {
      obj.elements[i].style.backgroundColor = "white";
    }
  }
}
return return_boolean;
}

// Spaces löschen
//------------------------------------------------------------------------------------------------------------------------------------------#	
function ignoreSpaces(string) {
var temp = "";
string = '' + string;
splitstring = string.split(" ");
for(i = 0; i < splitstring.length; i++)
temp += splitstring[i];
return temp;
}

// Disable Submit button
//------------------------------------------------------------------------------------------------------------------------------------------#	
function Disab (val) {

if(val=="1") 
{input_form.speichern.disabled=true
}
}

// Checkbox / Radio Open on Click
//------------------------------------------------------------------------------------------------------------------------------------------#	
var activeItem;
function showContent(checkObj){
        if(activeItem && activeItem!=checkObj){    // Close previous opened item
            document.getElementById(activeItem.value).style.display='none';    // The value of the checkbox matches the id of the div
            activeItem.checked=false;
        }
        var style='none';
        if(checkObj.checked)style='block';
        document.getElementById(checkObj.value).style.display=style;
        activeItem = checkObj;        
    }
	


// GetNickName AJAx
function getNickName(div_id,content_id) {
			subject_id = div_id;
			content = document.getElementById(content_id).value;
			http.open("GET", "../_config/_includes/_diverses/getnickname.php?content=" + escape(content), true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
}	
		
//HTTP REQUEST
	subject_id = '';
	function handleHttpResponse() {
		if (http.readyState == 4) {
			if (subject_id != '') {
				document.getElementById(subject_id).innerHTML = http.responseText;
			}
		}
	}
	function getHTTPObject() {
		var xmlhttp;
		/*@cc_on
		@if (@_jscript_version >= 5)
			try {
				xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (E) {
					xmlhttp = false;
				}
			}
		@else
		xmlhttp = false;
		@end @*/
		if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
			try {
				xmlhttp = new XMLHttpRequest();
			} catch (e) {
				xmlhttp = false;
			}
		}
		return xmlhttp;
	}
	var http = getHTTPObject(); // We create the HTTP Object
	
	
// Resize Textarea
function texareaResize(t) {
a = t.value.split('\n');
b=1;
for (x=0;x < a.length; x++) {
 if (a[x].length >= t.cols) b+= Math.floor(a[x].length/t.cols);
 }
b+= a.length;
if (b > t.rows) t.rows = b;
}


// CheckNick AJAx
function CheckNickAjax(div_id,content_id) {
			subject_id = div_id;
			content = document.getElementById(content_id).value;
			http.open("GET", "../_config/_includes/_diverses/checknick.php?content=" + escape(content), true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
}	

// CheckMailAjax AJAx
function CheckMailAjax(div_id,content_id) {
			subject_id = div_id;
			content = document.getElementById(content_id).value;
			http.open("GET", "../_config/_includes/_diverses/checkmail.php?content=" + escape(content), true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
}

// CheckPassLengtAjax AJAx
function CheckPassLengtAjax(div_id,content_id) {
			subject_id = div_id;
			content = document.getElementById(content_id).value;
			http.open("GET", "../_config/_includes/_diverses/checkpass.php?content=" + escape(content), true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
}

// CheckPassLengtAjax AJAx
function CheckCodeAjax(div_id,content_id) {
			subject_id = div_id;
			content = document.getElementById(content_id).value;
			http.open("GET", "../_config/_includes/_diverses/checkcode.php?content=" + escape(content), true);
			http.onreadystatechange = handleHttpResponse;
			http.send(null);
}

	
	
// Standard Java Funktionen
//------------------------------------------------------------------------------------------------------------------------------------------#	
function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
