	var http_request = false;
	var Get_http_response;


function go_createopenid() {
	var obj = document.getElementById("status");
	obj.innerHTML="<b>Vent...</b>";
	var poststr = "mode=do_createopenid&nick="+document.opretform.login_open.value;
	makePOSTRequest('/js_files/ajax.php', poststr);
}

function go_poll(type) {

     var obj = document.getElementById("statuspoll");
     obj.innerHTML="<b>Vent...</b><br />";
     var poststr = "mode=do_pollnow";
     poststr +="&id="+document.votePollForm.id.value;
     poststr +="&vote="+type;

             makePOSTRequest('/js_files/ajax.php', poststr);


}

function go_pairopenid() {

	var poststr = "mode=do_pairopenid&nick="+document.pairform.login_open.value;
		poststr +="&password="+document.pairform.kode_open.value;
	
	var obj = document.getElementById("statuspair");
	obj.innerHTML="<b>Vent...</b>";
	
	makePOSTRequest('/js_files/ajax.php', poststr);

}

function go_login() {

var poststr = "mode=do_login_ajax&Owner="+document.loginform.login_owner.value;
poststr +="&pass="+document.loginform.login_pass.value;
poststr += "&autologin="+(document.forms["loginform"].autologin.checked ? 1 : 0);


	var obj = document.getElementById("content");
	obj.innerHTML="<b>Vent...</b>";

      makePOSTRequest('/js_files/ajax.php', poststr);

}


function giveforumrate(type,id,where) {

      var poststr ="mode=do_giveforumrate&what="+ type +"&id="+ id +"&where="+ where;

        //toggleLayer('inlaeg_'+ id);

      makePOSTRequest('/js_files/ajax.php', poststr);


 }

function changetheme() {

      var poststr ="mode=do_changetheme&type="+document.userEditForm.type.value; 

      makePOSTRequest('/js_files/ajax.php', poststr);
 }
 

