// *******************************************************************
// 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 changeColor(menu,check,checkFont){

var onColor  = '#666666';
var outColor = '#FFFFFF';


	if(check==1){
			menu.style.backgroundImage='url(../images/nobg.png)';
			if(checkFont==1){
				menu.style.borderRight='1px solid #E7E7E7';
				menu.style.borderLeft='1px solid #F2F2F2';
			}
			if(checkFont==7){
				menu.style.borderRight='1px solid #CCCCCC';
			}
			else{
			    menu.style.borderRight='1px solid #E7E7E7';
			}
		menu.style.backgroundColor='#E2E4E7';
         menu.style.borderBottom ='none';
			if(checkFont==1){
				menu1.style.color= onColor;
				menu1.style.textDecoration ='underline';
				
				//bg_image.style.backgroundImage='url(/sasol_sf_2007/images/topframe/topmenu_side.gif)';

			}
			if(checkFont==2){
				menu2.style.color= onColor;
				menu2.style.textDecoration ='underline';
				
			}
			if(checkFont==3){
				menu3.style.color= onColor;
				menu3.style.textDecoration ='underline';
			}
			if(checkFont==4){
				menu4.style.color= onColor;
				menu4.style.textDecoration ='underline';
			}
			if(checkFont==5){
				menu5.style.color= onColor;
				menu5.style.textDecoration ='underline';
			}
			if(checkFont==6){
				menu6.style.color= onColor;
				menu6.style.textDecoration ='underline';
			}
			if(checkFont==7){
				menu7.style.color= onColor;
				menu7.style.textDecoration ='underline';
			}
			if(checkFont==8){
				menu8.style.color= onColor;
				menu8.style.textDecoration ='underline';
			}
			if(checkFont==9){
				menu9.style.color= onColor;
				menu9.style.textDecoration ='underline';
			}
			
	}
	if(check==0){
	menu.style.backgroundImage='url(/mr_ye_2008/images/menu/top_bg.png)';
	
			if(checkFont==1){
				menu.style.borderRight='1px solid #777777';
				menu.style.borderLeft='1px solid #CCCCCC';
			}
			if(checkFont==7){
				menu.style.borderRight='1px solid #CCCCCC';
			}
			else{
			    menu.style.borderRight='1px solid #777777';
			}
		menu.style.backgroundColor='#000000';
	     //menu.style.border ='1px solid #003399';   
			if(checkFont==1){
				menu1.style.color= outColor;
				menu1.style.textDecoration ='none';
				//bg_image.style.backgroundImage='url(/sasol_sf_2007/images/topframe/topmenu_side_2.gif)';

			}
			if(checkFont==2){
				menu2.style.color= outColor;
				menu2.style.textDecoration ='none';
				
			}
			if(checkFont==3){
				menu3.style.color= outColor;
				menu3.style.textDecoration ='none';
			}
			if(checkFont==4){
				menu4.style.color= outColor;
				menu4.style.textDecoration ='none';
			}
			if(checkFont==5){
				menu5.style.color= outColor;
				menu5.style.textDecoration ='none';
			}
			if(checkFont==6){
				menu6.style.color= outColor;
				menu6.style.textDecoration ='none';
			}
			if(checkFont==7){
				menu7.style.color= outColor;
				menu7.style.textDecoration ='none';
			}
			if(checkFont==8){
				menu8.style.color= outColor;
				menu8.style.textDecoration ='none';
			}
			if(checkFont==9){
				menu9.style.color= outColor;
				menu9.style.textDecoration ='none';
			}
	}
}
function changeColorSubNav(menu,check){

	if(check==1){			
		menu.style.backgroundColor='#FFFFFF';    
	}
	if(check==0){
		menu.style.backgroundColor='#F8F8F8';
	}
}



function doLightImage(image,element,text){
	
	//for(i=1;i<=7;i++){
		//if(i==element){
		//image[element].style.backgroundImage='url(images/home/sus_1d.jpg)';
		//id[element].style.visibility = 'visible';
	//}
	if(element==1){
		//image1.style.backgroundImage='url(images/home/sus_1d.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'visible';id1.style.display = 'inline';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==2){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2d.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'visible';id2.style.display = 'inline';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==3){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3d.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'visible';id3.style.display = 'inline';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==4){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4d.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'visible';id4.style.display = 'inline';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==5){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5d.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'visible';id5.style.display = 'inline';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==6){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6d.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'visible';id6.style.display = 'inline';
		id7.style.visibility = 'hidden';id7.style.display = 'none';
	}
	if(element==7){
		//image1.style.backgroundImage='url(images/home/sus_1.jpg)';
		//image2.style.backgroundImage='url(images/home/sus_2.jpg)';
		//image3.style.backgroundImage='url(images/home/sus_3.jpg)';
		//image4.style.backgroundImage='url(images/home/sus_4.jpg)';
		//image5.style.backgroundImage='url(images/home/sus_5.jpg)';
		//image6.style.backgroundImage='url(images/home/sus_6.jpg)';
		//image7.style.backgroundImage='url(images/home/sus_7d.jpg)';
		id1.style.visibility = 'hidden';id1.style.display = 'none';
		id2.style.visibility = 'hidden';id2.style.display = 'none';
		id3.style.visibility = 'hidden';id3.style.display = 'none';
		id4.style.visibility = 'hidden';id4.style.display = 'none';
		id5.style.visibility = 'hidden';id5.style.display = 'none';
		id6.style.visibility = 'hidden';id6.style.display = 'none';
		id7.style.visibility = 'visible';id7.style.display = 'inline';
	}
	
}
