function selectlinks(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

$(function(){

	if(typeof console === "undefined") {
		console = { log: function() { } };
	}
	
	var $ = jQuery;
	var AJ;
	
	var DSBI	=	{

		forms: function(){
			$('.default').each(function() {
				var default_value = this.value;
				$(this).focus(function() {
					if(this.value == default_value) {
					this.value = '';
					}
				});
				$(this).blur(function() {
					if(this.value == '') {
					this.value = default_value;
					}
				});
			});
			if ($('select').length > 0) {
				$('select').selectmenu();
			}
		},

		placeholders: function() {
			var showPlaceholder = function(input) {    
				//see if there is HTML5 support - if so bail out... no need for the rest
				if ('placeholder' in document.createElement('input')) return;
				var placeholderText = input.attr("placeholder");
				if ( input.val() === "" || input.val() === placeholderText ) {
					input.val(placeholderText);
				}
			};	
			$("input[type=text][placeholder]").each(function() {
				showPlaceholder($(this));
			}).blur(function() {
				showPlaceholder($(this));
			}).focus(function() {
				var input = $(this);
				if (input.val() === input.attr("placeholder")) {
					input.val("");
				}
			});
		},

		ui: function(){
			var config = {
				over: function(){$(this).addClass('over');},
				timeout: 300,
				out: function(){$(this).removeClass('over');}
			};
			$('#header ul li').hoverIntent(config);
			$('#header ul li:last-child').addClass('last');
			if ($('#home-slideshow-slides').length > 0) {
				$('#home-slideshow-slides').nivoSlider({
					effect:'boxRain',
					pauseTime:5000,
					controlNav:true,
					captionOpacity:1
				});
			}
			if ($('#slideshow').length > 0) {
				$('#slideshow').cycle({
					fx: 'scrollHorz',
					cleartypeNoBg: true,
					activePagerClass: 'active',
					timeout: 0,
					prev: '#nav-bar .prev',
					next: '#nav-bar .next',
					pager: '#nav-bar ul',
					pagerAnchorBuilder: function(idx, slide) {
						return '#nav-bar ul li:eq(' + (idx) + ') a';
					}
				});
			}
			if ($('#home-thumbs').length > 0) {
				$('#home-thumbs').jcarousel({ scroll: 6 });
			}
			if ($('a[rel="colorbox"]').length > 0) {
				$('a[rel="colorbox"]').colorbox({
					opacity: 0.5
				});
			}
			$('.cleared').append('<span class="clear"></span>');
			
			$('#cboxWrapper').mouseenter(function(event) {
				$('#cboxNext').css('visibility', 'visible');
				$('#cboxPrevious').css('visibility', 'visible');
			});
			
			$('#cboxWrapper').mouseleave(function(event) {
				$('#cboxNext').css('visibility', 'hidden');
				$('#cboxPrevious').css('visibility', 'hidden');
			});
			
			console.log($('#customer-login').contents());
			
		},
							
		init: function(){
			DSBI.forms();
			DSBI.placeholders();
			DSBI.ui();
		}

	};
	
	DSBI.init();

});
