
$(document).ready(function(){

    $.preloadimages('images/nav/mainNav-Blog_over.gif', 
                    'images/nav/mainNav-Clients_over.gif', 
                    'images/nav/mainNav-Construction_over.gif', 
                    'images/nav/mainNav-Lease_Rental_over.gif',
					'images/nav/mainNav-Portfolio_over.gif',
					'images/nav/secNav-about_over.gif',
					'images/nav/secNav-careers_over.gif',
					'images/nav/secNav-contact_over.gif',
					'images/left-arrow_over.gif',
					'images/right-arrow_over.gif'
                    );

    $('.changemo').swapit('_over');
    
    var _port = Array();
		_port['comm'] = Array();
		_port['comm'].push('gretchens_house.php');
		_port['comm'].push('tcf_bank_projects.php');
		_port['comm'].push('saturn_of_ann_arbor.php');
		_port['comm'].push('reinhart_realtors.php');
		_port['comm'].push('hillers_market.php');
		_port['comm'].push('foto1.php');
		_port['comm'].push('aero_corporation.php');
		_port['comm'].push('adams_advertising.php');
		_port['comm'].push('dental_office.php');
		_port['comm'].push('fifth_third.php');
		_port['comm'].push('fran_coy.php');
		_port['comm'].push('vet_hospital.php');
    
    	_port['inst'] = Array();
    	_port['inst'].push('pittsfield_township_hall.php');
    	_port['inst'].push('saline_municipal_building.php');
    	_port['inst'].push('washtenaw_county_road.php');
    	_port['inst'].push('ypsilanti_fire_museum.php');
    	_port['inst'].push('first_presbyterian_church.php');
    	_port['inst'].push('saline_library.php');
    	_port['inst'].push('unitarian_church.php');
    	_port['inst'].push('um_law.php');
    	
    	_port['resid'] = Array();
    	_port['resid'].push('sunward_cohousing.php');
    	_port['resid'].push('great_oak_cohousing.php');
    	_port['resid'].push('crawford_house.php');
    	_port['resid'].push('touchstone_cohousing.php');
    	_port['resid'].push('gathering_place.php');
    	
    	_port['restor'] = Array();
    	_port['restor'].push('murphys-crossing.php');
    	_port['restor'].push('schwaben.php');
    	_port['restor'].push('flour_mill.php');
    	_port['restor'].push('chelsea_courthouse.php');
 		_port['restor'].push('merchant_square.php');
   	
    if ($('#portNumbers').length) {
    
    	var filename = window.location.href.split('/');
    		filename = filename[(filename.length-1)];
    		filename = filename.split('-');
    		
    	if (filename.length > 3) {
    		var _tmpfilename = Array();
    			_tmpfilename[0] = filename[0];
    			_tmpfilename[1] = filename[1];
    			delete filename[0];
    			delete filename[1];
    			_tmpfilename[2] = filename.join('-');
    			filename = _tmpfilename;
    	}
    	
    	if (filename.length == 3) {
			
			var _position = 0;
			var _total = _port[filename[1]].length;
			
			for (var i in _port[filename[1]]) {
				var _tmp = _port[filename[1]][i];
				if (_tmp == filename[2]) {
					_position = i;
				}
				
			}
			
			_position = parseInt(_position);
			
			if (_position == 0) {
				$('#left ul li a').eq(0).attr('href', 'port-'+filename[1]+'-'+_port[filename[1]][(_total-1)]);
			} else {
				$('#left ul li a').eq(0).attr('href', 'port-'+filename[1]+'-'+_port[filename[1]][(_position-1)]);
			}
			
			if (_position == 0) {
				$('#left ul li a').eq(1).attr('href', 'port-'+filename[1]+'-'+_port[filename[1]][(_position+1)]);
			} else {
				if (_position == (_total-1)) {
					$('#left ul li a').eq(1).attr('href', 'port-'+filename[1]+'-'+_port[filename[1]][0]);
				} else {
					$('#left ul li a').eq(1).attr('href', 'port-'+filename[1]+'-'+_port[filename[1]][(_position+1)]);
				}
			}
			
			$('#portNumbers').html((_position+1)+'/'+_total);
			
		}
    	
    }
    
});