/*=======================================================================================
iVidPlay version 2.0
Copyright �2008 iVidPlay.com - http://www.ividplay.com. All Rights Reserved.

This file is part of iVidPlay script, iVidPlay is a commercial script, any usage must
have and agree to iVidPlay license. Duplication and/or redistribution in whole or part
is strictly prohibited.
========================================================================================*/

function ltrim(str)
{
	return str.replace(/\s*((\S+\s*)*)/g, "$1");
}

function rtrim(str)
{
	return str.replace(/((\s*\S+)*)\s*/g, "$1");
}

function trim(str)
{
	return ltrim(rtrim(str));
}

function checkAll(checkboxes, state)
{
  if (checkboxes.length)
    for (i=0;i<checkboxes.length;i++){
      checkboxes[i].checked = state;
    }
  else
    checkboxes.checked = state;
}

function checkSelection(checkboxes)
{
  if (checkboxes.length)
    for (i=0;i<checkboxes.length;i++){
     if (checkboxes[i].checked)
       return true;
    }
  else
   if (checkboxes.checked)
     return true;

  alert("Please make selection first");
  return false;
}

function confirmDel(key)
{
  var alertMessage;

    switch(key) {

      case 'TV': alertMessage = "Do you want to delete this Channel?"; break;
      case 'PL': alertMessage = "Do you want to delete this Playlists?"; break          
      case 'CON': alertMessage = "Do you want to remove this user from your subscription?"; break          
      case 'VI': alertMessage = "Do you want to delete this Video?"; break          
      case 'GP': alertMessage = "Do you want to delete this Group?"; break          
      default  : alertMessage = "Are you sure you want to delete this data?";break;            

    }    
    
  return confirm(alertMessage);
}

function confirmDelete(currentform, actfield)
{
  if (!actfield)
    actfield = 'mode';

  if (currentform) {
    currentform[actfield].value='del';

    if (confirmDel())
      currentform.submit();
  }
  return false;
}

function getUrlParam(url, par)
{
  var rgx = "[\\?&]"+par+"=([^&#]*)";
  var regex = new RegExp(rgx);
  var matches = regex.exec(url);

  return (matches == null)? "" : matches[1];
}

function submitForm(frm, btn, text)
{
  if (btn) {
    btn.disabled = true;
    btn.value = text;
  }
  frm.submit();
}

function changeWidgetCode(wtype)
{
  var newcode = $('#widget_code').val();
  var w = $('#widget_width').val();
  var h = $('#widget_height').val();

  if (wtype == 1) {
    newcode = newcode.replace(/videowidget.*?\.swf/, "videowidget.swf");
    newcode = newcode.replace(/width=".*?"/, "width=\""+w+"\"");
    newcode = newcode.replace(/height=".*?"/, "height=\""+h+"\"");
  } else {
    newcode = newcode.replace(/videowidget.*?\.swf/, "videowidget_s.swf");
    newcode = newcode.replace(/width=".*?"/, "width=\"380\"");
    newcode = newcode.replace(/height=".*?"/, "height=\"285\"");
  }

  $('#widget_code').val(newcode);
  var embed_regex = new RegExp(/<embed.*<\/embed>/);
  var embed_code = embed_regex.exec(newcode);

  if (embed_code)
    $('#embed_code').html(embed_code[0]);

  return false;
}

function getVideoInfo(videourl)
{
  if (videourl.value == '') {
    alert('Please enter video url');
    return false;
  }

  oldbuttonval = $('#getvideo').val();
  $('#getvideo').val('Retrieving info...').attr({'disabled': 'disabled'});

  if(videourl.value != undefined){ 
  $.post('getvideoinfo.php',
         {'url' : videourl.value},
         function(json) {
           $('#getvideo').val(oldbuttonval).removeAttr('disabled');
           result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#getinfomsg').html(result.returnmsg).slideDown('slow').animate({opacity:1}, 7000).slideUp('slow');
           } else {
             $('#title').val(result.title);
             $('#thumbnail_url').val(result.thumbnail);
             $('#description').val(result.description);
             $('#tags').val(result.tags);
             $('#embed_code').val(result.embed_code);
           }
         });
    } else {
    $.post('getvideoinfo.php', //Bookmarklet
         {'url' : videourl},
         function(json) {
          //$('#getvideo').val(oldbuttonval).removeAttr('disabled');
           result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#getinfomsg').html(result.returnmsg).slideDown('slow').animate({opacity:1}, 7000).slideUp('slow');
           } else {
             $('#title').val(result.title);
             $('#thumbnail_url').val(result.thumbnail);
             $('#description').val(result.description);
             $('#tags').val(result.tags);
             $('#embed_code').val(result.embed_code);
           }
         });
 
    }
  return false;
}


