// alternate js file to avoid conflicts in jquery plugins

var swap_text_boxes = [];

function init_swap_text_boxes(){
  //Store the default value for each box
  $('input[type=text][value].swaptextbox').each(function() {
    swap_text_boxes[$(this).attr('id')] = $(this).attr('value');
  });
  //Add focus and blur events to set or clear the value
  $('input[type=text][value].swaptextbox').bind('focus', function() {
    if($(this).val() == swap_text_boxes[$(this).attr('id')]) {
      $(this).val('');
    }
  });
  $('input[type=text][value].swaptextbox').bind('blur', function() {
    if($(this).val() == '') {
      $(this).val(swap_text_boxes[$(this).attr('id')]);
    }
  });
}

$(document).ready(function(){ init_swap_text_boxes(); }); 

// dropdown implementation

$(document).ready(function() { 
    $('ul.main-nav').superfish({ 
        delay:       500,                            // half second delay on mouseout 
        animation:   {height:'show'},  				// slide-down animation 
        speed:       'medium',                          // slower animation speed 
        autoArrows: true,                           // enable generation of arrow mark-up 
        dropShadows: true                            // enable drop shadows 
    }); 
});	


//image slideshow

$(document).ready(function() {
    $('.image-slides').cycle()
});


// loader 


$(document).ready(function(){
			
	$('#preloaded_content').hide();

	});		  
		  
function showContent(){
	$('#preloaded_content').show();
	$('#loading').hide();
}


//range functions 

// Cycle implementation on gallery tabs 
// auto advance, and pager fns.

$(function() {

	$('#slideshow').before('<ul id="nav">').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 0, 
	    pager:  '#nav', 
	    pagerEvent: 'mouseover',
		before:     function() {
            $('#caption').html(this.alt);				
		},
		after: function(){
			$('#slideshow').attr("style", "position:relative;left:10px;height:"+ this.height + "px");
		},

	     
	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>'; 		
	    } 		 
	});		
});

// Cycle implementation on deck tabs 
// auto advance, and pager fns.

$(function() {

	$('#slideshow2').after('<ul id="nav2">').cycle({ 
	    fx:     'fade', 
	    speed:  'slow', 
	    timeout: 0, 
	    pager:  '#nav2', 
	    pagerEvent: 'mouseover',
		before:     function() {
            $('#caption2').html(this.alt)
		},
	     
	    // callback fn that creates a thumbnail to use as pager anchor 
	    pagerAnchorBuilder: function(idx, slide) { 
	        return '<li><a href="#"><img src="' + slide.src + '" width="80" height="40" /></a></li>'; 
	    } 
	});		
});	

//z-index ie 7 bug fix

$(function() {
	var zIndexNumber = 1000;
	$('ul').each(function() {
		$(this).css('zIndex', zIndexNumber);
		zIndexNumber -= 10;
	});
});
