function doRateLib( rate, id ) {
   var ajax = new dle_ajax();
   ajax.onShow ('');
   var varsString = "go_rate=" + rate;
   ajax.setVar("b_id", id);
   ajax.setVar("skin", dle_skin);
   ajax.requestFile = dle_root + "engine/ajax/lib_rating.php";
   ajax.method = 'GET';
   ajax.element = 'ratig-layer';
   ajax.sendAJAX(varsString);
};

function dleRateLib( rate, id ) {
   var ajax = new dle_ajax();
   ajax.onShow ('');
   var varsString = "go_rate=" + rate;
   ajax.setVar("b_id", id);
   ajax.setVar("skin", dle_skin);
   ajax.setVar("mode", "short");
   ajax.requestFile = dle_root + "engine/ajax/lib_rating.php";
   ajax.method = 'GET';
   ajax.element = 'ratig-layer-' + id;
   ajax.sendAJAX(varsString);
};

function doAddCommentsLib()
{
   var form = document.getElementById('dle-comments-form');
    var dle_comments_ajax = new dle_ajax();

   if (dle_wysiwyg == "yes")
   {
      document.getElementById('comments').value = tinyMCE.get('comments').getContent();
      dle_comments_ajax.setVar("editor_mode", 'wysiwyg');
   } else {
      closeall();
   }

   if (form.comments.value == '' || form.name.value == '')
   {
      alert ( dle_req_field );
      return false;
   }

   dle_comments_ajax.onShow ('');
   var varsString = "b_id=" + form.b_id.value;
   dle_comments_ajax.setVar("comments", dle_comments_ajax.encodeVAR(form.comments.value));
   dle_comments_ajax.setVar("name", dle_comments_ajax.encodeVAR(form.name.value));
   dle_comments_ajax.setVar("mail", dle_comments_ajax.encodeVAR(form.mail.value));
   dle_comments_ajax.setVar("skin", dle_skin);

   if ( form.sec_code )
   {
      dle_comments_ajax.setVar("sec_code", form.sec_code.value);
   }

   dle_comments_ajax.requestFile = dle_root + "engine/ajax/lib_addcomments.php";
   dle_comments_ajax.method = 'POST';
   dle_comments_ajax.execute = true;
   dle_comments_ajax.element = 'dle-ajax-comments';
   dle_comments_ajax.sendAJAX(varsString);

};
function lib_dle_copy_quote(qname) 
{
 lib_dle_txt='';

   if (document.getSelection) 
   {
    lib_dle_txt=document.getSelection();
   }
   else if (document.selection) 
   {
    lib_dle_txt=document.selection.createRange().text;
   }
   if (lib_dle_txt.replace(" ","") != "")
   {
    lib_dle_txt='[quote='+qname+']'+lib_dle_txt+'[/quote]\n';
   }
};

function LibMenuCommBuild( m_id, b_id )
{
var lib_menu=new Array();

lib_menu[0]='<a onclick="lib_ajax_comm_edit(\'' + m_id + '\'); return false;" href="#">' + menu_short + '</a>';
lib_menu[1]='<a href="' + dle_root + 'index.php?do=library&action=comments&subaction=edit&id=' + m_id + '&book_id=' + b_id + '">' + menu_full + '</a>';

return lib_menu;
};

function lib_ajax_comm_edit( c_id )
{
   if ( ! c_cache[ c_id ] || c_cache[ c_id ] == '' )
   {
      c_cache[ c_id ] = document.getElementById( 'comm-id-'+c_id ).innerHTML;
   }

   var ajax = new dle_ajax();
   comm_id = c_id;
   ajax.onShow ('');
   var varsString = "";
   ajax.setVar("id", c_id);
   ajax.setVar("action", "edit");
   ajax.requestFile = dle_root + "engine/ajax/lib_editcomments.php";
   ajax.method = 'GET';
   ajax.element = 'comm-id-'+c_id;
   ajax.execute = true;
   ajax.onCompletion = whenCompletedCommentsEdit;
   ajax.sendAJAX(varsString);
   return false;
};

function lib_ajax_cancel_comm_edit( c_id )
{
   if ( n_cache[ c_id ] != "" )
   {
      document.getElementById( 'comm-id-'+c_id ).innerHTML = c_cache[ c_id ];
   }
   
   return false;
};

function lib_whenCompletedSaveComments()
{
   c_cache[ comm_edit_id ] = '';
}

