// *******************************************************************
// fader.js - a small JavaScript mouseOver fade in and out library
// Developed by Martin Joergensen, (c) 2005
// martin@globalflyfisher.com, http://globalflyfisher.com
// This code is licensed under the Noncommercial Creative Commons License
// You are not only encouraged to use it noncommercially but also to develop it
// Please credit me if you use or redistribute it

// Global timer table
var timers=new Array();

function _fade_in(element, opacity) // private
    {
    // Get object
    obj = document.getElementById(element);

    // Tidy up timer and register
    stop_timeout(element);

    // Make visible
    if (opacity==0)
        obj.style.visibility="";

    // Fade in one more step
    if (opacity <= 100) {
        _set_opacity(obj, opacity);
        opacity+=10;
        window.setTimeout("_fade_in(\'"+element+"\',"+opacity+")", 50);
        }

    // If fully visible, start countdown to fade out
    if (opacity >= 100) {
       // window.setTimeout("_fade_out(\'"+element+"\', 100)", 5000);
        }
    }

function _fade_out(element, opacity) // private 
    {

    // Get object
    obj = document.getElementById(element);

    // If still visible, fade down one further step
    if (opacity > 0) {
        _set_opacity(obj, opacity);
        opacity-=10;
        window.setTimeout("_fade_out(\'"+element+"\',"+opacity+")", 50);
        }

    // If close to invisible, hide object completely
    if (opacity<10) {
        obj.style.visibility="hidden";
        }
    }

function _set_opacity(obj, opacity) // private
    {
    opacity=(opacity==100) ? 99.999 : opacity;

    // IE/Win
    obj.style.filter="alpha(opacity:"+opacity+")";

    // Safari<1.2, Konqueror
    obj.style.KHTMLOpacity=opacity/100;

    // Older Mozilla and Firefox
    obj.style.MozOpacity=opacity/100;

    // Safari 1.2, newer Firefox and Mozilla, CSS3
    obj.style.opacity=opacity/100;
    }
    
function fade_in(element) // public
    {
    var obj=document.getElementById(element);
    // Start timer
    timers[element]=setTimeout("_fade_in(\'"+element+"\', 0)", 100);
    }

function fade_out(element, e) // public
    {
    // Tidy up timer and register
    stop_timeout(element);

    // Make sure we´re outside the whole fading div
   
   
   // var relTarg;
   // if (e.relatedTarget) 
   //     relTarg = e.relatedTarget;
   // else if (e.toElement) 
    //    relTarg = e.toElement;

    // If all the way out, fade out
	
	
    //if (relTarg.id=="") 
        _fade_out(element, 100);
    }

function stop_timeout(element) // public
    {
    // Stop timer
    clearTimeout(timers[element]);

    // Clear register
    timers[element]=false;
    }
/*-------------TABLE HIGHLIGHT CODE---------------//
usage : 
<table width="100%" cellpadding="0" cellspacing="0" onMouseover="changeto('#FEEDE6')" onMouseout="changeback('')">

To exclude any cell(s) from the rollover effect,
simply give that cell an id="ignore_[number]"
declaration, inserted inside the <tr> tag. 
For example:  <tr id="ignore_1">
(for validation purposes the "number" should be different for each id.)

*/
function changeto(highlightcolor){
source=event.srcElement

if (source.tagName=="TR"||source.tagName=="TABLE")
return
while(source.tagName=="TD" || source.tagName=="SPAN" || source.tagName=="EM" || source.tagName=="STRONG" || source.tagName=="SUP" || source.tagName=="A" || source.tagName=="IMG")
source=source.parentElement	
if (source.style.backgroundColor!=highlightcolor&&source.id.replace(/[\d\/]+/g, '')!="ignore_")
source.style.backgroundColor=highlightcolor
}

function changeback(originalcolor){
if (event.fromElement.contains(event.toElement)||source.contains(event.toElement)||source.id.replace(/[\d\/]+/g, '')=="ignore_")
return
if (event.toElement!=source)
source.style.backgroundColor=originalcolor
}
//-------------TABLE HIGHLIGHT CODE---------------//

           
            
        






function confirmDelete(page)
{
var agree=confirm("Are you sure you want to delete \""+page+"\" from your library?");
	if (agree)
	return true ;
	else
	return false ;

}
function confirmDeleteAll()
{
var agree=confirm("Are you sure you want to delete all pages?");
	if (agree)
	return true ;
	else
	return false ;

}

function goTo(url,getIndex){
	if(getIndex==0){
		document.location.href = url;
	}
	
	if(getIndex==1){
		document.location.href = '../index.php';
	}
	 
}











function mailpage()
{
  mail_str = "mailto:?subject=" + document.title;
 // mail_str += "&body= " + document.title;
  mail_str += "&body=" + location.href; 
  location.href = mail_str;
}








function PrintThisPage() 
{ 
   var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
       sOption+="scrollbars=yes,width=1000,height=600,left=100,top=25"; 

   var sWinHTML = document.getElementById('contentstart').innerHTML; 
   
   var winprint=window.open("","",sOption); 
       winprint.document.open(); 
       winprint.document.write('<html><link href=../css/print.css rel=Stylesheet><body>'); 
       winprint.document.write(sWinHTML);          
       winprint.document.write('</body></html>'); 
       winprint.document.close(); 
       winprint.focus(); 
}
