function navPrevLabel() {
	$('div#project_nav').css('background','url(/images/interface/project_labels.png) no-repeat 0px 11px');
}

function navNextLabel() {
	$('div#project_nav').css('background','url(/images/interface/project_labels.png) no-repeat 0px -23px');
}

function navClearLabel() {
	$('div#project_nav').css('background','');
}

function navPrevPage() {
	$('div#project_nav').css('background','url(/images/interface/project_labels.png) no-repeat 0px -67px');
}

function navNextPage() {
	$('div#project_nav').css('background','url(/images/interface/project_labels.png) no-repeat 0px -103px');
}

$(document).ready(function() {
	$('#row_built .jcarousel-next').bind('mouseenter',function() {
		alert('foo');
	});
});

$(document).ready(function(){ formatH4(); });

function formatH4() {
	headings = document.getElementsByTagName('h4');
	for (i=0;i<headings.length;i++) {
		if (headings[i].firstChild && headings[i].className == 'portfolio_heading') {
			headingText = headings[i].firstChild.nodeValue;
			var so = new SWFObject('/images/swf/project_title.swf', 'heading'+ i, '218', '30', '9', '#fff');
			so.addParam('wmode', 'transparent');
			so.addVariable('title', headingText);
			so.write(headings[i]);
		}
	}
}

function loadContent(url) {
	$('div#col2_copy').text('');
	$('div#col2_copy').css('background','url(/images/interface/loading.gif) no-repeat center center');
	req = false;
    // branch for native XMLHttpRequest object
    if(window.XMLHttpRequest && !(window.ActiveXObject)) {
    	try {
			req = new XMLHttpRequest();
        } catch(e) {
			req = false;
        }
    // branch for IE/Windows ActiveX version
    } else if(window.ActiveXObject) {
       	try {
        	req = new ActiveXObject("Msxml2.XMLHTTP");
      	} catch(e) {
        	try {
          		req = new ActiveXObject("Microsoft.XMLHTTP");
        	} catch(e) {
          		req = false;
        	}
		}
    }
	if(req) {
		req.onreadystatechange = applyContent;
		req.open("GET", url, true);
		req.send("");
	}
}

function applyContent() {
    // only if req shows "loaded"
    if (req.readyState == 4) {
        // only if "OK"
        if (req.status == 200) {
			$('div#col2_copy').css('background','');
			$('div#col2_copy').html(req.responseText);
			scrollbar.recalculateLayout();
        } else {
            alert("There was a problem retrieving the XML data:\n" + req.statusText);
        }
    }
}

var slOpen = '';
function openNode(obj,haspic) {
	if (obj.parentNode.id != slOpen) {
		if (slOpen != '') {
			openLink = slOpen+'_link';
			openImg = slOpen+'_img';
			$('a#'+openLink).removeClass('active');
			$('dd#'+openImg).slideUp('fast');
		}

		newNode = obj.parentNode.id;
		newLink = obj.id;
		newImg = newNode+'_img';
		$('a#'+newLink).addClass('active');
		if (haspic != 'nopic') {
			$('dd#'+newImg).slideDown('fast');
		}
		slOpen = newNode;
		return false;
	}
	else {
		return false;
	}
}

function openNav(section) {
//	alert(currentSection);
	if (section == 'projects' && currentSection != 'projects') {
		resetNavStates();
		$('a#n_projects_link').addClass('active');
		if (currentSection == 'information') {
//			alert('information is showing');
//			Effect.Fade('information_nav', {duration: .1});
			$('ul#information_nav').fadeOut('fast', function() {
				$('ul#projects_nav').fadeIn('fast');
				$('a#n_information_link').removeClass('active');
			});
		}
		else {
			$('ul#projects_nav').fadeIn('fast');
		}
		currentSection = 'projects';
	}
	else if (section == 'information' && currentSection != 'information') {
		resetNavStates();
		$('a#n_information_link').addClass('active');
		if (currentSection == 'projects') {
//			alert('projects is showing');
//			Effect.Fade('projects_nav', {duration: .1});
			$('ul#projects_nav').fadeOut('fast', function() {
				$('ul#information_nav').fadeIn('fast');
				$('a#n_projects_link').removeClass('active');
			});
		}
		else {
			$('ul#information_nav').fadeIn('fast');
		}
		currentSection = 'information';
	}
}

function resetNavStates() {
	// dirty but easy.
	$('ul#nav a').removeClass('active');
//	for (i=0;i<d.length;i++) {
//		d[i].className = 'noem';
//	}

	$('ul#projects_nav a').removeClass('active');
//	for (i=0;i<e.length;i++) {
//		e[i].className = 'noem';
//	}
	$('ul#information_nav a').removeClass('active');
//	for (i=0;i<f.length;i++) {
//		f[i].className = 'noem';
//	}
}

$(document).ready(function() {
	positionFooter();
	$(window).bind('resize', function() {
		positionFooter();
	});
});

function positionFooter() {
//	document.title = $(window).height();
	bm = $(window).height() - 38;
		$('#footer').css('top',bm);
	if ($(window).height() < 600) {
		$('#footer').css('top', 562);
	}
}
