/* Variable Declarations
var sliding = false;
var slideInterval;
var gDirection;
var selItem=0;
var galleryItems=[]; */

// Cufone Replacements
Cufon.replace('h2.cufon');
Cufon.replace('#top_nav ul li a',{hover:true});
Cufon.replace('#landing_nav ul li a',{hover:true});
Cufon.replace('.img-link a');
Cufon.replace('#gallery_controls');
Cufon.replace('a#close_vid');

/*
var sliding = false;

// Event Observer Regsitrations
document.observe(
    'dom:loaded',
    function(){
		if($('featured_slides')) {
        Event.observe('featured_slides','mouseout', function() {slide('off')});
        Event.observe('featured_slides','mouseover', function() {slide('on')});
        
        Event.observe(
            'featured_slides',
            'mousemove',
            function(event){
                gDirection=event.pointerX()/(document.viewport.getWidth()/2)-1;
            }
        );
        
        $$('dt.gallery-icon a').each(
            function(n){
                Event.observe(
                    n,
                    'click',
                    function(event){
                        event.stop();
                        showLightbox(this.href,'close<span class=yellow-italic>photo</span>','image');
                        return false;
                    }
                );
            }
        );

        selItem=0;
        $$('.gallery-icon a').each(
            function(n){
                Event.observe(
                    n,
                    'click',
                    function(){
                        galleryNavigation(this);
                    }
                );
            }
        );
		}
    }
);

// Navigation/Gallery Slider Functions

function slide(action) {
    if (action == 'off'){
        clearInterval(slideInterval);
        sliding = false;
    } else {
        slideInterval=setInterval(slideAction,1);
        sliding = true;
    }
}

function slideAction() {
    $('slider').scrollLeft += gDirection * 10;
}

function swapPgImg(href) {
	if ($('page_image') != null) {
		$('page_image').src=href;
	} else {
		$('featured_photo1').replace(new Element('img', {src:href, id:'page_image', style:'width:820px;height:545px'}));
	}
}

function setFocusRing(elm, title, href) {
	rings = $$('.hilite_slide').invoke('hide');
}

// Custom Light Box/Featured Slider Functions

function toggleFeatured(){
    elm=$('featured');
    if(elm.style.left=='830px'||elm.style.left==""){
        new Effect.Move('featured',{x:0,y:84,mode:'absolute'});
    }else{
        new Effect.Move('featured',{x:830,y:84,mode:'absolute'});
    }
}

/*function showLightbox(file,closeString,lbType){
    if(lbType=='image'){
        $('vid_embed').hide();
        $('lbImage').src=file;
        $('lbImage').show();
        $('browsing_controls').show();
    }else{
        $('lbImage').hide();
        $('browsing_controls').hide(); 
        swfobject.embedSWF('http://www.coachchristensen.com/wp-content/themes/uwf/scripts/player.swf',"vid_embed","600","400","7.0.0",null,{'file':file+'&autostart=true'},{'wmode':'transparent','allowfullscreen':'true'});
        $('vid_embed').show();
    }
    
    window.location='#lbox';
    if(closeString !=null||closeString !=undefined){
        $('close_vid').innerHTML=closeString;
    }
    $('intro_screen').style.height = $('contents').offsetHeight+'px';
    $('intro_screen').show();
    Cufon.refresh('h2.cufon');
    Cufon.refresh('a#close_vid');

}

function hideLightbox(){
    $('intro_screen').style.display="none";
    window.location='#lboxclose';
    contents.scrollLeft = 0;
    contents.scrollTop = 0;
}*/
/*
function galleryNavigation(clickedElm){
    galleryItems=$$('.gallery-icon');
    var clickedItem=clickedElm.up();
    galleryItems.each(
        function(n,key){
            if(n==clickedItem){
                selItem=key;
            }
        }
    );
}

// Various image swapping functions

function changeGalleryItem(amount){
    selItem +=amount;
    
    if(selItem==-1){
        selItem=galleryItems.length - 1;
    }
    
    if(selItem==galleryItems.length){
        selItem=0;
    }
    
    $('lbImage').src=galleryItems[selItem].down().href;
}

var curA = ""
// sets up the mouseover/mouseout events for colorizing/greyscaling the thumbnail images.
function colorImg() {
	$$('.slider_link').each(function(elm) {
		// hide all the slide hilighters. 
		$$('.hilite_slide').invoke('hide');
		Event.observe(elm,'mouseout', function(event) {decolorize(elm.down().next().down());});
      Event.observe(elm,'mouseover', function() {colorize(elm.down().next().down());});
		Event.observe(elm,'mouseover', function() {colorize(elm.down().next().down());});
		Event.observe(elm,'click', function(e) {followLink(elm); e.stop();});
	});
}

function followLink(elm) {
	if(elm.up().hasClassName('gallery')) {
		swapPgImg(elm.down().next().href);
	} else {
		window.location = elm.down().next().href;
	}
}

function colorize(elm) {
	if(curA != elm) {
		curA = elm;
		$$('.hilite_slide').invoke('hide');
		elm.up().previous().appear({duration:0.10});
	}
	elm.src = elm.src.replace('bw_', '');
	
}

function decolorize(elm) {
	if(elm.src.indexOf('sub_nav') != -1) {
		// for IE make sure we didn't start with our mouse over this element when the page loaded.
		if(elm.src.indexOf('sub_nav_bw_') == -1) {
			elm.src = elm.src.replace('sub_nav_', 'sub_nav_bw_');
		}
	} else {
		old_src = elm.src;
		// if this isn't a blank image (no image was referenced in the CMS, which shouldn't happen :)
		// also for IE make sure we didn't start with our mouse over this element when the page loaded.
		if(old_src.indexOf('blank.gif') == -1 || old_src.indexOf('bw_') != -1) {
			slash = old_src.lastIndexOf('/');
			new_src = old_src.substring(0, slash + 1);
			elm.src = new_src + 'bw_' + old_src.substring(slash + 1);
		}
	}
	
}

// other colorizing/greyscaling used in featured section
function colorFeat(elm) {
	elm.src = elm.src.replace('bw_', '');
}

function decolorFeat(elm, url) {
	elm.src = url;
}

document.observe('dom:loaded', colorImg);
*/
