function showThis(thisNumber, sector){
	var thisNumber = sector + thisNumber;
	var thisNumberClickHere = "click_here_" + thisNumber;

	if($(thisNumber).style.display == "none"){
		$(thisNumber).style.display = "block";
		$(thisNumberClickHere).style.display = "none";
	}else if($(thisNumber).style.display == "block"){
		$(thisNumber).style.display = "none";
		$(thisNumberClickHere).style.display = "block";
	}

}


function clickHere(information){

	var informationBox = "information_click_here" + information;
	var informationDetails = "information_" + information;

	if($(informationBox).style.display == "block"){
		$(informationBox).style.display = "none";
		$(informationDetails).style.display = "block";
	}else{
		$(informationBox).style.display = "block";
		$(informationDetails).style.display = "none";
	}

}





/****************************** BEGIN HOMEPAGE IMAGE SLIDESHOW ********************************/



function rotateActive(active){	


	var thisImage = "li#pic_" + active + 1;
	var thisImageli = "#rotator ul " + thisImage; 
	
	active = active - 1;
	var current = $noConflict("#rotator ul li.show");
	var next = $noConflict("#rotator ul li").get(active);

	
};


function rotate(active){	

	if(active){
		var thisImage = "li#pic_" + active + 1;
		var thisImageli = "#rotator ul " + thisImage; 

		active = "#pic_" + active;
		var current = $noConflict("#rotator ul li.show");
	
		if(active == '#pic_1'){
			var next = $noConflict("#rotator ul li").first();
		}else{
			var next = $noConflict("#rotator ul li").next(active);
		}

		
		next.css({
			opacity: 0.0
		})
		.addClass("show")
		.animate({
			opacity: 1.0
		}, 1000);

		current.animate({
			opacity: 0.0
		}, 1000)
		.removeClass("show");

	}else{

		var length = $noConflict("#rotator ul li").length;
		var current = $noConflict("#rotator ul li.show");

		if($noConflict("#rotator ul li.show")[0] == $noConflict("#rotator ul li")[length - 1]){
			var next = $noConflict("#rotator ul li").first();
		}else{
			var next = $noConflict("#rotator ul li.show").next();
		}

		
		next.css({
			opacity: 0.0
		})
		.addClass("show")
		.animate({
			opacity: 1.0
		}, 1000);

		current.animate({
			opacity: 0.0
		}, 1000)
		.removeClass("show");
	}
	
};


function theRotator(active){

	
	$noConflict("#rotator ul li").css({
		opacity:0.0
	});

	$noConflict("#rotator ul li:first").css({
		opacity:1.0
	});
	
	if(!active){
		setInterval("rotate()", 6000);
	}else{
		setInterval("rotateActive()", 6000);
		alert('is active');
	}
}



/************************** END HOMEPAGE IMAGE SLIDESHOW *********************************/




/************************** BEGIN COLLECTION FUNCTIONS ***********************************/


var $noConflict = jQuery.noConflict();



$noConflict(document).ready(function(){

	$noConflict("a.iframe").fancybox({
		'width'				: 500,
		'height'			: 400
	});


	$noConflict("div.inline_collection_details").fancybox({
		'width'				: 620,
		'height'			: 500,
		'padding'			: 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$noConflict("#question_fit").fancybox({
		'width'				: 620,
		'height'			: 500,
		'padding'			: 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none',
		'type'				: 'iframe'
	});

	$noConflict("#video_art").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_fabrics").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_fits").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_mini").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_ordering").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_pads").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_shorts").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_stitch").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});

	$noConflict("#video_zippers").fancybox({
	    'padding'           : 0,
        'autoScale'     	: false,
        'transitionIn'		: 'none',
		'transitionOut'		: 'none'
	});


			
});




function gallerySubView(selectThis){

	for(var i = 1; i <= $("gallery_options").getElementsByTagName("img").length; i++){
		$("gallery_options").getElementsByTagName("img")[i - 1].style.display = "none";
	}
	$("gallery_options").getElementsByTagName("img")[selectThis - 1].style.display = "block";

}


function inlineColors(selection_container, selection_image){

	var previousImage = $("showcase_active").value;
	var selection_image = selection_image / 2;

	for(var i = 0; i < $("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByTagName("img").length; i++){
		$("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByClassName("img_gallery_large")[i].style.display = "none";
	}

	// REMOVE PREVIOUS IMAGE FROM STAGE AND REPLACE WITH SELECTED IMAGE
	$("gallery_options").getElementsByClassName("img_gallery_large")[previousImage].style.display = "none";

	// REMOVE PREVIOUS LARGE COLOR PREVIEWS FROM STAGE
	for(var i = 0; i < $("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByTagName("img").length; i++){
		$("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByClassName("img_gallery_large")[i].style.display = "none";
	}

	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].getElementsByTagName("img")[selection_image].style.display = "block";

	
}

function inlineColors_backup(selection_container, selection_image){

	var selection_image = selection_image / 2;

	for(var i = 0; i < $("gallery_options").getElementsByClassName("inline_color_container").length; i++){
		$("gallery_options").getElementsByClassName("inline_color_container")[i].style.display = "none";
	}
	for(var j = 0; j < $("gallery_options").getElementsByClassName("img_gallery_large").length; j++){
		$("gallery_options").getElementsByClassName("img_gallery_large")[j].style.display = "none";
	}

	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].getElementsByTagName("img")[selection_image].style.display = "block";

	
}

function inlineColors_old(selection_container, selection_image){

	var selection_image = selection_image / 2;

	for(var i = 0; i < $("gallery_options").getElementsByClassName("inline_color_container").length; i++){
		$("gallery_options").getElementsByClassName("inline_color_container")[i].style.display = "none";
	}
	for(var j = 0; j < $("gallery_options").getElementsByClassName("img_gallery_large").length; j++){
		$("gallery_options").getElementsByClassName("img_gallery_large")[j].style.display = "none";
	}

	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[selection_container].getElementsByTagName("img")[selection_image].style.display = "block";

	
}

function previousPage(){

	var toPage = Number($("page_number").value) - 2;
	var fromPage = $("page_number").value - 1;

	if($("page_number").value > 1){
		$("page_number").value = Number($("page_number").value) - 1;
		$("gallery_container").getElementsByClassName("showcase_divisions")[fromPage].style.display = "none";
		$("gallery_container").getElementsByClassName("showcase_divisions")[toPage].style.display = "block";

		var pageCounter = $("page_number").value * 10;
		galleryView(pageCounter - 10);
	}

	for(var j = 0; j < $("page_turn_container").getElementsByClassName("page_turn").length; j++){
		$("page_turn_container").getElementsByClassName("page_turn")[j].style.display = "none";
	}		
	if($("page_number").value == 1){
		$("previous_page_off").style.display = "block";
		$("previous_page").style.cursor = "default";
		$("next_page_on").style.display = "block";
		$("next_page").style.cursor = "pointer";
	}else if($("page_number").value != 1 && $("page_number").value != Math.ceil($("gallery_container").getElementsByClassName("inline_color_container").length / 10)){
		$("previous_page_on").style.display = "block";
		$("previous_page").style.cursor = "pointer";
		$("next_page_on").style.display = "block";
		$("next_page").style.cursor = "pointer";
	}else{
		$("next_page_off").style.display = "block";
		$("next_page").style.cursor = "default";
		$("previous_page_on").style.display = "block";
		$("previous_page").style.cursor = "pointer";
	}
}


function nextPage(){


	var fromPage = Number($("page_number").value) - 1;
	var toPage = $("page_number").value;

	if($("page_number").value < Math.ceil($("gallery_container").getElementsByClassName("inline_color_container").length / 10)){
		$("page_number").value = Number($("page_number").value) + 1;
		$("gallery_container").getElementsByClassName("showcase_divisions")[fromPage].style.display = "none";
		$("gallery_container").getElementsByClassName("showcase_divisions")[toPage].style.display = "block";

		var pageCounter = $("page_number").value * 10;
		galleryView(pageCounter - 10);
	}


	// BRING NEXT AND PREVIOUS PAGE BUTTONS UP TO DATE
	for(var j = 0; j < $("page_turn_container").getElementsByClassName("page_turn").length; j++){
		$("page_turn_container").getElementsByClassName("page_turn")[j].style.display = "none";
	}
	if($("page_number").value == Math.ceil($("gallery_container").getElementsByClassName("inline_color_container").length / 10)){
		$("previous_page_on").style.display = "block";
		$("next_page").style.cursor = "pointer";
		$("next_page_off").style.display = "block";
		$("next_page").style.cursor = "default";
	}else if($("page_number").value != 1 && $("page_number").value != Math.ceil($("gallery_container").getElementsByClassName("inline_color_container").length / 10)){
		$("previous_page_on").style.display = "block";
		$("previous_page").style.cursor = "pointer";
		$("next_page_on").style.display = "block";
		$("next_page").style.cursor = "pointer";
	}else{
		$("previous_page_on").style.display = "block";
		$("previous_page").style.cursor = "pointer";
		$("next_page_off").style.display = "block";
		$("next_page").style.cursor = "default";
	}

}



function galleryView(galleryNumber){

	var previousImage = $("showcase_active").value;

	if(galleryNumber != previousImage){
		// REMOVE PREVIOUS IMAGE FROM STAGE AND REPLACE WITH SELECTED IMAGE
		$("gallery_options").getElementsByClassName("img_gallery_large")[previousImage].style.display = "none";
		document.getElementsByName("main")[galleryNumber].style.display = "block";
		$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].style.display = "block";

		// REMOVE PREVIOUS LARGE COLOR PREVIEWS FROM STAGE
		for(var i = 0; i < $("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByTagName("img").length; i++){
			$("gallery_options").getElementsByClassName("inline_color_container")[previousImage].getElementsByClassName("img_gallery_large")[i].style.display = "none";
		}
		
		// REMOVE ACTIVE COLOR OPTIONS AND REPLACE WITH SELECTED IMAGES
		$("gallery_container").getElementsByClassName("options_container")[previousImage].style.display = "none";
		$("gallery_container").getElementsByClassName("collection_active_overlay")[previousImage].style.display = "none";
		$("gallery_options").getElementsByClassName("inline_color_container")[previousImage].style.display = "none";
		
		$("gallery_container").getElementsByClassName("options_container")[galleryNumber].style.display = "block";
		$("gallery_container").getElementsByClassName("collection_active_overlay")[galleryNumber].style.display = "block";
		$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].style.display = "block";


		// SET FORM TO SELECTED VALUE SO THIS FUNCTION KNOWS WHAT TO REMOVE THE NEXT TIME IT'S CALLED
		$("showcase_active").value = galleryNumber;
	}
}


function galleryView_backup(galleryNumber){

	// RESET AND SHOW MAIN IMAGE ON STAGE

	for(var i = 0; i < $("gallery_options").getElementsByClassName("img_gallery_large").length; i++){
		$("gallery_options").getElementsByClassName("img_gallery_large")[i].style.display = "none";
	}

	document.getElementsByName("main")[galleryNumber].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].style.display = "block";

	// RESET AND SHOW CORRESPONDING COLOR OPTIONS FOR MAIN IMAGE
	for(var j = 0; j < $("gallery_container").getElementsByClassName("options_container").length; j++){
		$("gallery_container").getElementsByClassName("options_container")[j].style.display = "none";
		$("gallery_container").getElementsByClassName("collection_active_overlay")[j].style.display = "none";
		$("gallery_options").getElementsByClassName("inline_color_container")[j].style.display = "none";
	}

	$("gallery_container").getElementsByClassName("options_container")[galleryNumber].style.display = "block";
	$("gallery_container").getElementsByClassName("collection_active_overlay")[galleryNumber].style.display = "block";

	$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].style.display = "block";
	
}

function galleryView_old(galleryNumber){

	for(var i = 0; i < $("gallery_options").getElementsByClassName("img_gallery_large").length; i++){
		$("gallery_options").getElementsByClassName("img_gallery_large")[i].style.display = "none";
	}

	$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].getElementsByClassName("img_gallery_large")[0].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[galleryNumber].style.display = "block";


	
	for(var j = 0; j < $("gallery_container").getElementsByClassName("options_container").length; j++){
		$("gallery_container").getElementsByClassName("options_container")[j].style.display = "none";
		$("gallery_container").getElementsByClassName("collection_active_overlay")[j].style.display = "none";
	}

	$("gallery_container").getElementsByClassName("options_container")[galleryNumber].style.display = "block";
	$("gallery_container").getElementsByClassName("collection_active_overlay")[galleryNumber].style.display = "block";
	
}


function collectionInitialize(){

	for(var i = 1; i < $("gallery_container").getElementsByClassName("showcase_divisions").length; i++){
		$("gallery_container").getElementsByClassName("showcase_divisions")[i].style.display = "none";
	}
	document.page_number_form.page_number.value = 1;

	for(var i = 0; i < $("gallery_options").getElementsByClassName("img_gallery_large").length; i++){
		$("gallery_options").getElementsByClassName("img_gallery_large")[i].style.display = "none";
	}

	document.getElementsByName("main")[0].style.display = "block";
	$("gallery_options").getElementsByClassName("inline_color_container")[0].style.display = "block";

	for(var i = 0; i < $("gallery_container").getElementsByClassName("options_container").length; i++){
		$("gallery_container").getElementsByClassName("options_container")[i].style.display = "none";
		$("gallery_container").getElementsByClassName("collection_active_overlay")[i].style.display = "none";
	}
	$("gallery_container").getElementsByClassName("options_container")[0].style.display = "block";
	$("gallery_container").getElementsByClassName("collection_active_overlay")[0].style.display = "block";



	if(Math.ceil($("gallery_container").getElementsByClassName("inline_color_container").length / 10) <= 1){
		$("next_page").style.display = "none";
		$("previous_page").style.display = "none";
	}

	$("gallery_content_loading").style.display = "none";
	$("gallery_container").getElementsByClassName("gallery_content_body")[0].style.display = "block";
	$("showcase_active").value = 0;
}




//ATTEMPTING TO CONTROL IMAGE LOADS TO INCREASE PAGE EFFICIENCY HERE
/*
$noConflict(document).ready(function(){
	$noConflict("img").lazyload();
});
*/

function loadImage(imageName,imageFile){
	if (!document.images) return;

	var i = 0;
	if($("page_number").value == 1 && i < 10){
		document.images[imageName].src = imageFile;
		i++;
	}
}

	





/************************** END COLLECTION FUNCTIONS ***********************************/