var d = document;
var offsetX, offsetY, curz = 1;
var mx, my, el, myObj;
if(d.layers) {
	var isNav = 1;
	var isIE = 0
	var isNS6 = 0;
}else if(d.all) {
	var isIE = 1;
	var isNav = 0
	var isNS6 = 0;
}else if (d.getElementById) {
	var isNS6 = 1;
	var isNav = 0
	var isIE = 0;
}



function makeSexy(obj,lnk){
	var url="tpl/detail.php?"+lnk;
	makeRequest(url);
	tip=document.getElementById("popup");
	tip.style.visibility="visible";
}


	
function shiftTo(obj, x, y) {
	if(isIE) {
		myObj = eval("d.all."+obj+".style");
		myObj.pixelLeft = x;
		myObj.pixelTop = y;
	}else if(isNav) {
		myObj = eval("d."+obj);
		myObj.moveTo(x,y);
	}else {
		myObj = eval("d.getElementById('"+obj+"')");
		myObj.style.top = y;
		myObj.style.left = x;
	}
}

function startdrag(obj) {
}
		
		
function mousemoved(evt) {
	if(isIE) {
		mousex = window.event.clientX+document.body.scrollLeft;
		mousey = window.event.clientY+document.body.scrollTop;
	}else if(isNav) {
		mousex = evt.pageX+window.pageXOffset;
		mousey = evt.pageY+window.pageYOffset;
	}else {
		mousex = evt.pageX;
		mousey = evt.pageY;
	}
    if(el) {
    	wx = mousex - offsetX;
   		wy = mousey - offsetY;
   		wx = (wx>0) ? wx:0;
   		wy = (wy>0) ? wy:0;
    	shiftTo(el,wx, wy);
		
	}
	return false;
}

function stopdrag() {el = null;}			

//if(isNav) {
//	window.captureEvents(Event.MOUSEMOVE);
//	window.onmousemove = mousemoved;
//}else{
//	document.onmousemove = mousemoved;
//} 


// AJAXy stuff
function makeRequest(url) {
	var httpRequest;
	if (window.XMLHttpRequest) { // Mozilla, Safari, ...
		httpRequest = new XMLHttpRequest();
		if (httpRequest.overrideMimeType) {
			httpRequest.overrideMimeType('text/xml');
		}
	}else if (window.ActiveXObject) { // IE
		try {
			httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
        	}
		catch (e) {
			try {
				httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			}catch (e) {}
			}
	}

	if (!httpRequest) {
		alert('Giving up :( Cannot create an XMLHTTP instance');
		return false;
	}
	httpRequest.onreadystatechange = function() { alertContents(httpRequest); };
    httpRequest.open('GET', url, true);
    httpRequest.send(null);
}

function alertContents(httpRequest) {
	if (httpRequest.readyState == 4) {
			document.getElementById('container').innerHTML=httpRequest.responseText;
	}
}
