// disable window.alert through site
// window.alert=function(msg){}

$(document).ready( function() {
	
	var url = window.location.toString();
	if (url.charAt(url.length-1) == '/') {
		url = url.substring(0, url.length-1);
	}
	
	var url_split = url.split('/');
	catalog = url_split[url_split.length-1];
	selectorClass = '';
	// catalog image header
	if (catalog == 'boys' || catalog == 'girls') {
		$('#headerImage').addClass('show')
	}
	
	// left navigation
	if (url.indexOf('boys') != -1) {
		$('#boys .submenu').removeClass('hide');
		$('#boys .submenu').addClass('show');
		// $('#boys').addClass('selected');
	}
	else if (url.indexOf('girls') != -1) {
		$('#girls .submenu').removeClass('hide');
		$('#girls .submenu').addClass('show');
		// $('#girls').addClass('selected');
	}
	else if (url.indexOf('accessories') != -1) {
		$('#accessories .submenu').removeClass('hide');
		$('#accessories .submenu').addClass('show');
		// $('#accessories').addClass('selected');
	}
	
	$('.' + catalog).addClass('selected');
	
	$('.productCaptioning').hover(
		function() {
			e = $(".caption", this);
			p = $(".caption p", this);
			to_move = 125 - p.height();
			to_move += 'px';
			$(e).stop().animate({top: to_move},{queue:false,duration:500});
		},
		function() {
			e = $(".caption", this);
			$(e).stop().animate({top:'135px'},{queue:false,duration:500});  
		}
	);
	
	$(".jqzoom").jqzoom({ zoomWidth: 300, zoomHeight: 300 });
	
	$("#homeNavigation .boys, #homeNavigation .girls, #homeNavigation .accessories").hover(
		function() {
			image = '/images/home/' + $(this).attr('class') + '_roll.gif';
			$(this).attr('src', image);
		},
		function () {
			image = '/images/home/' + $(this).attr('class') + '.gif';
			$(this).attr('src', image);
		}
	);
	
	if ( $('.alternateImage').attr('href') != "" ) {
		$('.alternateView').css('display', 'block');
	}
	var ALTERNATE_VIEW = $('.alternateView').attr('href');
	// alert(ALTERNATE_VIEW);
	$(".alternateImage").fancybox({
		'titlePosition'		: 'inside',
		'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});		
});