function getTVInfo(TVurl)
{
  if (TVurl.value == '') {
    alert('Please enter Channel url');
    return false;
  }

  /*oldbuttonval = $('#getvideo').val();
  $('#getvideo').val('Retrieving info...').attr({'disabled': 'disabled'});*/
if(TVurl.value != undefined){ 
  $.post('getTVinfo.php',
         {'url' : TVurl.value},
         function(json) {
           $('#getvideo').val(oldbuttonval).removeAttr('disabled');
           result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#getinfomsg').html(result.returnmsg).slideDown('slow').animate({opacity:1}, 7000).slideUp('slow');
           } else {
             $('#title').val(result.title);
             $('#thumbnail_url').val(result.thumbnail);
             $('#description').val(result.description);
             $('#url').val(result.url);
             $('#embed_code').val(result.embed_code);
           }
         });
    } else {

 $.post('getTVinfo.php',
         {'url' : TVurl},
         function(json) {
          //$('#getvideo').val(oldbuttonval).removeAttr('disabled');
           result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#getinfomsg').html(result.returnmsg).slideDown('slow').animate({opacity:1}, 7000).slideUp('slow');
           } else {
             $('#title').val(result.title);
             $('#thumbnail_url').val(result.thumbnail);
             $('#description').val(result.description);
            $('#url').val(result.url);
             $('#embed_code').val(result.embed_code);
           }
         });

    }
  
}



function addComment(frm)
{
  $('#cmt_msg').slideUp();
  var oldbuttonval = $('#addcomment').val();
  $('#addcomment').val('Adding comment...').attr({'disabled': 'disabled'});
  $.post(IVIDPLAY_BASE_DIR+'comment/add.php',
         {'ajax' : '1',
          'timestamp' : frm.timestamp.value,
          'video_id' : frm.video_id.value,
          'name' : frm.name.value,
          'comment' : frm.comment.value},
         function(json) {
           $('#addcomment').val(oldbuttonval).removeAttr('disabled');
           var result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#cmt_msg').html(result.returnmsg).slideDown();
           } else {
             frm.reset();
             $('#cmt_nocomment').remove();
             if (getUrlParam($('#link_newer').attr('href'), 'cst') == '1') {
               $('.cmt_nav').css({'display': 'block', 'visibility': 'visible'});
               $(result.comment).hide().prependTo('#cmt_comments').fadeIn('slow');
             } else {
               var url = $('#link_newer').attr('href').replace(/cst=\d+/, 'cst=1');
               $('#link_newer').attr({'href' : url});
               url = $('#link_older').attr('href').replace(/cst=\d+/, 'cst=1');
               $('#link_older').attr({'href' : url});
               loadComments($('#link_newer'), 'reload');
             }
           }
         });
  return false;
}

function addComment_tv(frm)
{

  $('#cmt_msg').slideUp();
  var oldbuttonval = $('#addcomment').val();
  $('#addcomment').val('Adding comment...').attr({'disabled': 'disabled'});
  $.post(IVIDPLAY_BASE_DIR+'comment/add.php',
         {'ajax' : '1',
          'timestamp' : frm.timestamp.value,
          'video_id' : frm.video_id.value,
          'name' : frm.name.value,
	  'type' : frm.type.value,
          'comment' : frm.comment.value},
         function(json) {
           $('#addcomment').val(oldbuttonval).removeAttr('disabled');
           var result = eval('('+json+')');
           if (result.returnval != 1) {
             $('#cmt_msg').html(result.returnmsg).slideDown();
           } else {
             frm.reset();
             $('#cmt_nocomment').remove();
             if (getUrlParam($('#link_newer').attr('href'), 'cst') == '1') {
               $('.cmt_nav').css({'display': 'block', 'visibility': 'visible'});
               $(result.comment).hide().prependTo('#cmt_comments').fadeIn('slow');
             } else {
               var url = $('#link_newer').attr('href').replace(/cst=\d+/, 'cst=1');
               $('#link_newer').attr({'href' : url});
               url = $('#link_older').attr('href').replace(/cst=\d+/, 'cst=1');
               $('#link_older').attr({'href' : url});
               loadComments($('#link_newer'), 'reload');
             }
           }
         });
  return false;
}

function loadComments(obj, getcmt)
{
  var params = $(obj).attr('href').split('?');

  $.get(IVIDPLAY_BASE_DIR+'comment/load.php?'+params[1],
         function(json) {
           var result = eval('('+json+')');
           if (result.returnval == 1) {
             $('#cmt_comments').fadeOut('fast', function() { $(this).html(result.comments).fadeIn('slow'); });

             if (getcmt != 'reload') {
               var url = $('#link_newer').attr('href').replace(/cst=\d+/, 'cst='+result.cst);
               $('#link_newer').attr({'href' : url});
               url = $('#link_older').attr('href').replace(/cst=\d+/, 'cst='+result.cst);
               $('#link_older').attr({'href' : url});
             }
           }
        });
  return false;
}

