// AJAX FUNCTIONS
function xml (){
	if (typeof XMLHttpRequest == 'undefined') {
		objects = Array(
			'Microsoft.XmlHttp',
			'MSXML2.XmlHttp',
			'MSXML2.XmlHttp.3.0',
			'MSXML2.XmlHttp.4.0',
			'MSXML2.XmlHttp.5.0'
		);
		for (i = 0; i < objects.length; i++) {
			try {
				return new ActiveXObject(objects[i]);
			} catch (e) {}
		}
	} else {
		return new XMLHttpRequest();
	}
}

function element ( id )
{
	return document.getElementById ( id );
}

function doAjax ( url )
{
	ajax.open( 'GET' , url, true );
	ajax.send(null);
}

function steadyAjax ()
{
	if ( ajax.readyState == 4 && ajax.status == 200 )
	{
		response = ajax.responseText;
		return true;
	}
}

function doSplit()
{
	returnSplit();
	for ( var i = 0; i < arguments.length; i++ )
	{
		document.getElementById(arguments[i]).innerHTML = response[i];
	}
}
function applySplitResponse ()
{
	if ( !arguments ) { return; }
	var o = new Array();
	for ( var i = 0; i < arguments.length; i++ )
	{
		o[i] = arguments[i];
	}
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			for ( var i = 0; i < o.length; i++ )
			{
				document.getElementById(o[i]).innerHTML = response[i];
			}
		}
	}
}

function returnSplit ()
{
	response = response.split(customSplit);
	customSplit = '|';
}

function setCustomSplit ( i )
{
	if ( !i )
	{
		return;
	}
	customSplit = i;
}

// OBJECTS FUNCTIONS

function doFave ( id, act )
{
	if ( !id ) { return; }

	var ele = 'tutfav_'+id;

	if ( act == true )
	{
		act = 'addFave';
	}
	else
	{
		act = 'remFave';
	}

	doAjax ( 'ajax.php?act='+act+'&id='+id );
	ajax.onreadystatechange = function()
	{
		if ( steadyAjax () )
		{
			document.getElementById(ele).innerHTML = response;
			if ( act == 'remFave' )
			{
				document.getElementById('fave_icon_'+id).src = '/css/images/but_fave_off.gif';
			}
			else
			{
				document.getElementById('fave_icon_'+id).src = '/css/images/but_fave_on.gif';
			}
		}
	}
}

function getcategory_hard(cattopid,catstatus)
{
	doAjax ("ajax.php?act=getcategory_hard&id=" + escape(cattopid) + "&catst=" + escape(catstatus));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("cat_list_"+response[0]).innerHTML = response[1];
		}
		//window.moveTo(0, 0) ;
	}
}
function getcategory_soft(cattopid,catstatus)
{
	doAjax ("ajax.php?act=getcategory_soft&id=" + escape(cattopid) + "&catst=" + escape(catstatus));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("cat_list_"+response[0]).innerHTML = response[1];
		}
	}
}
function getcategory_print(cattopid,catstatus)
{
	doAjax ("ajax.php?act=getcategory_print&id=" + escape(cattopid) + "&catst=" + escape(catstatus));
	//alert("ajax.php?act=getcategory_print&id=" + escape(cattopid) + "&catst=" + escape(catstatus));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("cat_list_"+response[0]).innerHTML = response[1];
			//alert(response);
		}
	}
}

