/*
//this is the object which is passed to the onmiture function which we are going to construct
channel    :   "Microsite EcoFlex" <-- hard-coded
heir1      :   "index,microsites,ecoflex,agila,environmental,5door,view_1" <-- split string then tack on the end
pageName   :   "Microsite : EcoFlex: Agila_ Environmental " <-- calculate last page variable
*/

function tc_log(obj){	
	
	//create obj to pass to omniture
	var newObj = new Object();
	setDefaults(newObj);
	newObj.channel = "Microsite EcoFlexCars";
	newObj.hier1 = "index,microsites,"+(obj.split('/').join(','));
	
	//parse the obj string to create useable variables
	var parsedString = obj.split('/');
	var pageName = "";
	var separation_char = "";
	$.each(parsedString, function(index, value) {
			switch(index){
				case 0:
				   break;
				default:
					pageName = pageName + separation_char + value.capitalize();
					separation_char = ": "; 
			}
		});
		newObj.pageName = "Microsite: EcoFlexCars: " + pageName;

	//pass to function
	omniture_log(newObj);	
	
	return;
}

/* 
	this function logs the loading of the the html pages 
*/
function html_page_log(obj){	
	
	//create obj to pass to omniture
	var newObj = new Object();
	setDefaults(newObj);
	newObj.hier1 = "index,microsites,EcoFlexCars,"+obj;
	newObj.pageName = "Microsite: EcoFlexCars: "+obj.capitalize();
	//pass to function
	omniture_log(newObj);	
	
	return;
}

function setDefaults (ourObj) {

	 ourObj.channel="Microsite EcoFlexCars";
	 ourObj.prop1="Vauxhall Ecoflex";
	 ourObj.prop3="Car";
	 ourObj.prop17="EcoFlexCars";
	 ourObj.prop18="Vauxhall";

	 ourObj.eVar5=Omniture_s.prop1;
	 ourObj.eVar6=Omniture_s.prop2;
	 ourObj.eVar7=Omniture_s.prop3;
 	 ourObj.eVar17=ourObj.prop17;
	 ourObj.eVar18=Omniture_s.prop18; 
	 
	 var emailLinkId = Omniture_s.getQueryParam('linkid');
	if (emailLinkId != ""){
		ourObj.prop11=emailLinkId;
		ourObj.prop8=Omniture_s.getQueryParam('campaignid');
	}
	 
	 return;
	 
}

//function to capatalise first letter
String.prototype.capitalize = function(){ //v1.0
    return this.replace(/\w+/g, function(a){
        return a.charAt(0).toUpperCase() + a.substr(1).toLowerCase();
    });
};