function delVideo(href, divid)
{

  if (confirmDel("VI")) {
    var video_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_video.php?id='+video_id+'&token='+token,
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}

function finishEditPosition(divid,vid,newval,video_id) {

	if(newval == vid) {
	document.getElementById(divid).style.display = "block";
	document.getElementById("update_"+divid).style.display = "none";
	return false;
	} else {
	location.replace(IVIDPLAY_BASE_DIR+'member/changepos.php?video_id='+video_id+'&newpos='+newval+'&oldpos='+vid);
	}

}

function editPosition(vid, divid,videoid) {
//document.getElementById(divid).innerHTML="<b>Position :&nbsp;</b> <input type ='text' id='"+vid+"' size='3' maxlength='4' value='"+vid+"' onblur=finishEditPosition('"+divid+"','"+vid+"',this.value,'"+videoid+"') onkeypress='return numOnly(event)' >";
document.getElementById(divid).style.display = "none";
document.getElementById("update_"+divid).style.display = "block";
document.getElementById(vid).focus();
return false;
}

/*
function delPlaylist(href, divid)
{
  if (confirmDel()) {
    var playlist_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_playlist.php?id='+playlist_id+'&token='+token,
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}
*/


function delPlaylist(href, divid)
{

  if (confirmDel("PL")) {
    var playlist_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_playlist.php?id='+playlist_id+'&token='+token+'&delvideo=FALSE',
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { 
              if(confirm(result.returnmsg))
		{
		delPlaylist_videos(href,divid)
		}
            });
            }
          });
  }
  return false;
}

