// script (c) dialectbrand.com// Functions for the portfoliovar http = false;if(navigator.appName == "Microsoft Internet Explorer") {  http = new ActiveXObject("Microsoft.XMLHTTP");} else {  http = new XMLHttpRequest();} // Call this function to set the piece to show in the portfolio with Ajax// usage exampe: link="javascript:setpiece('aiga-website.php');"function setpiece(piece) {	  http.open("GET", '/portfolio/pieces/'+piece, true);  http.onreadystatechange=function() {	if(http.readyState == 4) {	  document.getElementById('portfolio-piece').innerHTML = http.responseText;	  newtitle = piece.replace('-',' ');	  newtitle = newtitle.replace('.php','');	  newtitle = toUpper(newtitle);	  document.title = "Dialect Brand :: Portfolio :: "+newtitle;	}  }  http.send(null);}//Ajax function for categoriesfunction replacecategory(category) {	    http.open("GET", '/portfolio/categories/'+category, true);  http.onreadystatechange=function() {	if(http.readyState == 4) {	  document.getElementById('portfolio-category').innerHTML = http.responseText;	  setdefaultpiece(category);	}  }  http.send(null);    }// Call this function to set the category of the portfolio// usage exampe: link="javascript:setcategory('print');"function setcategory(category) {		if (category != ""){		replacecategory(category.substring(1)+".php");	} else if (self.document.location.hash != "" && self.document.location.hash != "#" ) {		replacecategory(self.document.location.hash.substring(1)+".php");	} else {		replacecategory("localization.php");	}}// Use this to set the default piece for each category, the default one is just a catch-all.function setdefaultpiece(category) {	switch(category){		case 'print.php':			setpiece('amex-brochure.php');			break;		case 'corporateidentity.php':			setpiece('wtw-identity.php');			break;		case 'localization.php':			setpiece('tahitian-advertising.php');			break;		case 'logos.php':			setpiece('wtw-logo.php');			break;		case 'interactive.php':			setpiece('eden-website.php');			break;		default:			setpiece('ml-coasters.php');					}}// Quick Javascript function to uppercase the first letter of each wordfunction toUpper(piece) {    var pattern = /(\w)(\w*)/; // a letter, and then one, none or more letters     var a = piece.split(/\s+/g); // split the sentence into an array of words    for (i = 0 ; i < a.length ; i ++ ) {        var parts = a[i].match(pattern); // just a temp variable to store the fragments in.        var firstLetter = parts[1].toUpperCase();        var restOfWord = parts[2].toLowerCase();        a[i] = firstLetter + restOfWord; // re-assign it back to the array and move on    }        return a.join(' '); // join it back together}