//Checking whether browser is the latest version of IE
function microtime (get_as_float) {
    var now = new Date().getTime() / 1000;
    var s = parseInt(now, 10); 
    return (get_as_float) ? now : (Math.round((now - s) * 1000) / 1000) + ' ' + s;
}
 
xmlhttp = new Array();
 
function check(link,loader,target,dospecial) {
	//alert(target);
	link = link+"&dump="+microtime()+"&target="+target;
	var obj = document.getElementById(target);
	
	try {
		//If yes, create object of XMLHttpRequest
		xmlhttp[target] = new ActiveXObject("Msxml2.XMLHTTP");
		
	} catch(e) {
		//IF not latest browser

		//Checking if browser is a old version of IE
		try {
			//If yes, create object of XMLHttpRequest
			xmlhttp[target] = new ActiveXObject("Microsoft.XMLHTTP");
			
		} catch(e) {
		
			//If not both, then it is a NON-IE Browser
			xmlhttp[target] = false;
		}
	}
	
	//Checking if browser is a non IE browser
	if(!xmlhttp[target] && typeof XMLHttpRequest != 'undefined') {
		//Creating an object of XMLHttpRequest in non-IE browsers
		xmlhttp[target] = new XMLHttpRequest();
	}

	if (dospecial == 2) {
		//alert('Special'+link);
		xmlhttp[target].open("POST", link, true); //Opens connection to the scriptpage using POST response method
		xmlhttp[target].setRequestHeader("Pragma", "no-cache"); 
		xmlhttp[target].setRequestHeader("Cache-Control", "must-revalidate"); 
		xmlhttp[target].setRequestHeader("If-Modified-Since", document.lastModified); 
		xmlhttp[target].setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); 
		if (document.getElementById(target+'options')) {
			var contents = document.getElementById(target+'options').value.split(",");
			for (var p=0;p<contents.length;p++) {
				if (document.getElementById(contents[p])) {
					var content = document.getElementById(contents[p]).value;
					if (p == 0) {
						var submitter = contents[p]+"="+content;
					} else {
						var submitter = submitter+"&"+contents[p]+"="+content;
					}
				}
			}
			
			// Daten endlich senden			
    		xmlhttp[target].send(submitter);
    		//alert(submitter);
		}
    } else {
    	//alert(link);
    	xmlhttp[target].open("GET", link); //Opens connection to the scriptpage using GET response method
    	xmlhttp[target].send(null);
    } xmlhttp[target].onreadystatechange = function() {
    	if (xmlhttp[target].readyState == 4 && xmlhttp[target].status == 200) {
			obj.innerHTML = xmlhttp[target].responseText;
			if (dospecial == 1) {
				transferorders();
			} if (target == 'overlaycontent' && document.getElementById('fadeinimages')) {
				startfadeinimages(document.getElementById('fadeinimages').value);
			} if (target == 'overlaycontent' && document.getElementById('calender')) {
				//alert('ajax/ajax.php?loadwidget='+document.getElementById('calenderinit').value);
				check('ajax/ajax.php?loadwidget='+document.getElementById('calenderinit').value,'','calender',0);
			}
		} else {
			if (loader != '') {
				obj.innerHTML = loader;
			}
		}
	}
}
