function insert_pic(id){

      if(navigator.appName == 'Netscape'){
      
          if(document.getElementById('pic_'+id).style.visibility == 'visible'){
              document.getElementById('pic_'+id).style.visibility = 'collapse';
          }
          else{
              document.getElementById('pic_'+id).style.visibility = 'visible';
          }
          
      }else{
          if(document.getElementById('pic_'+id).style.display == 'block'){
              document.getElementById('pic_'+id).style.display = 'none';
          }
          else{
              document.getElementById('pic_'+id).style.display = 'block';
          }
      
      }

}



function countCharsComment(idtyp){
	
	
  
  comment = document.getElementById('u_text_' + idtyp).value;
  char_amount = comment.length;
  document.getElementById('char_' + idtyp).innerHTML = char_amount;
  //comment = document.getElementById('u_text_' + idtyp).value;
  //  char_amount = comment.length;
	
	//if(char_amount > 200){
	//	comment = comment.substr(0,200);
	//	document.getElementById('u_text_' + idtyp).value = comment;
	//	char_amount = 200;
	//}
	
	//char_amount = 200 - char_amount;
	//document.getElementById('char_' + idtyp).innerHTML = char_amount;
    
	
}


function comm_edit(id,typ){

    if(navigator.appName == 'Netscape'){
        fenster = window.open('http://www.bauportal24.com/rating/edit.php?id='+id+'&typ='+typ,'Kommentar bearbeiten','width=700,height=850,left=400,top=100');
        fenster.focus(); 
    }
    else{
        window.location.href = 'http://www.bauportal24.com/rating/edit.php?id='+id+'&typ='+typ;
    }
    
    
    
    document.getElementById('captcha_' + idtyp).value = '';

}


function del_comment(idtyp){

    document.getElementById('u_name_' + idtyp).value = '';
    document.getElementById('u_email_' + idtyp).value = '';
    //document.getElementById('u_rating').value = '';
    document.getElementById('u_title_' + idtyp).value = '';
    document.getElementById('u_text_' + idtyp).value = '';
    document.getElementById('captcha_' + idtyp).value = '';
    document.getElementById('char_' + idtyp).innerHTML = '0';
    
}

var idtyp_g = false;
function submit_edit(idtyp){
idtyp_g = idtyp;	
	 
   if(document.getElementById('u_notify_' + idtyp).checked){
		notify = '1';	
   }
   else{
	    notify = '0';
  }
   
   var poststr = 'http://www.bauportal24.com/rating/edit_comment.php?u_name='+ encodeURI(document.getElementById('u_name_' + idtyp).value)+'&u_email='+encodeURI(document.getElementById('u_email_' + idtyp).value)+'&u_rating='+encodeURI(document.getElementById('u_rating_' + idtyp).value)+'&u_title='+encodeURI(document.getElementById('u_title_' + idtyp).value)+'&u_text='+encodeURI(document.getElementById('u_text_' + idtyp).value)+'&obj_id='+encodeURI(document.getElementById('obj_id_' + idtyp).value)+'&typ='+encodeURI(document.getElementById('typ_' + idtyp).value)+'&id='+encodeURI(document.getElementById('id').value)+'&u_cat='+encodeURI(document.getElementById('u_cat_' + idtyp).value)+'&u_rel='+encodeURI(document.getElementById('u_rel_' + idtyp).value)+'&captcha='+encodeURI(document.getElementById('captcha_' + idtyp).value)+'&cid='+encodeURI(document.getElementById('cid_' + idtyp).value)+'&u_notify='+notify;
   
   document.getElementById('comm_out_' + idtyp).innerHTML = '<img src="http://www.bauportal24.com/rating/preloader.gif">';
   document.getElementById('captcha_' + idtyp).value = '';
    
   //alert(idtyp_g); 
   makeGETRequest(poststr, poststr);
    
   //document.getElementById('u_name_' + idtyp).value = '';
   //document.getElementById('u_email_' + idtyp).value = '';
   //document.getElementById('u_rating_' + idtyp).selectedIndex = 0;
   //document.getElementById('u_title_' + idtyp).value = '';
   //document.getElementById('u_text_' + idtyp).value = '';
   //document.getElementById('char_' + idtyp).innerHTML = '200';
           
}

function submit_comment(idtyp){
idtyp_g = idtyp;	
	 
   if(document.getElementById('u_notify_' + idtyp).checked){
		notify = '1';	
   }
   else{
	    notify = '0';
  }
   
   var poststr = 'http://www.bauportal24.com/rating/insert_comment.php?u_name='+ encodeURI(document.getElementById('u_name_' + idtyp).value)+'&u_email='+encodeURI(document.getElementById('u_email_' + idtyp).value)+'&u_rating='+encodeURI(document.getElementById('u_rating_' + idtyp).value)+'&u_title='+encodeURI(document.getElementById('u_title_' + idtyp).value)+'&u_text='+encodeURI(document.getElementById('u_text_' + idtyp).value)+'&obj_id='+encodeURI(document.getElementById('obj_id_' + idtyp).value)+'&typ='+encodeURI(document.getElementById('typ_' + idtyp).value)+'&url='+encodeURI(document.getElementById('url').value)+'&ip='+encodeURI(document.getElementById('ip').value)+'&u_cat='+encodeURI(document.getElementById('u_cat_' + idtyp).value)+'&u_rel='+encodeURI(document.getElementById('u_rel_' + idtyp).value)+'&captcha='+encodeURI(document.getElementById('captcha_' + idtyp).value)+'&cid='+encodeURI(document.getElementById('cid_' + idtyp).value)+'&u_notify='+notify+'&f_id='+encodeURI(document.getElementById('f_id_' + idtyp).value);
   
   
   document.getElementById('comm_out_' + idtyp).innerHTML = '<img src="http://www.bauportal24.com/rating/preloader.gif">';
	 
   //alert(idtyp_g); 
   makeGETRequest(poststr, poststr);
 
   //document.getElementById('u_name_' + idtyp).value = '';
   //document.getElementById('u_email_' + idtyp).value = '';
   //document.getElementById('u_rating_' + idtyp).selectedIndex = 0;
   //document.getElementById('u_title_' + idtyp).value = '';
   //document.getElementById('u_text_' + idtyp).value = '';
   //document.getElementById('char_' + idtyp).innerHTML = '200';
           
}

function makeGETRequest(url, parameters) {
    http_request = false;//falls die funktion mehrmals aufgerufen wird nochmal auf false setzen
    //überprüfen ob IE / mozilla safari opera etc und XMLhttprequest bzw XMLHttp laden
    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) {}
         }
    }
           
     //prüfen ob die entsprechende kompo geladen wurde
     if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
     }
     //rückgabefunktion definieren
     http_request.onreadystatechange = alertContents;
     //verbindung öffnen
     http_request.open('GET', url, true);
     //header senden
     //http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
     //http_request.setRequestHeader("Content-length", parameters.length);
     //http_request.setRequestHeader("Connection", "close");
     //parameter senden
     http_request.send(null);
     //fertig =)
}

              
function alertContents() {
    //wenn der request fertig ist
    if (http_request.readyState == 4) {
        //und erfolgreich war
        if (http_request.status == 200) {
               //ausgeben in einer messagebox
               //alert(http_request.responseText);
               document.getElementById('comm_out_' + idtyp_g).innerHTML = http_request.responseText;
			   //alert('Funktion wurde ausgeführt!');
        } else {
               alert('There was a problem with the request.');
        }
	}
}