$(function() {
	// ROOTS
	var root = new Array( '!img/characters/', '!img/comix/', '!img/constructs/' );
	
	// CHARACTERS ARRAY
	var chars = new Array( 
		'P17_robothead',
		'CHINBEARD_CYCLOPS',
		'COPPERDOG_CYCLOPS',
		'GOLDNOSE_CYCLOPS',
		'HEDGEBUG',
		'HOTNOSEDOGGIE',
		'KNOBNOSE_CLOWN',
		'OCEANROBOT',
		'RASTA_8BALL',
		'SNORKEL_CYCLOPS',
		'SPRINGNOSE',
		'ARTBUGARCHsm',
		'bandit',
		'BewilderedBunnysm',
		'blowfishbot',
		'bugbot',
		'BUGEYEARCHsm',
		'bugeyeboxbot',
		'highvoltage',
		'MrMustache',
		'oilycrab',
		'RADIALEYEBOT2',
		'RexTangleBot',
		'springnoseIronbot',
		'whistelingbot',
		'winged4eyedPSI'
	);
	// COMIX ARRAY
	var comix = new Array(
		'2866',
		'bad_dream',
		'electromagnetoman',
		'idol',
		'LOOPY_BAZOOKA',
		'Mao',
		'monster',
		'skinx15',
		'skinx19'		
	);
	// CONSTRUCTS ARRAY
	var cons = new Array(
		'arrowofgod',
		'atomicwanddelight',
		'boingobopola',
		'copperevaporator',
		'magellonator',
		'maxwellsilverhammer',
		'Planetoid_Eviscerator',
		'SaveThatStuff',
		'thompsonsubatomic',
		'dsd-cappachino',
		'dsd-cosmos_lavatorium',
		'dsd-elecroom',
		'dsd-kronos1',
		'dsd-kronos2',
		'dsd-upstairs_entrance'	
	);
	// ARRAY THE ARRAYS!
	var group = new Array( chars, comix, cons );
	
	// GET VALUE OF NAV BUTTON CLICKED
	function value(x) {
		if( (x === 'characters') ) {
			num = 0;
			rt = root[0];
			grp = group[0];
			max = chars.length;
		}
		if( x === 'comics' ) {
			num = 0;
			rt = root[1];
			grp = group[1];
			max = comix.length;
		}
		if( x === 'constructions' ) {
			num = 0;
			rt = root[2];
			grp = group[2];
			max = cons.length;
		}
	}
	
	// ADD OR SUBTRACT
	function increment(y) {
		if( y === 'next' ) {
			num++;
		}
		
		if( y === 'back' ) {
			num--;
		}
	}
	
	
	var num = 0;
	
		$('.contact').click(function() {
			$('.contactForm iFrame').animate({ 'top' : 0 }, 1500);
		});
		
	// RUN IT
	$('li').click(function() {
		var val = $(this).text();
		value(val);
		
		if( val != 'contact') {
			$('.contactForm iFrame').animate({ 'top' : -440 }, 250);
		}
	
		if( val === 'contact') {
			$('.contactForm iFrame').animate({ 'top' : 0 }, 1500);
		}
		if( (val === 'next') || (val === 'back') ) {
			increment(val);
		}
		
		// loop for next
		if( num === max ) {
			num = 0;
		}

		// loop for back
		if( num === -1 ) {
			num = max - 1;
		}
		
		// change the image
		$('.here img').attr('src',rt + grp[num] + '.jpg');
	});

});