function delgroup(href, divid) {

    if (confirmDel("GP")) {

        var group_id = getUrlParam(href, 'id');
        var token = getUrlParam(href, 'token');
        $('#'+divid).fadeTo('slow', 0.33);
        $.get(IVIDPLAY_BASE_DIR+'ajax/del_group.php?id='+group_id+'&token='+token,
	    function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
        
        
    }

    return false;

}

function delPlaylist_videos(href,divid)
{
 var token = getUrlParam(href, 'token');
  var playlist_id = getUrlParam(href, 'id');
 $('#'+divid).fadeTo('slow', 0.33);
 $.get(IVIDPLAY_BASE_DIR+'ajax/del_playlist.php?id='+playlist_id+'&token='+token+'&delvideo=TRUE',
	function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
}

function TDown(cid,view) {

   
    var token =  Math.random();
    $('#thumbs-'+cid).html("<img src='"+IVIDPLAY_BASE_DIR+"images/spinner.gif'/>");
            $.ajax({
			type: "POST",
			data: 'id='+cid+'&token='+token+'&action=down&view='+view,
			url: IVIDPLAY_BASE_DIR+'ajax/thumbs.php',
			success: function(msg)
			{
                               
				document.getElementById('thumbs-'+cid).innerHTML = msg;
				
			}
      });
      
}
function TUp(cid,view) {

    var token =  Math.random();

    $('#thumbs-'+cid).html("<img src='"+IVIDPLAY_BASE_DIR+"images/spinner.gif'/>");
            $.ajax({
			type: "POST",
			data: 'id='+cid+'&token='+token+'&action=up&view='+view,
			url: IVIDPLAY_BASE_DIR+'ajax/thumbs.php',
			success: function(msg)
			{
				document.getElementById('thumbs-'+cid).innerHTML = msg;
                               
			}
      });

}


function deltv(href, divid)
{

if (confirmDel("TV")) {
    var tv_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_tv.php?id='+tv_id+'&token='+token,
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}


function delFromGroup(href,divid,contentType){
       if(confirmDel(contentType)) {
           var content_id = getUrlParam(href, 'cid');
           var token = getUrlParam(href, 'token');

           $('#'+divid).fadeTo('slow', 0.33);
           $.get(IVIDPLAY_BASE_DIR+'ajax/removeFromGroup.php?cid='+content_id+'&token='+token,
           function(json) {
              var result = eval('('+json+')');
              if (result.returnval == 1) {
                $('#'+divid).fadeOut('slow');
              } else {
                $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
              }
          });

       }
       return false;
}


function delContact(href,divid,contact_id)
{
  if (confirmDel("CON")) {
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_contact.php?id='+contact_id,
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}

function delSubscribed(href, divid)
{
  if (confirm('Are you sure want to unsubscribe this playlist?')) {
    var playlist_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_subscribed.php?id='+playlist_id+'&token='+token,
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}

function delSubscribed_tv(href, divid)
{
  if (confirm('Are you sure want to unsubscribe this channel?')) {
    var tv_id = getUrlParam(href, 'id');
    var token = getUrlParam(href, 'token');
    $('#'+divid).fadeTo('slow', 0.33);
    $.get(IVIDPLAY_BASE_DIR+'ajax/del_subscribed.php?id='+tv_id+'&token='+token+'&type=channel',
          function(json) {
            var result = eval('('+json+')');
            if (result.returnval == 1) {
              $('#'+divid).fadeOut('slow');
            } else {
              $('#'+divid).fadeTo('fast', 1, function() { alert(result.returnmsg); });
            }
          });
  }
  return false;
}

function reportInappropriate(id, uid, reason)
{
	if (reason == "") {
		alert('Please choose your reason..');	
		return false;
	}
	if (id != "") {
		var report = confirm("Are you sure want to report this video as inappropriate ??");
		if (report) {
			$.get(IVIDPLAY_BASE_DIR + 'ajax/report_video.php?mode=r_inappropriate&id=' + id + '&uid=' + uid + '&reason=' + reason);
			$('#inappropriate_flag').html('Thank you for reporting this video');
			$('#inappropriate').toggle();
		}
	}
}


function reportInappropriate_tv(id, uid, reason)
{
	if (reason == "") {
		alert('Please choose your reason..');	
		return false;
	}
	if (id != "") {
		var report = confirm("Are you sure want to report this channel as inappropriate ??");
		if (report) {
			$.get(IVIDPLAY_BASE_DIR + 'ajax/report_channel.php?mode=r_inappropriate&id=' + id + '&uid=' + uid + '&reason=' + reason);
			$('#inappropriate_flag').html('Thank you for reporting this Channel');
			$('#inappropriate').toggle();
		}
	}
}


function reportLink(id, uid, url)
{
	if (url != "") {
		$.get(IVIDPLAY_BASE_DIR + 'ajax/report_video.php?mode=r_brokenlink&id=' + id + '&uid=' + uid + '&url=' + url);
	}
	else {
		$.get(IVIDPLAY_BASE_DIR + 'ajax/report_video.php?mode=r_brokenlink&id=' + id);
	}
	$('#broken_link').hide();
	$('#report_broken_link').html('Thank you for reporting this video');
}

function reportLink_TV(id, uid, url)
{
	if (url != "") {
		$.get(IVIDPLAY_BASE_DIR + 'ajax/report_channel.php?mode=r_brokenlink&id=' + id + '&uid=' + uid + '&url=' + url);
	}
	else {
		$.get(IVIDPLAY_BASE_DIR + 'ajax/report_channel.php?mode=r_brokenlink&id=' + id);
	}
	$('#broken_link').hide();
	$('#report_broken_link').html('Thank you for reporting this Channel');
}


function numOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[0-9]/
		return re.test(keyChar);
	}	
}

function alphaOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[a-zA-Z]/
		return re.test(keyChar);
	}	
}

function alphaNumOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[a-zA-Z0-9_-]/
		return re.test(keyChar);
	}	
}

function alphaNumSpaceOnly(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /[\sa-zA-Z0-9_-]/
		return re.test(keyChar);			
	}	
}

function noWhiteSpace(evt)
{	
	var charCode = (evt.which) ? evt.which : window.event.keyCode;

	if (charCode <= 13)
	{
		return true;
	}
	else
	{
		var keyChar = String.fromCharCode(charCode);
		var re = /\s/ 
		return !re.test(keyChar);
	}	
}


function invite_friend(userid,spid,imgUrl) {

        $('#'+spid).html('<img src='+imgUrl+'load.gif>');
        if (userid != "") {
           
        $.get(IVIDPLAY_BASE_DIR + 'ajax/friend_invite.php?fid='+userid);
        
         }
        $('#'+spid).html('A friend request has been sent for approval');
        return false;

}

/***********************************************
* What is this Pop up

***********************************************/

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="../images/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













var timeout	= 800;
var closetimer	= 0;
var ddmenuitem	= 0;

// open hidden layer
function mopen(id)
{	
	// cancel close timer
	mcancelclosetime();

	// close old layer
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';

	// get new layer and show it
	ddmenuitem = document.getElementById(id);
	ddmenuitem.style.visibility = 'visible';

}
// close showed layer
function mclose()
{
	if(ddmenuitem) ddmenuitem.style.visibility = 'hidden';
}

// go close timer
function mclosetime()
{
	closetimer = window.setTimeout(mclose, timeout);
}

// cancel close timer
function mcancelclosetime()
{
	if(closetimer)
	{
		window.clearTimeout(closetimer);
		closetimer = null;
	}
}

// close layer when click-out
document.onclick = mclose; 



