﻿
function getResult( id, url, f ) {
	if( f != "1" ){
		//
	}
	var xhr;
	try {
		xhr = new XMLHttpRequest();
	} catch (e) {
		var a = ['MSXML2.XMLHTTP.5.0', 'MSXML2.XMLHTTP.4.0','MSXML2.XMLHTTP.3.0', 'MSXML2.XMLHTTP', 'MICROSOFT.XMLHTTP.1.0', 'MICROSOFT.XMLHTTP.1', 'MICROSOFT.XMLHTTP'];
		for (var i = 0; i < a.length; i++) {
			try {
				xhr = new ActiveXObject(a[i]);
				break;
			} catch (e) {}
		}
	}
	
	if (xhr) {
		var data = encodeURIComponent(url);
		xhr.open("POST", url, true);
		xhr.onreadystatechange= function(){
				if (xhr.readyState==4 || xhr.readyState=="complete"){ 	
									
					if( f != "1" ){
						var t;
						var dur = 600;

						window.clearTimeout(t);
  						setDivInner( id,   xhr.responseText  );
 					}else{					
						
		 				if( ( getElement('msg_now').value !=  xhr.responseText ) || ( getElement('msg_now').value == "" ) ){
		 					setDivInner( id,   xhr.responseText  );
		 				}
		 				getElement('msg_now').value =  xhr.responseText;
 					}
 				}
			};    			

		xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); // set Header
		xhr.send(data);   
	}
}

function doGet(){

}
function doPost(){
	
}
function getMethod(){
	
}
function respond(){
	
}
function result(){
	
}
function getElement(namex){	
	if (document.getElementById){
		return document.getElementById(namex);	
	}else if (document.all){
		return document.all[namex];	
	}else{
		return null;
	}
}	
function setLoading( id, value ){
//	alert('');
	if( value == 'none' ){
		document.body.style.cursor = 'default';
	}else{
		document.body.style.cursor = 'wait';
	}	
	//setClass( 'content', 'show' );
	setPosIndicator()
	getElement( id ).style.display = value;
}
function setCursor( value ){
	document.body.style.cursor = value;		//default, wait
}
function setClass(id, c) {
	document.getElementById(id).className = c;
}
function setDivDisplay( id, d ){
	getElement( id ).style.display = d;
}
function setDivInner( id, v ){
	if( ( v != "" ) && ( id  != "" ) ){
		getElement( id ).innerHTML = v;		
	}
}
function setSrc( id, v ){
	getElement( id ).src =  v;
}
function setSleep(millisecondi){
	    var now = new Date();
	    var exitTime = now.getTime() + millisecondi;	
	    while(true){
	        	now = new Date();
	        	if(now.getTime() > exitTime) return;
	    }
	    return true;
}
function Now() {
	return (new Date()).getTime();
}

var indicator_top=null;
var indicator_left=null;
var indicator_position;

function setPosIndicatorTop(v){
 	indicator_top=v;	
 	return true;	
} 

function setPosIndicatorLeft(v){
 	indicator_left=v;
 	//indicator_left = (document.documentElement.clientWidth/2) - indicator_left;
 	return true;		
} 

function setPosIndicatorPosition(v){
 	indicator_position=v;	
	return true; 	
} 

function setPosIndicator(){
	if(indicator_top!=null){
		getElement('loading').style.top = indicator_top;
		//getElement('loading').style.left =  (document.documentElement.clientWidth/2) - indicator_left;
		getElement('loading').style.left = indicator_left;
		getElement('loading').style.position = indicator_position;
	}
	return true;
}