function giverate() {

      var poststr ="mode=do_giveuserrate2&user="+document.form1.user.value +"&type="+document.form1.type.value; 

      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function getedittime(id) {

      var poststr ="mode=do_getedittime&id="+ id;
      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function getsmsbox() {

      var poststr ="mode=do_getsms";

      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function tilmeld(id) {

      var poststr = "traadid=" + id +
                    "&mode=tilmeld_ajax&what=forum";

      makePOSTRequest('/js_files/ajax.php', poststr);
 
 }
function editcomment(id,type) {

      var poststr = "commentid=" + id +"&mode=editcomment&type="+ type;

      makePOSTRequest('/js_files/ajax.php', poststr);

 }


function pckonf(id,content) {


      var poststr = "mode=conf_"+ id +"&data="+document.forms["pckonfig"].elements[content].value

      makePOSTRequest('/js_files/pckonf.php', poststr);

}

function pckonfchange(id,content,value) {


      var poststr = "mode=saveconf_"+ id +"&data="+value;

      makePOSTRequest('/js_files/pckonf.php', poststr);

}

function sendpckonf() {


      var poststr = "mode=savepckonf2";
      var form = document.forms["pckonfig"];
		for(var i = 0; i<form.length;i++) {
			if(form[i].type == "text") {
				if (form[i].tagName == "INPUT") {
					poststr += "&"+ form[i].name + "=" + form[i].value;
				}
			}
			if(form[i].type == "select-one") {
				if (form[i].tagName == "SELECT") {
					poststr += "&"+ form[i].name + "=" + form[i].value;
				}
			}			
		}
      
      
//	    poststr += "&sli="+(document.forms["pckonfig"].sli.checked ? 1 : 0);
//		poststr += "&watersys="+(document.forms["pckonfig"].watersys.checked ? 1 : 0);
//alert(poststr);
      makePOSTRequest('/js_files/pckonf.php', poststr);
}

function freepckonf() {


      var poststr = "mode=freepckonf";

      makePOSTRequest('/js_files/pckonf.php', poststr);
}

function newnick() {

      var poststr = "name="+document.new_nick.name.value+"&mode="+document.new_nick.mode.value ;

      makePOSTRequest('/sms/send.php', poststr);

 }

function newtile() {

      var poststr = "name="+document.new_title.name.value+"&mode="+document.new_title.mode.value ;

      makePOSTRequest('/sms/send.php', poststr);

 }


function donatefn() {

      var poststr = "donate_pris="+document.donate.donate_pris.value+"&mode="+document.donate.mode.value ;
      makePOSTRequest('/sms/send.php', poststr);

 }

function removecoment(id) {
	if(confirm('Vil du slette indlęg') == true) {
	      var poststr = "removecoment="+id+"&mode=do_removecomment";
	      makePOSTRequest('/js_files/ajax.php', poststr);
	}
}

function removecasemod(id) {
        if(confirm('Vil du slette dit casemod') == true) {
              var poststr = "removecasemod="+id+"&mode=do_removecasemod";
              makePOSTRequest('/js_files/ajax.php', poststr);
        }
}

function removeimage(image,casemod) {

        if(confirm('Vil du slette billedet') == true) {
              var poststr = "removeimage="+image+"&mode=do_removeimage&casemod_id="+casemod;
              makePOSTRequest('/js_files/ajax.php', poststr);
        }

}


//javascript:removeimage('1195826589', '12');
function donecasemod() {

	var poststr = "mode=do_editcasemod&casemod_name="+ document.editcasemodform.casemod_name.value ;
	poststr += "&casemod_time="+ document.editcasemodform.casemod_time.value +"&casemod_price="+ document.editcasemodform.casemod_price.value;
	poststr += "&casemod_teaser="+ document.editcasemodform.casemod_teaser.value;
	poststr += "&casemod_category=0";
        poststr += "&casemod_status=1";
	poststr += "&casemod_id="+ document.editcasemodform.casemod_id.value;

      makePOSTRequest('/js_files/ajax.php', poststr);

 }

function casemod_comment() {

        var poststr = "mode=do_addcasemodcomment&comment="+ document.comment.besked.value;
        poststr += "&casemod_id="+ document.comment.casemod_id.value;

      makePOSTRequest('/js_files/ajax.php', poststr);
}

function thumbset(type,id) {

      var poststr ="mode=do_setthumb&what="+ type +"&id="+ id ;

      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function ratemod(id,type) {

      var poststr ="mode=do_ratecasemod&vote="+ type +"&casemod_id="+ id ;

      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function casemodstat(id,type) {

      var poststr ="mode=do_casemodstat&what="+ type +"&id="+ id ;

      makePOSTRequest('/js_files/ajax.php', poststr);
 }

function saveworklog() {

var poststr = "mode=do_saveworklog";
poststr += "&worklog="+ escape(document.editcasemodform.worklog.value);
poststr += "&casemod_id="+ document.editcasemodform.casemod_id.value;


//var poststr ="test";
makePOSTRequest('/js_files/ajax.php', poststr);

 }
function showcasemod(id) {
 saveworklog();
 setTimeout("window.location='/casemods/vis/"+id+"/'",500);

}

function closecasemod(id) {
 saveworklog();
 setTimeout("window.location='/my_mods.php'",500);

}

function worklog() {
 editcasemod();
 setTimeout("window.location='/worklog.php?id='+ document.editcasemodform.casemod_id.value;",500);

}

function editcasemod() {

var poststr = "mode=do_editcasemod&casemod_name="+ escape(document.editcasemodform.casemod_name.value) ;
poststr += "&casemod_time="+ escape(document.editcasemodform.casemod_time.value);
poststr += "&casemod_price="+ escape(document.editcasemodform.casemod_price.value);
poststr += "&casemod_teaser="+ escape(document.editcasemodform.casemod_teaser.value);
poststr += "&casemod_category=0";
poststr += "&casemod_id="+ document.editcasemodform.casemod_id.value;
poststr += "&casemod_status=0";


//var poststr ="test";      
makePOSTRequest('/js_files/ajax.php', poststr);

 }


function mailtest() {

	var url="mode=mail_ajax&mail="+document.maillistform.mail.value +"&valg="+document.maillistform.valg.value;
      	makePOSTRequest('/js_files/ajax.php', url);

}


//--------------------------------------//
   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);
            process(http_request.responseText);

			} else {
            alert('There was a problem with the request.');
         }
      }
   }
   
   function get(obj) {
      var poststr = "mytextarea1=" + encodeURI( document.getElementById("mytextarea1").value ) +
                    "&mytextarea2=" + encodeURI( document.getElementById("mytextarea2").value );
      makePOSTRequest('post.php', poststr);
   }
   
function process(rsp) {

	setTimeout(rsp,100);

}
   

function makeRequest(url) {

                http_request = false;

                if (window.XMLHttpRequest) { // Mozilla, Safari,...
                    http_request = new XMLHttpRequest();
                    if (http_request.overrideMimeType) {
                        http_request.overrideMimeType('text/xml');
                    }
                } 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 an XMLHTTP instance");
                    return false;
                }

                http_request.onreadystatechange = alertContents;

                http_request.open('POST', url, true);
                http_request.send(null);

            }

            function alertContents() {

                if (http_request.readyState == 4) {
                    if (http_request.status == 200) {
			        //var obj = document.getElementById("content");
	                        process(http_request.responseText);

                    } else {
                        alert("There was a problem with the request.");
                    }
                }

            }


