// JavaScript Document

var timeoutTip;

function createRequestObject() {
     if(navigator.appName == "Microsoft Internet Explorer"){
          var ro = new ActiveXObject("Microsoft.XMLHTTP");
     }else{
          var ro = new XMLHttpRequest();
     }
     return ro;
}

var ajaxHTTP = createRequestObject();

function ajaxSendRequest(url) {
     ajaxHTTP.open('get', url);
     ajaxHTTP.onreadystatechange = handleResponse;
     ajaxHTTP.send(null);
}


function handleResponse() {
	if(ajaxHTTP.readyState == 4 && ajaxHTTP.responseText.length>0){
		var hintObj = document.getElementById('companyHint');
		hintObj.innerHTML = ajaxHTTP.responseText;
		timeoutTip=setTimeout(function(){hintObj.style.display = 'block';} , 500);
	}
}




	




function getAbsPos(p){
	var s={x:0,y:0};
	while(p.offsetParent){
		s.x+=p.offsetLeft;
		s.y+=p.offsetTop;
		p=p.offsetParent;
	}
	return(s);
}

function createHintObj(){
	if (document.getElementById('companyHint')!=null){
		return;
	}
	var obj=document.createElement('div');
	obj.id = 'companyHint';
	document.body.appendChild(obj);
	var hintObj = document.getElementById('companyHint');
	hintObj.innerHTML='asfdhafhdsafhsdf';
	hintObj.onmouseover = function(){clearTimeout(timeoutTip);}
	hintObj.onmouseout = function(){hideCompanyHint();}
}


function showCompanyHint(linkObj,id){
	createHintObj();
//	alert(document.getElementById('companyHint'));
	var hintObj = document.getElementById('companyHint');
	var coord = getAbsPos(linkObj);
	hintObj.style.left = (coord.x-11)+'px';
	hintObj.style.top = (coord.y-10)+'px';
	ajaxSendRequest('/ajax/company_hint.php?comp_id=' /*+ id*/ +id);
}


function hideCompanyHint(){
	var hintObj = document.getElementById('companyHint');
	
	timeoutTip=setTimeout(function(){hintObj.style.display='none';} , 100);
	hintObj.onMouseOver = function(){
		alert('df');
		clearTimeout(hintObj.timeoutTip);
	}
}


