
    // SLIDESHOW: set number of seconds to pause
    var seconds = 4;






    
    
    
    
    
    window.onload = function() {   
		prepcarousel();
    }

    var litems = new Array();
    var op = 9;
    var n = 0;

    function prepcarousel() {
    
	if(document.getElementById("carousel")) {
	    var carousel = document.getElementById("carousel");
	} else if (document.getElementById("carousel_split")) {
	    var carousel = document.getElementById("carousel_split");
	} else {
	    return;
	}
	var c = 0;
	for (var i = 0; i < carousel.childNodes.length; i++) {
	    if (carousel.childNodes[i].nodeName == 'LI') {
		litems[c] = carousel.childNodes[i];
		c++;
	    }
	}
	setzindex();
	if(slideshow==1){
		setTimeout("startslideshow(0)", seconds*1000);
	}
    }

    function setzindex() {
	n >= litems.length ? n = 0 : '';
	var z = litems.length - 1;
	var c;
	for (var i = 0; i < litems.length; i++) {
	    c = i + n;
	    c >= litems.length ? c -= litems.length : '';
	    litems[c].style.zIndex = z;
	    litems[c].style.opacity = 1;
	    litems[c].style.filter = 'alpha(opacity=100)';
	    z--;
	}
    }

	
    function startslideshow() {
	setzindex();
	var id = litems[n].getAttribute("id");
	fadeout(id);
    }
    
    function fadeout(id) {
    var body = document.body.id;
    if(body == 'home'){
	var el = document.getElementById(id);
	if (op >= 0) {
	    el.style.opacity = "0." + op;
	    el.style.filter = "alpha(opacity=" + op + "0)";
	    op--;
	    setTimeout('fadeout("' + id + '")', 60);
	} else {
	    el.style.opacity = "0";
	    el.style.filter = "alpha(opacity=0)";
	    op = 9;
	    n++;
	    setTimeout("startslideshow(" + n + ")", seconds*1000);
	}	
	}
    }
    
    
  	
	

    jQuery.noConflict();    // eliminates dispatchEvent error in error console
			    // subsequently requires jQuery(...) syntax rather than $(...)
    
    var menuisopen = 0;

    jQuery(document).ready(function() {
    
    jQuery(".li_contact_sub a").each(function(){
    	var href = jQuery(this).attr('href');
    	var url = window.location;
    	if(href == url){
    		jQuery(this).attr('id','selected');
    	}
 
    });
    
    jQuery(".subnav").each(function() {
			var side = jQuery(this).children().size();
			if(side > 0){
				jQuery(this).parent().addClass("arrow");
				jQuery(this).parent().addClass("sub-true");
				jQuery(this).addClass("sub-visible");
			}
			else {
				jQuery(this).parent().addClass("sub-false");
				jQuery(this).addClass("sub-hidden");
			}
	});
	
    
    
	var hovered = 0;
	
	jQuery(".subnav li a").each(function(){
	    	var subselect = jQuery(this).attr("id");
	    	if(subselect == 'selected'){
	    		menuisopen = 1;
	    	}
	    });	
	
	if (menuisopen == 1) {
	    //jQuery('li.sub-true .sub-visible').hide();
	    //jQuery('li.sub-true .sub-visible').show('blind');
	    jQuery("#sidenav li.sub-false .subnav").each(function(){
	    	jQuery(this).hide();
	    });
	    jQuery('.arrow').removeClass('arrow');
	} else {
	    jQuery('.subnav').hide();
	    jQuery('#sidenav li.sub-true').mouseover(function() {    
		if (!hovered) {
		    jQuery('.sub-visible').show('blind', function(){
			//document.getElementById("a_crudeoil").style.backgroundImage = 'none';
			jQuery(this).parent().removeClass("arrow");
		    });
		    hovered = 1;
		}
	    });
	}
    });