function lib_ajax_save_comm_edit( c_id )
{
   var ajax = new dle_ajax();
   var comm_txt = '';

   comm_edit_id = c_id;
   ajax.onShow ('');

   if (dle_wysiwyg == "yes")
   {
      comm_txt = ajax.encodeVAR( tinyMCE.get('dleeditcomments'+c_id).getContent() );
   } else {
      comm_txt = ajax.encodeVAR( document.getElementById('dleeditcomments'+c_id).value );
   }

   var varsString = "comm_txt=" + comm_txt;
   
   ajax.setVar("id", c_id);
   ajax.setVar("action", "save");
   ajax.requestFile = dle_root + "engine/ajax/lib_editcomments.php";
   ajax.method = 'POST';
   ajax.element = 'comm-id-'+c_id;
   ajax.onCompletion = lib_whenCompletedSaveComments;
   ajax.sendAJAX(varsString);

   return false;
};

function del_cat()
{
    return confirm( dle_del_agree );
}

function alpha_type( alpha_type )
{
   var ajax = new dle_ajax();
   ajax.onShow ('');
   var varsString = "";
   ajax.setVar("alpha_type", alpha_type);
   ajax.requestFile = dle_root + "engine/ajax/lib_alpha_type.php";
   ajax.method = 'POST';
   ajax.element = 'alpha';
   ajax.sendAJAX(varsString);
}

function LibShowOrHide(d1)
{
     if (d1 != '') LibDoDiv(d1);
};

function LibDoDiv(id)
{
     var item = null;
     if (document.getElementById) {
      item = document.getElementById(id);
     } else if (document.all) {
      item = document.all[id];
     } else if (document.layers){
      item = document.layers[id];
     }
     if (!item) { } else if (item.style) {
     if (item.style.display == "none"){ item.style.display = ""; }
     else {item.style.display = "none"; }
     } else{ item.visibility = "show"; }
};

function send_download_captcha( code , b_id)
{
  var ajax = new dle_ajax();
   ajax.onShow ('');
   var varsString = "";
   ajax.setVar("sec_code", sec_code);
    ajax.setVar("b_id", b_id);
   ajax.requestFile = dle_root + "engine/ajax/lib_download_captcha.php";
   ajax.method = 'POST';
   ajax.element = 'download_area';
   ajax.sendAJAX(varsString);
}


/***********************************************
* Show Hint script- c Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
        
var horizontal_offset="9px" //horizontal offset of hint box from anchor link

/////No further editting needed

var vertical_offset="0" //horizontal offset of hint box from anchor link. No need to change.
var ie=document.all
var ns6=document.getElementById&&!document.all

function getposOffset(what, offsettype){
var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop;
var parentEl=what.offsetParent;
while (parentEl!=null){
totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;
parentEl=parentEl.offsetParent;
}
return totaloffset;
}

function iecompattest(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function clearbrowseredge(obj, whichedge){
var edgeoffset=(whichedge=="rightedge")? parseInt(horizontal_offset)*-1 : parseInt(vertical_offset)*-1
if (whichedge=="rightedge"){
var windowedge=ie && !window.opera? iecompattest().scrollLeft+iecompattest().clientWidth-30 : window.pageXOffset+window.innerWidth-40
dropmenuobj.contentmeasure=dropmenuobj.offsetWidth
if (windowedge-dropmenuobj.x < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure+obj.offsetWidth+parseInt(horizontal_offset)
}
else{
var windowedge=ie && !window.opera? iecompattest().scrollTop+iecompattest().clientHeight-15 : window.pageYOffset+window.innerHeight-18
dropmenuobj.contentmeasure=dropmenuobj.offsetHeight
if (windowedge-dropmenuobj.y < dropmenuobj.contentmeasure)
edgeoffset=dropmenuobj.contentmeasure-obj.offsetHeight
}
return edgeoffset
}

function showhint(menucontents, obj, e, tipwidth){
if ((ie||ns6) && document.getElementById("hintbox")){
dropmenuobj=document.getElementById("hintbox")
dropmenuobj.innerHTML=menucontents
dropmenuobj.style.left=dropmenuobj.style.top=-500
if (tipwidth!=""){
dropmenuobj.widthobj=dropmenuobj.style
dropmenuobj.widthobj.width=tipwidth
}
dropmenuobj.x=getposOffset(obj, "left")
dropmenuobj.y=getposOffset(obj, "top")
dropmenuobj.style.left=dropmenuobj.x-clearbrowseredge(obj, "rightedge")+obj.offsetWidth+"px"
dropmenuobj.style.top=dropmenuobj.y-clearbrowseredge(obj, "bottomedge")+"px"
dropmenuobj.style.visibility="visible"
obj.onmouseout=hidetip
}
}

function hidetip(e){
dropmenuobj.style.visibility="hidden"
dropmenuobj.style.left="-500px"
}

function createhintbox(){
var divblock=document.createElement("div")
divblock.setAttribute("id", "hintbox")
document.body.appendChild(divblock)
}

if (window.addEventListener)
window.addEventListener("load", createhintbox, false)
else if (window.attachEvent)
window.attachEvent("onload", createhintbox)
else if (document.getElementById)
window.onload=createhintbox