function getcontent(cattopid,catstatus,whichPrice)
{
	//alert("ajax.php?act=getcontent&id=" + escape(cattopid) + "&catst=" + escape(catstatus)+"&price="+escape(whichPrice));
	doAjax ("ajax.php?act=getcontent&id=" + escape(cattopid) + "&catst=" + escape(catstatus)+"&price="+escape(whichPrice));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById('content').innerHTML = response[1];
      //alert(response[1]);
              window.scrollTo(0,255);


		}
	}
}
function updsort_displayoptions()
{
	tempa = document.getElementById('dispopt_av').checked;
	tempb = document.getElementById('dispopt_tutnum').value;
	doAjax ("ajax.php?act=updsort_displayoptions&opta=" + escape(tempa) + "&optb=" + escape(tempb));
	setCustomSplit ( '[][]' );
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			if ( response.length == 3 )
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
				document.getElementById('tutorial_random').innerHTML = response[2];
			}
			else
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
			}
		}
	}
}
function updsort_filteroptions ()
{
  var s1What = document.getElementById('sortone_what').value;
  var s1How = document.getElementById('sortone_how').value;
  var s2What = document.getElementById('sorttwo_what').value;
  var s2How = document.getElementById('sorttwo_how').value;

  doAjax ( "ajax.php?act=updsort_filteroptions&s1What="+escape(s1What)+"&s1How="+escape(s1How)+"&s2What="+escape(s2What)+"&s2How="+escape(s2How));
  setCustomSplit ( '[][]' );
  ajax.onreadystatechange = function ()
  {
		if ( steadyAjax() )
		{
			returnSplit();
			if ( response.length == 3 )
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
				document.getElementById('tutorial_random').innerHTML = response[2];
			}
			else
			{
				document.getElementById('sortingsub').innerHTML = response[0];
				document.getElementById('tutorial_landing').innerHTML = response[1];
			}
		}
  }

}

function remDockFav ( id )
{
	doAjax ( 'ajax.php?act=remDockFav&id='+escape(id));
	applySplitResponse('boxid_dockfaves');
}

function removemycat(catid)
{
	doAjax ("ajax.php?act=remove_mycat&id=" + escape(catid));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("center_mycat_link_rem").innerHTML = response[2];
			document.getElementById('center_mycat_link_rem').id = 'center_mycat_link';
		}
	}
}
function addmycat(catid)
{
	doAjax ("ajax.php?act=add_mycat&id=" + escape(catid));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("center_mycat_link").innerHTML = response[2];
			document.getElementById('center_mycat_link').id = 'center_mycat_link_rem';
		}
	}
}

function addCat ( id )
{
	doAjax ("ajax.php?act=addCat&id=" + escape(id));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("filter_mycat").innerHTML = response[2];
		}
	}
}
function remCat ( id )
{
	doAjax ("ajax.php?act=remCat&id=" + escape(id));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById("mycat_addrem_a").innerHTML = response[0];
			document.getElementById("cat_list_my").innerHTML = response[1];
			document.getElementById("filter_mycat").innerHTML = response[2];
		}
	}
}


function devtools_searchbar()
{
	devkey = document.getElementById('key').value;
	devcat = document.getElementById('searchin').value;
	devcolor1 = document.getElementById('bginput').value;
	devcolor2 = document.getElementById('borderinput').value;
	devcolor3 = document.getElementById('textinput').value;
	doAjax("ajax.php?act=devtools_searchbar&key=" + escape(devkey) + "&cat=" + escape(devcat) + "&color1=" + escape(devcolor1) + "&color2=" + escape(devcolor2) + "&color3=" + escape(devcolor3));
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById('generated').value = response[0];
		}
	}

}
function getuserdock(dock)
{
	var style2 = document.getElementById('boxid_dock'+dock);
	var style3 = document.getElementById('tabdock_'+dock);
	style2.style.display = style2.style.display ? "":"none";
	if (style2.style.display == "") {
		if(dock == 'forums') {
			document.getElementById('boxid_dock'+dock).innerHTML = doLoading;
		}
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
		getnewsbox_open = true;
	} else {
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}

	doAjax("ajax.php?act=getuserdock&dock=" + escape(dock));
	setCustomSplit ('[][]');
	ajax.onreadystatechange = function ()
	{
		if (steadyAjax())
		{
			returnSplit();
			document.getElementById("boxid_dock"+dock).innerHTML = response[0];
		}
	}
}
function getfindsite_s()
{
	doAjax ("ajax.php?act=getfindsite_s");
	applySplitResponse("findsite_s");
}
function getnewsbox(box)
{
	var style2 = document.getElementById('boxid_news'+box);
	var style3 = document.getElementById('tabnews_'+box);
	style2.style.display = style2.style.display ? "":"none";
	if (style2.style.display == "") {
		document.getElementById('boxid_news'+box).innerHTML = doLoading;
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
		getnewsbox_open = true;
	} else {
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}
	doAjax("ajax.php?act=getnewsbox&box=" + escape(box));
	ajax.onreadystatechange = function ()
	{
		if(getnewsbox_open) {applySplitResponse('boxid_news'+box);}
	}

}
function getbox ( box )
{
	doAjax("ajax.php?act=getbox&box=" + escape(box));
	applySplitResponse("mainnav", "adwrap_content");
}

