 /* Parses URL Pathname
	Author: Jamie L. Marin, Senior Web Developer
	Date: June !5, 2005
*/

/* Sets varibles for URI pathname and pathname length */
var browserURI = location.pathname;
var uriLength = browserURI.length;

/* Creates Array */
var directories = new Array( );

/* Find out indexes of first, next, and last slashes */
var startSlash = browserURI.indexOf('/');
var nextSlash =  browserURI.indexOf('/', startSlash + 1);
var lastSlash = browserURI.lastIndexOf('/');
var slashCount = 0;

/* test for one deep section */ 
if (startSlash == lastSlash)
{
	directories[slashCount] = location.pathname.slice(startSlash + 1);
}


/* Loop to define sections from 1 to N */
while (startSlash != lastSlash || nextSlash != -1)
{
	directories[slashCount] = location.pathname.substring(startSlash + 1,nextSlash);	
	
	if (lastSlash + 1 != uriLength)
		directories[slashCount +1] = browserURI.slice(nextSlash + 1);
		
	startSlash = nextSlash;
	nextSlash =  browserURI.indexOf('/', startSlash + 1);		
	slashCount++;	
}

/* Set User Friendly Variables */
var firstDir = directories[0];
var lastDir = directories[directories.length-1];

/* End parsing code */

/* set Omni-friendly path */

var omniHierarchy = "";
for (var i=0; i<directories.length; i++) {
    omniHierarchy += directories[i];
    if (i != directories.length - 1)
        omniHierarchy += ",";
}

/* set prop6-prop9 of omniture code */

var setProp6;
var setProp7;
var setProp8;
var setProp9;
var setPageName;
var setPageType;
var setEvents;
var setProp3="";
var setProp41="";
var setProp5="";

 var slideshowLoc = window.location.toString();
 
 var searchString = "print/slideshow";
 
 var search25SexWomen = "25sexiestwomen";

if  (slideshowLoc.search(search25SexWomen) != -1) {
    setProp3 = "25 SEXIEST WOMEN";
    setProp41= "6229";
    setProp5 = "GQ Features";
}

 if (slideshowLoc.search(searchString) != -1) {
    setPageName = slideshowLoc.substring(0,slideshowLoc.indexOf('slideshow'));
    omniHierarchy="print"; 
    setProp3 = slideshowLoc.substring(slideshowLoc.indexOf('/print'));
    setProp41 = slideshowLoc.substring(slideshowLoc.indexOf('/print'));
    setProp5 = "printer page";
    setProp6="print";
    setProp7="";
    setProp8="";
    setProp9="";
    }
    
    
 else {    

if (directories[0] == "") {
    setProp6 = "homepage";
    omniHierarchy="homepage";
    setPageName="homepage";
    
}
if (directories.length >= 1 && directories[0] != "")
    setProp6 = directories[0];
if (directories.length >= 2)
    setProp7 = setProp6 + '/' + directories[1];
if (directories.length >= 3)
    setProp8 = setProp7 + '/' + directories[2];    
if (directories.length >= 4)
    setProp9 = setProp8 + '/' + directories[3];

 }

