var countKeyDownPress = 0;
var countKeyUppPress = 0;

function lookup(inputString,element,page,pageKey) {
 
 
   if(inputString.length < 2) {
 	
	  // Hide the suggestion box.
		$('#suggestions').hide();
		
    } else {
		
			
			$.post("http://www.lindahl.se/v3_site/load_content.php?op=script&name=callback", {queryString: ""+inputString+"*"+page+"*"+pageKey}, function(data){
			
				if(data.length >0) {
					
							
					$('#autoSuggestionsList').html(data);
					$('#suggestions').show();
					
				}
			});
	 
		  
	
    }
} // lookup


function linkToCooworker(dLink)
{
	document.location = dLink;	
}

function fill(thisText,thisValue) {

    $('#inputString').val(thisText);
   $('#suggestions').hide();
}


/*function toggleBox(oElement,oEvent)
{
	var keyPressed = oEvent.keyCode;
	var keyUpp      =  38;
	var keyDown     =  40;
	var keyEnter    =  13;
	
	var nbrOfIndexes = 0;		
	$('#autoSuggestionsList li').each(function(){
	   nbrOfIndexes++;
	});
 
	switch(keyPressed)
	{
		case keyUpp:
			
			
			if(countKeyUppPress < 0)
			{
					countKeyUppPress = 	nbrOfIndexes-1;
					$('li:eq('+ countKeyUppPress +')').css('backgroundColor','#e2d8c9');
					$('#fillNamesTest').val($('li:eq('+ countKeyUppPress +')').text());
					countKeyUppPress --;
			}else{
			
					
					$('li:eq('+ countKeyUppPress +')').css('backgroundColor','#e2d8c9');
					$('#fillNamesTest').val($('li:eq('+ countKeyUppPress +')').text());
					countKeyDownPress = countKeyUppPress+1;
					countKeyUppPress --;
			}
			
		break;
		
		case keyDown:
			 
			
				if(countKeyDownPress > nbrOfIndexes -1)
				{
					countKeyDownPress=0;
					$('li:eq('+ countKeyDownPress +')').css('backgroundColor','#e2d8c9');
					$('#fillNamesTest').val($('li:eq('+ countKeyDownPress +')').text());
					countKeyDownPress++;
					
				}else{
					
					$('li:eq('+ countKeyDownPress +')').css('backgroundColor','#e2d8c9');
					$('#fillNamesTest').val($('li:eq('+ countKeyDownPress +')').text());
					countKeyUppPress = countKeyDownPress-1;
					countKeyDownPress++; 
				}

		break;
		
		case keyEnter:
			alert('Enter');
			
		break;
	}
	
	
}*/
	


function getPos(oElement)
{
	
	var iReturnValueY = 0;
	var iReturnValueX = 0;
	while( oElement  != null ) {
		iReturnValueY    += oElement.offsetTop;
		iReturnValueX    += oElement.offsetLeft;
		oElement 		  = oElement.offsetParent;
	}
	
	
	document.getElementById('suggestions').style.top  = iReturnValueY+15+'px';
	document.getElementById('suggestions').style.left = iReturnValueX+'px';
	
	
	
}