function getsubmtuts_s()
{
	doAjax("ajax.php?act=getsubmtuts");
	applySplitResponse("findsite_s");
}
function gettutdispopt()
{
	doAjax("ajax.php?act=gettutdispopt");
	applySplitResponse("sortingdisp");
}
function gettutfilter()
{
	doAjax("ajax.php?act=gettutfilter");
	applySplitResponse("sortingdisp");
}
function setcommentreply(id)
{
	document.getElementById('comment_formtop').innerHTML = "<strong>Reply to Comment #" + (id + 1) + "</strong> <span class=\"small\">(<a href=\"#postacomment\" onclick=\"setcommentnew(); return false;\">New Comment</a>)</span>";
	document.getElementById('comment_type').value = id;
}
function setcommentnew()
{
	document.getElementById('comment_formtop').innerHTML = "<strong>New Comment</strong>";
	document.getElementById('comment_type').value = "new";
}
function editcomment(id, rid, tid)
{
	if(iseditcomment) {
		alert('You cannot edit 2 comments at the same time!');
	} else {
		iseditcomment = true;
		if(rid) {
			completeid = id + "-" + rid;
			ctype = true;
		} else {
			completeid = id;
			ctype = false;
		}
		document.getElementById('comment_id_' + completeid).innerHTML = doLoading;
		completeurl ="ajax.php?act=editcomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&ctype=" + ctype;
		doAjax(completeurl);
		applySplitResponse('comment_id_' + completeid);
	}
}
function savecomment(id, rid, tid)
{
	if(iseditcomment) {
		content = document.getElementById('commentedit').value;
		document.getElementById('comment_id_' + completeid).innerHTML = doLoading;
		completeurl ="ajax.php?act=savecomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&ctype=" + ctype + "&cdata=" + escape(content);
		doAjax(completeurl);
		applySplitResponse('comment_id_' + completeid);
		iseditcomment = false;
	} else {
		alert('Error: No edit comment request.');
	}
}
function ratecomment(id, rid, tid, type, uniqid)
{
	if(rid) {ctype = true;} else {ctype = false;}
	completeurl ="ajax.php?act=ratecomment&id=" + tid + "&cid=" + id + "&rid=" + rid + "&type=" + escape(type) + "&ctype=" + ctype;
	doAjax(completeurl);
	ajax.onreadystatechange = function () {
		if(steadyAjax()) {
			returnSplit();
			document.getElementById('commentrating_' + uniqid).innerHTML = response[0];
			document.getElementById('commentarrows_' + uniqid).innerHTML = response[1];
		}
	}
}

// #################################################################
// COMMENTS - SHOW ADD COMMENT FORM
// #################################################################

function display_commentform()
{
	document.getElementById("post_comment_add").style.visibility = 'visible';
	document.getElementById("pre_comment_add").style.overflow = 'hidden';
	document.getElementById("pre_comment_add").style.height = '1px';
	document.getElementById("pre_comment_add").style.visibility = 'hidden';
}

function headersubtext(subtext)
{
	if(!subtext)
	{
		document.getElementById("search_locator").innerHTML = '&nbsp;';
	}
	else
	{
		document.getElementById("search_locator").innerHTML = subtext;
	}
}

// #################################################################
// FORM - VALIDATE
// #################################################################

<!--
function ValidateForm() {
	var Check = 0;
	if (document.LOGIN.UserName.value == '') { Check = 1; }
	if (document.LOGIN.PassWord.value == '') { Check = 1; }
	if (Check == 1) {
		alert("Please enter your name and password before continuing");
		return false;
	} else {
		document.LOGIN.submit.disabled = true;
		return true;
	}
}
//-->
/*
    Written by Jonathan Snook, http://www.snook.ca/jonathan
    Add-ons by Robert Nyman, http://www.robertnyman.com
*/

