function buildProps(one, two, three) {
    s.prop5 = s.prop4 + ((one.length > 0) ? ("/" + one) : "");
    s.prop6 = s.prop5 + ((two.length > 0) ? ("/" + two) : "");
    s.prop7 = s.prop6 + ((three.length > 0) ? ("/" + three) : "");
}

function buildOmnitureGeneric() {
    /* prop7 is defined in the js function buildProps.  If buildProps was not executed in
        the PrintPaidVariables or PrintFreeVariables template then s.prop7 will be null.  In
        this case, the (sub)sections, hierarchy and pagename will also be undefined.  The following
        javascript function parses and cleans up the url, feeds it in the buildProps function 
        to give us an easier-to-read pageName, hierarchy, etc. in the Omniture reports. */
    if (s.prop7 == null) {
        
        var curr_url = "";
        var split_content_url = "";
        var properties_arr = ["","",""];
        var url_contains_page = false;

        /* grab the url */
        if (typeof(omnitureurl) == "undefined") {
        	curr_url = window.location.pathname;
        } else {
        	curr_url = omnitureurl;
        }
        
        /* before we cut off the file extension in the url, determine
            if there is a file.  If not, later on we are going to add
            "index" to the content type/title */
        if (curr_url.search(/\.xhtml/) != -1) {
            url_contains_page = true;
        }
        
        /* remove anything from the file extension or '?' onwards*/
        curr_url = curr_url.replace(/(\.|\?).*/i,"");
        /* remove leading '/' if it exists */
        curr_url = curr_url.replace(new RegExp("^\/"),"");
        /* remove trailing '/' if it exists */
        curr_url = curr_url.replace(/\/$/,"");
        
        /* for use with content variables prop9,10, 12 */
        split_content_url = curr_url.split('/');
        
        /* remove any instances of subscribe/, global/, or free/ at the beginning of the url */
        curr_url = curr_url.replace(/^(subscribe\/|global\/|free\/)/i,"");
        /* remove any instances of /hoov at the beginning of the url (this is taking 
        into consideration that subscribe, global and free have already been removed*/
        curr_url = curr_url.replace(new RegExp("^hoov\/", "i"),"");
        
        /*  split the remaining string into an array.  Using '/' as the delimiter */
        split_url = curr_url.split('/');
        
        /* move values from split_url into the properties_arr.  If there are more than three elements
            just start appending the excess elements to the third element, separated by a space. */
        /* hold the three values passed to buildProps */         
        for(i=0 ; i < split_url.length ; i++){
            if(i >= 3){
                properties_arr[2] += " "+split_url[i];
            }else{
                properties_arr[i] = split_url[i];
            }
        }

        buildProps(properties_arr[0], properties_arr[1], properties_arr[2]);
        
        /* Generate Content Type (prop12) and Content Title (prop9) */
        s.prop12 = "";
        s.prop9 = "";
        
        /* if the url did not contain a filename, assume "index" as that's
            the default file loaded */
        if(!url_contains_page){
            split_content_url = split_content_url.concat("index");
        }
        
        var content_url_length = split_content_url.length-1;
        
        for(i = content_url_length ; i >= 0 && content_url_length-i <= 2 ; i--){
            /* Content Type */
            /* Only store the filename and the next directory up */
            if(content_url_length-i < 2){
                s.prop12 = split_content_url[i]+" "+s.prop12;
            }
            
            /* Content Title */
            /* Only store the filename and the next two directories up */
            s.prop9 = split_content_url[i]+" "+s.prop9;
        }
        
        /* remove any trailing whitespace */
        s.prop12 = s.prop12.replace(/\s+$/, '');
        s.prop9 = s.prop9.replace(/\s+$/, '');
    }
    
    s.hier2 = s.prop7;
    s.pageName = s.prop7;
    
    if (s.prop10 == null || s.prop10 == "") {
    	s.prop10 = s.prop9;
    }
}


function signifyError(type) {
    s.pageName = "";
    s.pageType="errorPage";
	var errorString = " - " + type + " error page";
	
	if (s.prop7.length > 0) {
		s.prop7 += errorString;
	} else if (s.prop6.length > 0) {
		s.prop6 += errorString;
	} else if (s.prop5.length > 0) {
		s.prop5 += errorString;
	}
	s.hier2 = s.prop7;
	s.prop9 += errorString;
    s.prop10 += errorString;
    s.prop12 += errorString;
}