// show/hide layer.

function toggleLayer(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";

	}

	else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer].style;
		style2.display = style2.display? "":"block";
	}

	else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}


function hideLayer(whichLayer) {
        if (document.getElementById) {
                // this is the way the standards work
                var style2 = document.getElementById(whichLayer).style;
                style2.display = style2.display? "":"none";

        }

        else if (document.all) {
                // this is the way old msie versions work
                var style2 = document.all[whichLayer].style;
                style2.display = style2.display? "":"none";
q	        }

        else if (document.layers) {
                // this is the way nn4 works
                var style2 = document.layers[whichLayer].style;
                style2.display = style2.display? "":"none";
        }
}



        function popup(url,win_height,win_width) {
          pos_horizon = ((screen.width/2)-(win_width/2));
          pos_vertical = ((screen.height/2)-(win_height/2));
          window.open(url,"TW","width="+win_width+",height="+win_height+",top="+pos_vertical+",left="+pos_horizon);
        }
        function popupv2(url,name,win_height,win_width) {
          pos_horizon = ((screen.width/2)-(win_width/2));
          pos_vertical = ((screen.height/2)-(win_height/2));
          window.open(url,name,"resizable=yes,width="+win_width+",height="+win_height+",top="+pos_vertical+",left="+pos_horizon);
        }




function insertImage(imagename) {
    document.editcasemodform.worklog.value += '\n[img]' + imagename + '[/img]\n';
    document.editcasemodform.worklog.scrollTop = document.editcasemodform.worklog.scrollHeight;
    document.editcasemodform.worklog.focus();
}

function insertAtCursor(myField, myValue) {
  //IE support
  if (document.selection) {
    myField.focus();
    sel = document.selection.createRange();
    sel.text = myValue;
  }
  //MOZILLA/NETSCAPE support
  else if (myField.selectionStart || myField.selectionStart == '0') {
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    myField.value = myField.value.substring(0, startPos)
                  + myValue
                  + myField.value.substring(endPos, myField.value.length);
  } else {
    myField.value += myValue;
  }
}




function dosubmit(url) {
        //alert(document.getElementById('previewimg').src + url);
        //document.getElementById('previewimg').src = document.getElementById('previewimg').src + url;
	hideLayer('userfile');
        document.getElementById('wait').style.display='block';
        document.getElementById('imageUpload').submit();
}