function getElementsByClassName(oElm, strTagName, strClassName){
    var arrElements = (strTagName == "*" && document.all)? document.all : oElm.getElementsByTagName(strTagName);
    var arrReturnElements = new Array();
    strClassName = strClassName.replace(/\-/g, "\\-");
    var oRegExp = new RegExp("(^|\\s)" + strClassName + "(\\s|$)");
    var oElement;
    for(var i=0; i<arrElements.length; i++){
        oElement = arrElements[i];
        if(oRegExp.test(oElement.className)){
            arrReturnElements.push(oElement);
        }
    }
    return (arrReturnElements)
}

function expand ()
{
	doAjax ( 'ajax.php?act=expand' );
	applySplitResponse ( 'boxid_categories' );
}
function collapse ()
{
	doAjax ( 'ajax.php?act=collapse' );
	applySplitResponse ( 'boxid_categories' );
}

function toggleLayer(whichLink,whichLayer,whichCat,whichPrice) {

	var style2 = document.getElementById(whichLayer);
	var style3 = document.getElementById(whichLink);
	style2.style.display = style2.style.display ? "":"none";

	if (style2.style.display == "") {
		if (whichPrice=="hard")		getcategory_hard(whichCat,'open');
		if (whichPrice=="soft")		getcategory_soft(whichCat,'open');
		if (whichPrice=="print")	getcategory_print(whichCat,'open');
		if(style3.className == "menulink_closed_on") {style3.className = "menulink_open_on";}
		if(style3.className == "menulink_closed_off") {style3.className = "menulink_open_off";}
	} else {
		if (whichPrice=="hard") getcategory_hard(whichCat,'closed');
		if (whichPrice=="soft") getcategory_soft(whichCat,'closed');
		if (whichPrice=="print") getcategory_print(whichCat,'closed');
		if(style3.className == "menulink_open_on") {style3.className = "menulink_closed_on";}
		if(style3.className == "menulink_open_off") {style3.className = "menulink_closed_off";}
	}

	return false;
}
function toggleContent(whichLink,whichLayer,whichCat,whichPrice) {

		getcontent(whichCat,'open',whichPrice);

	return false;
}

function toggleTut(whichLayer) {
	if (document.getElementById) {
		// this is the way the standards work
		var style2 = document.getElementById(whichLayer).style;
		style2.display = style2.display? "":"block";
	} else if (document.all) {
		// this is the way old msie versions work
		var style2 = document.all[whichLayer.style];
		style2.display = style2.display? "":"block";
	} else if (document.layers) {
		// this is the way nn4 works
		var style2 = document.layers[whichLayer].style;
		style2.display = style2.display? "":"block";
	}
}

function changeColor(tdno, color)
{
	obj = document.getElementById("tutrow_" + tdno);
	obj.style.background = color;
	//alert(color);
}

function countword(source, target) {
	var vsource = document.getElementById(source);
	var vtarget = document.getElementById(target);
	var no_words = 0;

	no_words = vsource.value.split(" ");
	if(no_words.length < 2) {
		vtarget.innerHTML = no_words.length + " Word";
	} else {
		vtarget.innerHTML = no_words.length + " Words";
	}
	return true;
}

function counttextarea(source) {

	var vsource = document.getElementById(source);
	var no_words = 0;
	var no_pages = 0;
	var message = "";

	no_words = vsource.value.split(" ");
	no_pages = vsource.value.split("[nextpage]");
	if(no_words.length < 2) {
		if(no_pages.length < 2) {
			message = no_words.length + " word and " + no_pages.length + " page.";
		} else {
			message = no_words.length + " word and "  + no_pages.length + " pages.";
		}
	} else {
		if(no_pages.length < 2) {
			message = no_words.length + " words and " + no_pages.length + " page.";
		} else {
			message = no_words.length + " words and "  + no_pages.length + " pages.";
		}
	}

	alert("Your tutorial has " + message);

	return false;

}

