// HTTP requests

var http = false;

if(navigator.appName == "Microsoft Internet Explorer") {
	http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
	http = new XMLHttpRequest();
}

// Fader

function crossFade(element, responseText, timer) {
	
	$(element).ready(function(){

	  	$(element).animate({ opacity: 0}, timer );
	  	$(element).queue(function () {
	        $(this).empty().append(responseText);
	       	$(this).dequeue();
		});
	  	$(element).animate({ opacity: 1}, timer );
	});
}

function previewPic(file, n) {
	
	http.open("GET", "includes/preview.php?pic=" + file + "&cat=" + n, true);
	http.onreadystatechange=function() {
		if(http.readyState == 3) {}
		if(http.readyState == 4) {
			//document.getElementById('pic_preview').innerHTML = http.responseText;
			crossFade('#portfolio-img', http.responseText, 300);			
		}
	}
	http.send(null);
}

curThumbId = "";

function thumbHighlight(tID) {
	
	// Reset the last thumbnail style
	if (curThumbId != "") {
		$(curThumbId).ready(function(){
			$(curThumbId, this).css("border", "1px solid #909090");
		});
	}

	// Highlight the current one
	element = "#thumb_" + tID;
	curThumbId = element;
	
	$(element).ready(function(){
		$(element, this).css("border", "1px solid #a00");
	});
}
