// Title: KamaSutra Body JavaScripts
// URL: http://www.kamasutra.co.za
// Version: 1.3

// Menu Scrips //

function updatecook(itemmenu){
	cookitem='span_'+itemmenu;
	if(document.getElementById(cookitem).style.display!='none'){
		var expireDate = new Date;
		expireDate.setMinutes(expireDate.getMinutes()+10);
		document.cookie = "treemenustatus=" + itemmenu + "; expires=" + expireDate.toGMTString();
	}
	else{
		clearcook();
	}
}
function clearcook(){
	var expireDate = new Date;
	expireDate.setMinutes(expireDate.getMinutes()+10);
	document.cookie = "treemenustatus=" + "0" + "; expires=" + expireDate.toGMTString();
}
function launchpopupscroll(url, name, width, height,scroll) {
   winSet = "toolbar=no,location=no,directories=no,menubar=no,scrollbars="+scroll+",resizable=yes";
   winSet += ",width="+width +",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
   mypopwnd = window.open(url, name, winSet);
   mypopwnd.focus();
}
function launchpopup(url, name, width, height) {
   launchpopupscroll(url, name, width, height,"yes");
}
function launchsuccesspopup(url, name, width, height) {
   winSet = "toolbar=no,location=no,directories=no,menubar=no,scrollbars=yes,resizable=yes";
   winSet += ",width="+width +",height="+height+",left="+(screen.availWidth-width)/2+",top="+(screen.availHeight-height)/2;
   mypopwnd = window.open(url, name, winSet);
   mypopwnd.focus();
}
function launchwindow(url) {
   winSet = "toolbar=yes,location=no,directories=no,menubar=yes,scrollbars=yes,resizable=yes";
   mywnd = window.open(url, '', winSet);
}

if(document.getElementById&&!document.all){ns6=1;}else{ns6=0;}
var agtbrw=navigator.userAgent.toLowerCase();
var operaaa=(agtbrw.indexOf('opera')!=-1);
var head="display:''";
var folder='';

function expandit(curobj){
	if(document.getElementById(curobj)){
		folder=document.getElementById(curobj).style;
	}else{
		if(ns6==1||operaaa==true){
			folder=curobj.nextSibling.nextSibling.style;
		}else{
			folder=document.all[curobj.sourceIndex+1].style;
		}
	}
	if (folder.display=="none"){folder.display="";}else{folder.display="none";}
}

function right(e) {
	if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
	return false;
		else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
		alert("Uplifting photographs or content from this site is NOT PERMITTED! © kamasutra.co.za");
		return false;
		}
	return true;
	}
	
	document.onmousedown=right;
	document.onmouseup=right;
	if (document.layers) window.captureEvents(Event.MOUSEDOWN);
	if (document.layers) window.captureEvents(Event.MOUSEUP);
	window.onmousedown=right;
	window.onmouseup=right;

function ClipBoard(){
	textarea.innerText = copytext.innerText;
	Copied = textarea.createTextRange();
	Copied.execCommand("Copy");
	alert("The Code has been copied to the Clipboard, Paste (control+v) or (right-click paste) on-to the page where the banner should apprear.");
}

function out(site)
{
  image = new Image();
  image.src= 'links.php?a=out&u=' + site;
}

function remove_XS_whitespace(item)
{
  var tmp = "";
  var item_length = item.value.length;
  var item_length_minus_1 = item.value.length - 1;
  for (index = 0; index < item_length; index++)
  {
    if (item.value.charAt(index) != ' ')
    {
      tmp += item.value.charAt(index);
    }
    else
    {
      if (tmp.length > 0)
      {
        if (item.value.charAt(index+1) != ' ' && index != item_length_minus_1)
        {
          tmp += item.value.charAt(index);
        }
      }
    }
  }
  item.value = tmp;
}

function insertSmiley(smiley){
	var currentMessage = window.opener.document.forms[1].elements[1].value;
	newMessage = currentMessage+' '+smiley+' ';
	window.opener.document.forms[1].elements[1].value=newMessage;
	window.opener.document.forms[1].elements[1].focus();
}

function insertSmiley1(smiley){
	var currentMessage = window.opener.document.forms[1].elements[2].value;
	newMessage = currentMessage+' '+smiley+' ';
	window.opener.document.forms[1].elements[2].value=newMessage;
	window.opener.document.forms[1].elements[2].focus();
}

function insertSmiley2(smiley){
	var currentMessage = window.opener.document.forms[1].elements[0].value;
	newMessage = currentMessage+' '+smiley+' ';
	window.opener.document.forms[1].elements[0].value=newMessage;
	window.opener.document.forms[1].elements[0].focus();
}

function checkLen(Target) {
StrLen = Target.value.length;
	if (StrLen > 1000 ) {
		Target.value = Target.value.substring(0,1000);
		charsLeft = 0;
	}
	else {
		charsLeft = 1000 - StrLen;
	}
	document.sbform.charsLeft.value = charsLeft;
}

/***********************************************
* Cool DHTML tooltip script- © Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var offsetxpoint=-60 //Customize x offset of tooltip
var offsetypoint=20 //Customize y offset of tooltip
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") : ""

function ietruebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function ddrivetip(thetext, thecolor, thewidth){
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 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 rightedge=ie&&!window.opera? ietruebody().clientWidth-event.clientX-offsetxpoint : window.innerWidth-e.clientX-offsetxpoint-20
var bottomedge=ie&&!window.opera? ietruebody().clientHeight-event.clientY-offsetypoint : window.innerHeight-e.clientY-offsetypoint-20

var leftedge=(offsetxpoint<0)? offsetxpoint*(-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=ie? ietruebody().scrollLeft+event.clientX-tipobj.offsetWidth+"px" : window.pageXOffset+e.clientX-tipobj.offsetWidth+"px"
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+offsetxpoint+"px"

//same concept with the vertical position
if (bottomedge<tipobj.offsetHeight)
tipobj.style.top=ie? ietruebody().scrollTop+event.clientY-tipobj.offsetHeight-offsetypoint+"px" : window.pageYOffset+e.clientY-tipobj.offsetHeight-offsetypoint+"px"
else
tipobj.style.top=curY+offsetypoint+"px"
tipobj.style.visibility="visible"
}
}

function hideddrivetip(){
if (ns6||ie){
enabletip=false
tipobj.style.visibility="hidden"
tipobj.style.left="-1000px"
tipobj.style.backgroundColor=''
tipobj.style.width=''
}
}

document.onmousemove=positiontip