var newwindow;

function poptastic(url,name,width,height)
{
	newwindow = window.open(url,name,'height='+height+',width='+width);
	if(window.focus) {newwindow.focus();}
}

function newFilter ()
{
	if ( filterLoaded == false )
	{
		filterLoaded = true;
		document.getElementById('filter_content').style.display = 'block';
	}
	else
	{
		filterLoaded = false;
		document.getElementById('filter_content').style.display = 'none';
	}
}

function filterSave ()
{
	var tuts_per_page = document.getElementById('tuts_per_page');
	tuts_per_page = tuts_per_page.options[tuts_per_page.selectedIndex].value;

	var display_avatars = document.getElementById('display_avatars');
	display_avatars = display_avatars.options[display_avatars.selectedIndex].value;

	var sort_by_one = document.getElementById('sort_by_one');
	sort_by_one = sort_by_one.options[sort_by_one.selectedIndex].value;

	var sort_by_two = document.getElementById('sort_by_two');
	sort_by_two = sort_by_two.options[sort_by_two.selectedIndex].value;

	var sort_how_one = document.getElementById('sort_how_one');
	sort_how_one = sort_how_one.options[sort_how_one.selectedIndex].value;

	var sort_how_two = document.getElementById('sort_how_two');
	sort_how_two = sort_how_two.options[sort_how_two.selectedIndex].value;

	doAjax ( 'ajax.php?act=filterSave&tuts_per_page='+escape(tuts_per_page)+'&display_avatars='+escape(display_avatars)+'&sort_by_one='+escape(sort_by_one)+'&sort_by_two='+escape(sort_by_two)+'&sort_how_one='+escape(sort_how_one)+'&sort_how_two='+escape(sort_how_two));
	setCustomSplit ( '[][]' );
	ajax.onreadystatechange = function ()
	{
		if ( steadyAjax() )
		{
			returnSplit();
			document.getElementById('settings_saved').innerHTML = 'Settings Saved';
			//new Effect.Fade('settings_saved',{duration:1.5, from: 1.0, to: 0.0, afterFinish:function() { document.getElementById('settings_saved').innerHTML = ''; new Effect.Appear('settings_saved',{duration:0.1, from: 0.0, to:1.0}); }});
			if ( response.length == 2 )
			{
				document.getElementById('tutorial_landing').innerHTML = response[0];
				document.getElementById('tutorial_random').innerHTML = response[1];
			}
			else
			{
				document.getElementById('tutorial_landing').innerHTML = response[0];
			}

		}
	}
}

function filterReset ()
{
	var tuts_per_page = document.getElementById('tuts_per_page');
	var display_avatars = document.getElementById('display_avatars');
	var sort_by_one = document.getElementById('sort_by_one');
	var sort_by_two = document.getElementById('sort_by_two');
	var sort_how_one = document.getElementById('sort_how_one');
	var sort_how_two = document.getElementById('sort_how_two');

	tuts_per_page.options[2].selected = true;
	display_avatars.options[0].selected = true;
	sort_by_one.options[0].selected = true;
	sort_by_two.options[1].selected = true;
	sort_how_one.options[0].selected = true;
	sort_how_two.options[0].selected = true;

	filterSave();
}

function votePOP ( towhere )
{
	window.open("http://www.pixel2life.com"+towhere,"mywindow","menubar=0,resizable=0,location=0,status=0,scrollbars=0,width=500,height=250");
}

function count_textlink(id) { var tracker = '/textlink/'+id; i = new Image();	s = Math.round(1E10*Math.random());	i.src = tracker; }
function count_imagelink(id) { var tracker = '/imagelink/'+id;	i = new Image(); s = Math.round(1E10*Math.random()); i.src = tracker; }
function count_integrated(id) { var tracker = '/integrated/'+id;	i = new Image(); s = Math.round(1E10*Math.random()); i.src = tracker; }
function count_half(id) { var tracker = '/half/'+id;	i = new Image(); s = Math.round(1E10*Math.random()); i.src = tracker; }

