

sField = function()
         {
            var sBox = document.getElementsByName("searchfield");

             for(i=0;i<sBox.length;i++)
	         {
                        Search(sBox[i].id);
             }
         };
         
function Search(oid) {
	

	// set a default value to search field.
	var defaultText = "";	
	
	// set to either true or false
	// when set to true it will generate search suggestions list for search field based on content of variable below
	var suggestion = true;
	
	// static list of suggestion options, separated by comma
	var suggestionText = "106 & gospel,106 & park,106 & park connect,50 cent,aaliyah,access granted,aids,akon,album,alicia keys,"
	+ "american gangster ,ashanti,auditions,avant,awards,b5,baldwin hills,barack obama,beneath the underdog,BET awards,BET hip hop awards,"
	+ "BET honors,BET j,BET mobile,BET movies,BET music,BET news,BET now,BET onblast,BET schedule,BET shows,BET videos,beyonce,black carpet,"
	+ "black college tour,blackbuster movies,blogs,bobby jones gospel,bow wow,brandy,brothers to brutha,brutha,busta rhymes,careers,cassie,casting calls,"
	+ "celebration of gospel,celebrity,celebrity marriages,chat,chris brown,chris rock,ciara,click my pick,college hill,college hill atlanta,college hill interns,"
	+ "college hill reunion,college hill south beach,comedy,comic view,common,community,contests,countdown,day 26,danity kane,diet,"
	+ "dmx,downloads,dream,dr dre,dvd,eating disorder,egypt,eminem,entertainment news,entertainment spotlight,evolution,"
	+ "fantasia,fashion,fitness,flo rida,freestyle friday,full episodes,gospel music,gorilla zoe,gs boyz,gucci mane,hair,harlem heights,head over heels,"
	+ "health,heart health,hell date,hip hop,hip hop awards,hip hop vs america,hot styles,ice cube,interview,iron ring,j holiday,jadakiss,"
	+ "jamie foxx,janet jackson,jay z,jazmine sullivan,jennifer hudson,jim jones,jobs,john legend,kanye west,katt williams,keri hilson,"
	+ "keyshia cole,keyshia cole reunion,keyshia cole the way it is,kid cudi,kirk franklin,lifestyle,lil boosie,lil kim,lil mama,lil wayne, listen up,"
	+ "livin the life of marley,lloyd,ludacris,lyric cafe,makeover,makeup,mariah carey,mario,marvin sapp,mary j blige,martin lawrence,mary mary,mavado,maxwell,"
	+ "michael jackson,meet the faith,message boards,mims,mike jones,mobile,monica,movies,music,music videos,my president,"
	+ "my two cents,nas,nba,nelly,new artists,new music,new releases,new songs,new videos,news,news you should know,ne-yo,notorious,obama,"
	+ "obituary,omarion,onblast,one mic stand,one on one,pamela on politics,parallel paths,patti labelle,photos,playa hater,played by fame,"
	+ "pleasure p,plies,pretty ricky,prince,quiz,r kelly,r & b,ray j,rap,rap city,rap it up,real life divas,red carpet,reggae,rick ross,rihanna,"
	+ "ringtones,rip the runway,rocsi,ron browz,room remix,scholarship,scooter smiff,shari addison,crystal aiken,sex,shine,shows,silm thug,single ladies,skin care,"
	+ "snoop dogg,so special,solange,somebodies,soul food,soul sessions,soulja boy,sound off,specials,sports,spring bling,stanky legg,"
	+ "stay tuned,std,steve harvey,sunday best,t pain,t.i.,tears shears and beauty,terrence j,the boot,the deal,the dream,the game,"
	+ "the way it is,the wire,toccara,top 10 countdown,top 25 countdown,transmission,trey songz,trina,tupac,tv shows,tyler perry,uncf,"
	+ "urban livin,usher,video gospel,videos,virtual awards,vital signs,vote,what the flick,whitney houston,widgets,wild out wednesdays,"
	+ "wu tang,ya heard,young dro,young jeezy";
	
	var field = document.getElementById(oid);	
	//var field = a[i];	
	var classSuggestion = "sf_suggestion";
	this.safari = ((parseInt(navigator.productSub)>=20020000)&&(navigator.vendor.indexOf("Apple Computer")!=-1));
	if(field && !safari){
		field.value = defaultText;
		field.c = field.className;		
		field.onfocus = function(){
			this.value = (this.value == "" || this.value == defaultText) ?  "" : this.value;
		};
		field.onblur = function(){
			this.value = (this.value != "" && this.value != defaultText) ?  this.value : defaultText;
			clearList();
		};
		if (suggestion){
			
			var selectedIndex = 0;
			field.setAttribute("autocomplete", "off");
			var div = document.createElement("div");
			var list = document.createElement("ul");
			list.style.display = "none";
			div.className = classSuggestion;
			
//			if(document.all) // ie
//			{
//			  div.style.left = field.offsetLeft + "px" ;
//			}
//			else // firefox
//			{
//			    div.style.left = ((field.offsetLeft) - (field.parentNode.offsetLeft) )+ "px";
//			}
			list.style.width = field.offsetWidth + "px";
			div.appendChild(list);
			field.parentNode.appendChild(div);	

			field.onkeypress = function(e){
				
				var key = getKeyCode(e);
		
				if(key == 13){ // enter
					selectList(e);
					selectedIndex = 0;
					return false;
				};	
			};
				
			field.onkeyup = function(e){
			
				var key = getKeyCode(e);
		
				switch(key){
				case 13:
					return false;
					break;			
				case 27:  // esc
					field.value = "";
					selectedIndex = 0;
					clearList();
					break;				
				case 38: // up
					navList("up");
					break;
				case 40: // down
					navList("down");		
					break;
				default:
					startList();			
					break;
				};
			};
			
			//startList = 
			function startList(){
			
				var arr = getListItems(field.value);
				if(field.value.length > 0){
					createList(arr);
				} else {
					clearList();
				};	
			};
			
			//getListItems = 
			function getListItems(value){
				var arr = new Array();
				var src = suggestionText;
				var src = src.replace(/, /g, ",");
				var arrSrc = src.split(",");
				for(i=0;i<arrSrc.length;i++){
					if(arrSrc[i].substring(0,value.length).toLowerCase() == value.toLowerCase()){
						arr.push(arrSrc[i]);
					};
				};				
				return arr;
			};
			
			//createList = 
			function createList(arr){				
				resetList();			
				if(arr.length > 0) {
					for(i=0;i<arr.length;i++){				
						li = document.createElement("li");
						a = document.createElement("a");
						a.href = "javascript:void(0);";
						a.i = i+1;
						a.innerHTML = arr[i];
						li.i = i+1;
						li.onmouseover = function(){
							navListItem(this.i);
						};
					
						a.onmousedown = function(){
							selectedIndex = this.i;
							selectList(this.i);	
                           googleSearch(field.id);
							return false;
							
						};	
						
						li.appendChild(a);
						list.setAttribute("tabindex", "-1");
						list.appendChild(li);	
					};	
					list.style.display = "block";				
				} else {
					clearList();
				};
			};	
			
			//resetList = 
			function resetList(){
				var li = list.getElementsByTagName("li");
				var len = li.length;
				for(var i=0;i<len;i++){
					list.removeChild(li[0]);
				};
			};
			
			//navList = 
			function navList(dir){			
				selectedIndex += (dir == "down") ? 1 : -1;
				li = list.getElementsByTagName("li");
				if (selectedIndex < 1) selectedIndex =  li.length;
				if (selectedIndex > li.length) selectedIndex =  1;
				navListItem(selectedIndex);
			};
			
			//navListItem = 
			function navListItem(index){	
				selectedIndex = index;
				li = list.getElementsByTagName("li");
				for(var i=0;i<li.length;i++){
					li[i].className = (i==(selectedIndex-1)) ? "selected" : "";
				};
			};
			
			//selectList = 
			function selectList(e)
			{
	            li = list.getElementsByTagName("li");
	            if(li!=null)
	            {
		            if(selectedIndex>0)
		            {
			            a = li[selectedIndex-1].getElementsByTagName("a")[0];
			            if(document.all) // IE
			            {
			                field.value = a.innerText;
			            }
			            else // firefox
			            {
			                field.value = a.textContent;
			            }
			            
			           if (!e) var e = window.event; 
			           
			            if(e.keyCode == 13)
			            {
				            googleSearch(field.id);
			            }
			            clearList();
		            }
	            }
            };	// function selectList()
			
		};
	};
	
	//clearList = 
	function clearList(){
		if(list){
			list.style.display = "none";
			selectedIndex = 0;
		};
	};		
	//getKeyCode = 
	function getKeyCode(e){
		var code;
		if (!e) var e = window.event;
		if (e.keyCode) code = e.keyCode;
		return code;
	};
	//}
};

// script initiates on page load. 

this.addEvent = function(obj,type,fn){
	if(obj.attachEvent){
		obj['e'+type+fn] = fn;
		obj[type+fn] = function(){obj['e'+type+fn](window.event );}
		obj.attachEvent('on'+type, obj[type+fn]);
	} else {
		obj.addEventListener(type,fn,false);
	};
};
addEvent(window,"load",sField);

