//variables needed for HBX

var _hbEC=0,_hbE=new Array;function _hbEvent(a,b){b=_hbE[_hbEC++]=new Object();b._N=a;b._C=0;return b;}
//var hbx=_hbEvent("pv");hbx.vpc="HBX0200u";hbx.gn="ehg-veohnetworksinc.hitbox.com";
var hbx;

function parseTitle(pageTitle)
{
	var tail = "| Veoh Video Network";
	var index;
	var newTitle = pageTitle;
	if(pageTitle.length > tail.length)
	{
		//check if pageTitle contains tail string
		if(pageTitle.indexOf(tail) != -1 )
		{
			newTitle = pageTitle.slice(0, pageTitle.indexOf(tail));
		}
	}

	return newTitle;
		
}

function hbxStrip(a) {
	if(a != null) {
		a = a.split("|").join("");
		a = a.split("&").join("");
		a = a.split("'").join("");
		a = a.split("#").join("");
		a = a.split("$").join("");
		a = a.split("%").join("");
		a = a.split("^").join("");
		a = a.split("*").join("");
		a = a.split(":").join("");
		a = a.split("~").join("");
		a = a.split(";").join("");
		a = a.split(" ").join("+");
		a = a.split("\"").join("");
    }
    return a;
}



//INSERT CUSTOM EVENTS
function setPageName(pageName){
	hbx.pn = hbxStrip(pageName);
}

function setErrorMessage(errorMsg){
	hbx.pec = hbxStrip(errorMsg);
}

function logLinkClick(lidValue, lposValue){
	//_hbLink(hbxStrip(lidValue),hbxStrip(lposValue));
}

function logAjaxCall(lidValue, lposValue){
	//lidValue = 'Ajax ' + lidValue;
	//_hbLink(hbxStrip(lidValue),hbxStrip(lposValue));
}

function logAjaxResponse(pageName, contentCategoryName){
//	_hbPageView(hbxStrip(pageName),hbxStrip(contentCategoryName));
}

function getSearchType(type){
	var theType = "";
	
	switch (type){
		case 'v':
			theType = "Videos";
			break;
		case 'c':
			theType = "Channels";
			break;
		case 's':
			theType = "Series";
			break;
		case 'u':
			theType = "People";
			break;
		default : 
			theType =  "Videos";
	}
	return theType;
}

function getOrder(type, order){
	var theOrder = "";
	
	if(order == '')
		return "Most Relevant";
	
	switch (order){
		case 'mr':
			theOrder = "Most Recent";
			break;
		case 'mp':
			theOrder = "Most Popular";
			break;
		case 'mc':
			theOrder = "Most Discussed";
			break;
		case 'ms':
			theOrder = "Most Subscribed";
			break;
		case 'tr':
			theOrder = "Top Rated";
			break;
		case 'tf':
			theOrder = "Top Favorite";
			break;
		case 'rl':
			theOrder = "Run Length";
			break;			
	}
	return theOrder;
}

function getRange(range){
	var theRange = "";
	
	switch (range){
		case 't':
			theRange = "Today";
			break;
		case 'w':
			theRange = "This Week";
			break;
		case 'm':
			theRange = "This Month";
			break;
		case 'a':
			theRange = "All Time";
			break;
		default:
			theRange = "This Week";
	}
	return theRange;
}

/*
 *	input params:
 *		query 
 *		numResults
 *		attr1 - search type ( v,c,s,u)
 *		attr2 - order (mp,mr, tr, md, tf,rl)
 *		attr3 - range (t,w,m,a)
 *		attr4 - category
 */
function logSearchCall(query, numResults, attr1, attr2, attr3, attr4){
	var ev1 = _hbEvent("search"); 
	
	attr2 = getOrder(attr1,attr2);
	attr3 = getRange(attr3);
	attr1 = getSearchType(attr1);
		
	
 	ev1.keywords = hbxStrip(query);  	// search query term(s)
 	ev1.results = hbxStrip(numResults); // 0 OR non-zero integer
 	ev1.attr1 = hbxStrip(attr1);   		// 1-4 attributes of the search may be omitted if desired
 	ev1.attr2 = hbxStrip(attr2);  		// no attributed are recorded for failed searches
 	ev1.attr3 = hbxStrip(attr3);
 	ev1.attr4 = hbxStrip(attr4);	
}



//END EDITABLE SECTION
