var avpGlobalSearchBoxOverrides = {
	selectSuggestion : function(e) {
		e.preventDefault();
				
		var core = this, coreVars = core.getVars(), ui = coreVars.ui, local = coreVars.local;

		if (e !== undefined && e.type === 'click') {
			var target = e.target;
			if (target.nodeName === 'B') { target = target.parentNode; }
			ui.$input.val($(target).text());
		}
		
		if (ui.$input.val() !== '' && ui.$input.val() !== local.ghostText) {
			return srchSub('151'); AVHeader.chkFamily();
		}
	},
	processInputFocus : function(e) {				
		com.aol.video.portal.Events.inputHeadClear();
	},
	processInputBlur : function(e) {
		com.aol.video.portal.Events.inputHeadText();
	}
}

function srchSub(id) {
	var frm=document.GH_search_form;
	if(Utils.trim(frm.query.value) != "" && Utils.trim(frm.query.value) != 	com.aol.video.portal.searchDefaultText &&  com.aol.video.portal.userHeadInput){
	    AVP.showGSL("1");
		var hostname = videopagehostUrl;
		frm.query.value=Utils.trim(frm.query.value);
		frm.sourceType.value=id;
		if(id==151) {
			if(frm.query.value!="") {
				var frmValue = frm.query.value;
				var frmStr = Utils.escapeHTMLString(frmValue);
				var loc_searchurl = hostname+"/video-search/query/"+frmStr;
				if(frm.query.value!="" && frm.familyFilter.value!=0) {
					window.location = loc_searchurl;
				} else {
					window.location = loc_searchurl+"/familyFilter/0";
				}
				return false;
			}
			return false;
		} else if(frm.sourceType.value==415) { 
			if(frm.query.value!="") {
				var audioUrl = "http://aolsearch.aol.com/aol/audio?invocationType=topsearchbox.audiohome&query="+frm.query.value;
				window.location = audioUrl;
			} 
		} else{
			if(frm.query.value!=""){
			frm.submit();return false;
			}
		}
		return true;
	}
	else{
		return false;
	}
}

function srchfSub(id){
	var frmfoot=document.av_fsearch;
	if(Utils.trim(frmfoot.q.value) != "" && Utils.trim(frmfoot.q.value) != 	com.aol.video.portal.searchDefaultText && com.aol.video.portal.userFootInput){
		AVP.showGSL("1");
		var hostname = videopagehostUrl; 
		frmfoot.q.value=Utils.trim(frmfoot.q.value);
		if(id==151) {
			if(frmfoot.q.value!="") {
				var frmfootValue = frmfoot.q.value;
				var frmfootStr = Utils.escapeHTMLString(frmfootValue);
				var loc_searchurl = hostname+"/video-search/query/"+frmfootStr;
				window.location = loc_searchurl;
				
			}
			return false;
		} 
	}
	else{
		return false;
	}
}
