function test() {
	Effect.SlideUp('thing');
}

function trackHit(url) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try {
      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      		} catch (e) {
      			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	xmlHttp.onreadystatechange=function() {
    	
		if(xmlHttp.readyState==4) {
      		//document.getElementById(div).innerHTML = xmlHttp.responseText;
			//Effect.SlideDown('article');
			
      	}
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);	
}

function toggleBot(what) {

	ar = findPos(what);
	
	document.getElementById('articleContainer').style.top = (ar[1] + 12) + "px";
	document.getElementById('articleContainer').style.left = (ar[0] + 162) + "px"; // was 195

	display = document.getElementById('nikonbot').style.display;

	if(display == 'none') {
	
		
		if(document.getElementById('nodes').innerHTML == "") {
			prep();	
		}
		trackHit("http://press.nikonusa.com/request.php?action=hit");
		//document.getElementById('nikonbot').style.display = '';
		Effect.Appear('nikonbot');
		
		what.style.margin = 0;
		what.src = "http://press.nikonusa.com/images/nikonbot2.gif";
		
		
	} else if(display == '') {
	
		closeItem();
		//document.getElementById('nikonbot').style.display = 'none';
		Effect.Fade('nikonbot');
		what.style.margin = "0 0 10px 0";
		what.src = "http://press.nikonusa.com/images/nikonbot.gif";
	}

}


function prep() {
	prepareBot("http://press.nikonusa.com/request.php?action=list", 'nodes');
	
}

function findPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		do {
			curleft += obj.offsetLeft;
			curtop += obj.offsetTop;
		} while (obj = obj.offsetParent);
	}
	return [curleft,curtop];
}

function toggle(div) {

	display = document.getElementById(div).style.display;
	
	if(display == 'none') {
		document.getElementById(div).style.display = '';
	} else {
		document.getElementById(div).style.display = 'none';
	}

}

function ajaxFunction(url, div) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try {
      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      		} catch (e) {
      			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	xmlHttp.onreadystatechange=function() {
    	
		if(xmlHttp.readyState==4) {
      		document.getElementById(div).innerHTML = xmlHttp.responseText;
			document.getElementById(div).style.display = '';
			
      	}
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function prepareBot(url, div) {
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try {
      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      		} catch (e) {
      			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	xmlHttp.onreadystatechange=function() {
    	
		if(xmlHttp.readyState==4) {
      		document.getElementById(div).innerHTML = xmlHttp.responseText;
			//Effect.SlideDown('article');
			
      	}
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}

function fetchCategory(id) {
	
	div = "cat" + id;
	url = "http://press.nikonusa.com/request.php?action=none&id=" + id;
	
	display = document.getElementById(div).style.display;
	
	if(display == 'none') {
		ajaxFunction(url, div);
	} else {
		document.getElementById(div).style.display = 'none';
	}
	
	
}

function closeItem() {
	document.getElementById('articleContainer').style.display = 'none';
}

function fetchItem(id) {
	
	url = "http://press.nikonusa.com/request.php?action=article&id=" + id;
	
	var xmlHttp;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
	} catch (e) {
		// Internet Explorer
		try {
    		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    	} catch (e) {
    		try {
      			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      		} catch (e) {
      			alert("Your browser does not support AJAX!");
      			return false;
      		}
    	}
	}
	xmlHttp.onreadystatechange=function() {
    	
		if(xmlHttp.readyState==4) {
			//alert(xmlHttp.responseText);
			document.getElementById('articleContainer').style.display = '';
			//Effect.SlideDown('articleContainer');
      		document.getElementById('article').innerHTML = xmlHttp.responseText + '<div style="clear:both;"></div>';
			
      	}
    }
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
	
}



function fetchChildren(id) {
	ajaxFunction("http://press.nikonusa.com/request.php?action=children&id=" + id, "nodes");
	ajaxFunction("http://press.nikonusa.com/request.php?action=path&id=" + id, "crumbs");
}