window.addEvent('domready', function(){

	over = new Array;
	
	// scroll arrows
	over['previousOver'] = new Asset.image('/furniture/scroll_left_over.gif');
	over['nextOver'] = new Asset.image('/furniture/scroll_right_over.gif');
	over['previousOut'] = new Asset.image('/furniture/scroll_left.gif');
	over['nextOut'] = new Asset.image('/furniture/scroll_right.gif');
	
	// job sub arrows
	over['subLeftOver'] = new Asset.image('/furniture/subarrow_left_over.gif');
	over['subRightOver'] = new Asset.image('/furniture/subarrow_right_over.gif');
	over['subLeftOut'] = new Asset.image('/furniture/subarrow_left.gif');
	over['subRightOut'] = new Asset.image('/furniture/subarrow_right.gif');
	
	swapScrollers = function(img, toggle) {
		$(img).setProperty('src', over[img+toggle].src);
	}
	
	if ($('subLeft')) {
		
		$('subLeft').addEvent('mouseover', function(e){
			e = new Event(e);
			
			swapScrollers('subLeft', 'Over');
			
			e.stop();
		});
		
		$('subLeft').addEvent('mouseout', function(e){
			e = new Event(e);
			
			swapScrollers('subLeft', 'Out');
			
			e.stop();
		});
	}
	
	if ($('subRight')) {
		
		$('subRight').addEvent('mouseover', function(e){
			e = new Event(e);
			
			swapScrollers('subRight', 'Over');
			
			e.stop();
		});
		
		$('subRight').addEvent('mouseout', function(e){
			e = new Event(e);
			
			swapScrollers('subRight', 'Out');
			
			e.stop();
		});
	}

	$('about').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/about.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	$('about1').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/about.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	$('contact').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/contact.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	$('contact1').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/contact.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	$('clients').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/clients.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	$('clients1').addEvent('click', function(e){
		e = new Event(e);
		
		var url = "/clients.php";
		
		new Ajax(url, {
			method: 'get',
			update: $('content')
		}).request();

		e.stop();
	});
	
	getFullview = function() {
		
		$('leftCol').addClass('col1');
		
		
		$('leftCol').removeClass('welcome');
		$('leftCol').removeClass('contact');
		$('leftCol').removeClass('clients');
		$('leftCol').removeClass('about');
		
		$('rightCol').addClass('col2');
		$('rightCol').removeClass('latest');
		$('rightCol').removeClass('clientsLogos');
		
		
		
		$('rightCol').innerHTML = '<p>loading...</p>';
		
		var url = "/script/post_fullview.js";
		
		new Ajax(url, {
			method: 'get',
			evalScripts: true,
			onComplete: function() {
				//$('mainimage').height = imgFile.height;
				//resize();
			}
		}).request();
		
	}
	
	resize = function() {
		if (fileExt != 'swf') {
			//$('mainimage').width = '504';
			//$('mainimage').height = imgSrc.height;
		}
	}
	
	// function to swap main image when thumbnails clicked
	swapJob = function(jobId) {
		
		//curJob = jobId-1;
		//document.getElementById('mainimage').src = jobs[curJob][0][0].src;
		for (var i=0; i < jobs.length; i++ ) {
			if (jobId == jobs[i][1]) {
				// the image to swap to
				imgFile = jobs[i][0][0];
				
				// swap the main image using ajax
				getFullview();
				// swap the long description 
				$('description').innerHTML = jobs[i][2][0];
				curJob = i;
				curImg = 0;
				arrows(curJob);
				break;
			}
		}
	}
	
	// functions to cycle through main images
	swapNext = function() {
		// if not the last image
		if (curImg != jobs[curJob][0].length-1) {
			curImg++;
		}
		// else cycle to first
		else {
			curImg = 0;
		}
		// the image to swap to
		imgFile = jobs[curJob][0][curImg];
		// swap the main image using ajax
		getFullview();
		// swap the long description 
		document.getElementById('description').innerHTML = jobs[curJob][2][curImg];
	}
	swapPrev = function() {
		// if not the first image
		if (curImg != 0) {
			//alert("not first");
			curImg--;
		}
		// else cycle to last
		else {
			curImg = jobs[curJob][0].length-1;
		}
		// the image to swap to
		imgFile = jobs[curJob][0][curImg];
		// swap the main image using ajax
		getFullview();
		// swap the long description
		document.getElementById('description').innerHTML = jobs[curJob][2][curImg];
	}
	// function to show or hide arrows
	arrows = function(id) {
		if (jobs[id][0].length == 1) {
		elm1 = document.getElementById('leftarrow');
		elm1.className = "hidearrow";
		elm2 = document.getElementById('rightarrow');
		elm2.className = "hidearrow";
		}
		else {
		elm1 = document.getElementById('leftarrow');
		elm1.className = "showarrow";
		elm2 = document.getElementById('rightarrow');
		elm2.className = "showarrow";
		}
	}
	
	
	
});