/*@cc_on @if (@_win32 && @_jscript_version >= 5) if (!window.XMLHttpRequest)
window.XMLHttpRequest = function() { return new ActiveXObject('Microsoft.XMLHTTP') }
@end @*/

function xhr(method, url, data, cb, apply_para) {
  method = method.toLowerCase();
  var req;
  req = new XMLHttpRequest();
  req.open(method, url + (data && method == 'get' ? '?' + data : ''), true);
  req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  if (method == 'post') {
      req.setRequestHeader("Method", "POST " + url + " HTTP/1.1");
      req.setRequestHeader("Content-Length", data.length);
  }
  req.onreadystatechange = function() {
      if (req.readyState == 4 && req.status == 200) {
              if (cb) {
              cb.apply(null, [req].concat(apply_para));
          }
      }
  }
  req.send(data);
}
function uncheck(id){
	var Arr = id.split(',');
	for(i=0; i<Arr.length; i++){
    	if(document.getElementById(Arr[i]).checked == true) document.getElementById(Arr[i]).checked = false;
	}
	xhr('get','../hf/handyfinder.inc.php5','daten='+JSON(),shout);
	return true;
}
    function JSON() {
        //loadLoader();
        var formValues = '{';
        formValues = formValues + '\"' + document.getElementById("hersteller").name + '\":\"' + document.getElementById("hersteller").value + '\",';
        if (document.getElementById("gewicht").value != "") {
            formValues = formValues + '\"' + document.getElementById("gewicht").name + '\":\"' + document.getElementById("gewicht").value + '\",';
        }
        for (var i=0; i<document.getElementsByTagName('input').length; i++) with (document.getElementsByTagName('input')[i])
        {
            if (checked) {
                formValues = formValues + '\"' + name + '\":\"' + value + '\",';
            }
        }
        //unloadLoader();
        return formValues = formValues.substr(0,formValues.length-1) + '}';
    }
    function page(seite) {
        //loadLoader();
        var formValues = '{';
        formValues = formValues + '\"p\":\"' + seite + '\",';
        formValues = formValues + '\"' + document.getElementById("hersteller").name + '\":\"' + document.getElementById("hersteller").value + '\",';
        if (document.getElementById("gewicht").value != "") {
            formValues = formValues + '\"' + document.getElementById("gewicht").name + '\":\"' + document.getElementById("gewicht").value + '\",';
        }
        for (var i=0; i<document.getElementsByTagName('input').length; i++) with (document.getElementsByTagName('input')[i])
        {
            if (checked) {
                formValues = formValues + '\"' + name + '\":\"' + value + '\",';
            }
        }
        //unloadLoader();
        return formValues = formValues.substr(0,formValues.length-1) + '}';
    }
    function shout(req) {
        document.getElementById("hf").innerHTML = req.responseText;
    }
    function anker() {
        location.href='#page_margins';
    }

function loadLoader() {
  var WindowWidth = 0, WindowHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    WindowWidth = window.innerWidth;
    WindowHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    WindowWidth = document.documentElement.clientWidth;
    WindowHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    WindowWidth = document.body.clientWidth;
    WindowHeight = document.body.clientHeight;
  }
	loadDiv=document.createElement("div");
	loadDiv.className = "loadDivContainer";
	loadDiv.id = "loadDivContainer";
	loadDiv.style.position = 'absolute';
	loadDiv.style.top = 0;
	loadDiv.style.left = 0;
	loadDiv.style.width = WindowWidth;
	loadDiv.style.height = WindowHeight;
	loadDiv.style.filter = 'Alpha(opacity=50)';
	loadDiv.style.opacity = 0.5;
	loadDiv.style.background = '#000000';
	document.body.appendChild(loadDiv);

	imgLeft = WindowWidth / 2;
	imgTop = WindowHeight / 2.6;
	var img=document.createElement('IMG');
	img.id = 'loaderImg';
	img.src = '/img/layout/wait.gif';
	img.style.position = 'absolute';
	img.style.left=imgLeft;
	img.style.top=imgTop;
	document.body.appendChild(img);

}
function unloadLoader() {
  document.body.removeChild(document.getElementById('loadDivContainer'));
  document.body.removeChild(document.getElementById('loaderImg'));
}