// Current Page Reference
// copyright Stephen Chapman, 1st Jan 2005
// you may copy this function but please keep the copyright notice with it
function getURL(uri) {
	uri.dir = location.href.substring(0, location.href.lastIndexOf('\/'));
	uri.dom = uri.dir; if (uri.dom.substr(0,7) == 'http:\/\/') uri.dom = uri.dom.substr(7);
	uri.path = ''; var pos = uri.dom.indexOf('\/'); if (pos > -1) {uri.path = uri.dom.substr(pos+1); uri.dom = uri.dom.substr(0,pos);}
	uri.page = location.href.substring(uri.dir.length+1, location.href.length+1);
	pos = uri.page.indexOf('?');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	pos = uri.page.indexOf('#');if (pos > -1) {uri.page = uri.page.substring(0, pos);}
	uri.ext = ''; pos = uri.page.indexOf('.');if (pos > -1) {uri.ext =uri.page.substring(pos+1); uri.page = uri.page.substr(0,pos);}
	uri.file = uri.page;
	if (uri.ext != '') uri.file += '.' + uri.ext;
	if (uri.file == '') uri.page = 'index';
	uri.args = location.search.substr(1).split("?");
	return uri;
}

var uri = new Object();
getURL(uri);

             


// general parameters for Portfolio Image Swap...
xBase = "/images/";
if ((uri.dom == "www.clutchmedia.com") || (uri.dom == "clutchmedia.com")) { xBase = "/clients/mcg/images/"; }

var gPathBase = xBase + "portfolio/";
var gBoxRedPath = xBase + "general/navbox-red.gif";
var gBoxWhitePath = xBase + "general/navbox-white.gif";
var gCaption = 1;
var gBox = 1;


function mOver(xID) {
	// set up path variables...
	xCaptionPath = gPathBase + gCatDir + "/" + gDir + "/c" + xID + ".gif";
	// set caption and box...
	if (document.all) {	
		document.all['Caption'].src = xCaptionPath;
		document.all['Image'+xID].src = gBoxWhitePath;
	} else {
		document.images['Caption'].src = xCaptionPath;
		document.images['Image'+xID].src = gBoxWhitePath;
	}
}

function mOff(xID) {
	// set up path variables...
	xCaptionPath = gPathBase + gCatDir + "/" + gDir + "/c" + gCaption + ".gif";
	// set caption and box...
	if (document.all) {	
		document.all['Caption'].src = xCaptionPath;
		if (xID != parseInt(gBox)) document.all['Image'+xID].src = gBoxRedPath;
	} else {
		document.images['Caption'].src = xCaptionPath;
		if (xID != parseInt(gBox)) document.images['Image'+xID].src = gBoxRedPath;
	}
}

function swapPhoto(xID) {
	// set up path variables...
	xPhotoPath = gPathBase + gCatDir + "/" + gDir + "/" + xID + ".jpg";
	xCaptionPath = gPathBase + gCatDir + "/" + gDir + "/c" + xID + ".gif";

	// reset boxes...
	for (i=1; i<=gCnt; i++) {
		if (document.all) {	
			document.all['Image'+i].src = gBoxRedPath;
		} else {
			document.images['Image'+i].src = gBoxRedPath;
		}
	}
	
	// set caption, photo and box...
	if (document.all) {	
		document.all['Photo'].src = xPhotoPath;
		document.all['Caption'].src = xCaptionPath;
		document.all['Image'+xID].src = gBoxWhitePath;
	} else {
		document.images['Photo'].src = xPhotoPath;
		document.images['Caption'].src = xCaptionPath;
		document.images['Image'+xID].src = gBoxWhitePath;
	}
	
	// set defaults
	gCaption = xID;
	gBox = xID;
}

// preload Portfolio project-specific photo caption images
function MCG_Preloader() {
	// if gCnt has been defined...
	if (typeof(window['gCnt']) != "undefined") {
		// preload photo captions using page-specific variables 
		for (i=1; i<=gCnt; i++) {
			xOverImgPath = "../../images/portfolio/" + gCatDir + "/" + gDir + "/c" + i + ".gif";
			MM_preloadImages(xOverImgPath);
		}
  } 
}



function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