var filterLoaded = false;
var doLoading = '<img src="/images/indicator.gif" alt="" />';
var doElement;
var customSplit = '|';
var response;
var eleSave;
var ajax = xml();
var iseditcomment;

function showtip(id, event, tip)
{
var Div = document.getElementById(id);
divId = new Object();
divId.id = Div;
divId.id.innerHTML = tip;
divId.id.style.display = 'block';
var x=event.clientX;
var y=document.body.scrollTop+event.y;

var Y = y;
window.status = document.body.scrollTop;
window.status = "X : " + window.event.x + " | Y : " + window.event.y;
divId.id.style.left = x+'px';
divId.id.style.top = Y+'px';
/*
var x = document.body.scrollLeft + event.x;
var y = document.body.scrollTop + event.y;
alert('x:' + x + ' y:' + y);
*/
}

function hidetip()
{
divId.id.style.display = 'none';
}






var offsetfromcursorX=12 //Customize x offset of tooltip
var offsetfromcursorY=10 //Customize y offset of tooltip

var offsetdivfrompointerX=10 //Customize x offset of tooltip DIV relative to pointer image
var offsetdivfrompointerY=14 //Customize y offset of tooltip DIV relative to pointer image. Tip: Set it to (height_of_pointer_image-1).

document.write('<div id="dhtmltooltip"></div>') //write out tooltip DIV
document.write('<img id="dhtmlpointer" src="img/arrow2.gif">') //write out pointer image

var ie=document.all
var ns6=document.getElementById && !document.all
var enabletip=false
if (ie||ns6)
var tipobj=document.all? document.all["dhtmltooltip"] : document.getElementById? document.getElementById("dhtmltooltip") : ""

var pointerobj=document.all? document.all["dhtmlpointer"] : document.getElementById? document.getElementById("dhtmlpointer") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thewidth, thecolor){
if (ns6||ie){
if (typeof thewidth!="undefined") tipobj.style.width=thewidth+"px"
if (typeof thecolor!="undefined" && thecolor!="") tipobj.style.backgroundColor=thecolor
tipobj.innerHTML=thetext
enabletip=true
return false
}
}

function positiontip(e){
if (enabletip){
var nondefaultpos=false
var curX=(ns6)?e.pageX : event.clientX+ietruebody().scrollLeft;
var curY=(ns6)?e.pageY : event.clientY+ietruebody().scrollTop;
//Find out how close the mouse is to the corner of the window
var winwidth=ie&&!window.opera? ietruebody().clientWidth : window.innerWidth-20
var winheight=ie&&!window.opera? ietruebody().clientHeight : window.innerHeight-20

var rightedge=ie&&!window.opera? winwidth-event.clientX-offsetfromcursorX : winwidth-e.clientX-offsetfromcursorX
var bottomedge=ie&&!window.opera? winheight-event.clientY-offsetfromcursorY : winheight-e.clientY-offsetfromcursorY

var leftedge=(offsetfromcursorX<0)? offsetfromcursorX*(-1) : -1000

//if the horizontal distance isn't enough to accomodate the width of the context menu
if (rightedge<tipobj.offsetWidth){
//move the horizontal position of the menu to the left by it's width
tipobj.style.left=curX-tipobj.offsetWidth+"px"
nondefaultpos=true
}
else if (curX<leftedge)
tipobj.style.left="5px"
else{
//position the horizontal position of the menu where the mouse is positioned
tipobj.style.left=curX+offsetfromcursorX-offsetdivfrompointerX+"px"
pointerobj.style.left=curX+offsetfromcursorX+"px"
}

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight){
tipobj.style.top=curY-tipobj.offsetHeight-offsetfromcursorY+"px"
nondefaultpos=true
}
else{
tipobj.style.top=curY+offsetfromcursorY+offsetdivfrompointerY+"px"
pointerobj.style.top=curY+offsetfromcursorY+"px"
}
tipobj.style.visibility="visible"
if (!nondefaultpos)
pointerobj.style.visibility="visible"
else
pointerobj.style.visibility="hidden"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
pointerobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip




