$().ready(function() {
	$('#collections .kwicks').kwicks({
		max: 200,
		spacing: 1
	});
	
	$('#spec_collections .kwicks').kwicks({
		max: 180,
		spacing: 1
	});
	
	// Collections
	$("li.liKwicksCollection").mouseover(function () {
		var tmp = this.id.split('kwickCollection');
		var id = 'kwickCollection' + tmp[1];
		document.getElementById(id).value = 1;
		
		//restoreCollection('Special');
		
		var nbLi = document.getElementsByClassName('liKwicksCollection').length;
		pause(100);
		var isOverCollection = document.getElementById(id).value;
		
		if (isOverCollection == 1) {
			overULCollection = true;
			
			for (var i = 1; i <= nbLi; i++) {
				if (this.id == "kwickCollection" + i) {
					selectedLi = i;
					//$("#divFadeCollection" + i).fadeOut(100);
					//$("#divSpacerCollection" + i).fadeIn(100);
					document.getElementById('divNameCollection' + i).className = 'divNameCollection kwickOver';
				}
				else 
					if (previousSelectedLi == 0 || previousSelectedLi == i) {
						//$("#divFadeCollection" + i).fadeIn(500);
						//$("#divSpacerCollection" + i).fadeOut(500);
					}
			}
			
			previousSelectedLi = selectedLi;
		}
		return false;
	});
	
	$("li.liKwicksCollection").mouseout(function () {
		var tmp = this.id.split('kwickCollection');
		
		document.getElementById('divNameCollection' + tmp[1]).className = 'divNameCollection';
		document.getElementById('isOverCollection' + tmp[1]).value = 0;
		overULCollection = false;
	}); 
	
	$("li.liKwicksSpecial").mouseover(function () {
		var tmp = this.id.split('kwickSpecial');
		var id = 'kwickSpecial' + tmp[1];
		document.getElementById(id).value = 1;
		
		//restoreCollection('Collection');
		
		var nbLi = document.getElementsByClassName('liKwicksSpecial').length;
		pause(100);
		var isOverSpecial = document.getElementById(id).value;
		
		if (isOverSpecial == 1) {
			overULSpecial = true;
			
			for (var i = 1; i <= nbLi; i++) {
				if (this.id == "kwickSpecial" + i) {
					selectedLi = i;
					//$("#divFadeSpecial" + i).fadeOut(100);
					//$("#divSpacerSpecial" + i).fadeIn(100);
					document.getElementById('divNameSpecial' + i).className = 'divNameSpecial kwickOver';
				}
				else 
					if (previousSelectedLi == 0 || previousSelectedLi == i) {
						//$("#divFadeSpecial" + i).fadeIn(500);
						//$("#divSpacerSpecial" + i).fadeOut(500);
					}
			}
			
			previousSelectedLi = selectedLi;
		}
		return false;
	});
	
	$("li.liKwicksSpecial").mouseout(function () {
		var tmp = this.id.split('kwickSpecial');
		
		document.getElementById('divNameSpecial' + tmp[1]).className = 'divNameSpecial';
		document.getElementById('isOverSpecial' + tmp[1]).value = 0;
		overULSpecial = false;
	}); 
	
	$("#mainContainer").mouseover(function () {
		//setTimeout('restoreCollection(\'Collection\')', 1000);
		//setTimeout('restoreCollection(\'Special\')', 1000);
		
		return false;
	});
});

