var $bs = jQuery.noConflict();

$bs(document).ready(function() {
	
	showChooserTarget();
	hideChooserTarget();
	showSearchLink();
	hideSearchLink();
});


/**
 * This block functions show or hide options to change target (customer|company)
 */
function showChooserTarget(){
    $bs('.choosertarget').live('mouseover', function(e){
       var linkList = $bs('div', this);
       $bs('div', this).show() ;
    });
}
function hideChooserTarget(){
	$bs('.choosertarget').live('mouseout', function(e){
	       var linkList = $bs('div', this);
	       $bs('div', this).hide() ;
	});
}

/*****END BLOCK SHOW AND HIDE CHOOSER TARGET *********/





function showEmptyText(input,text) {
	if (input.value == '') {input.value = text;}
}

function hideEmptyText(input,text) {
	if (input.value == text) {input.value = '';}
}

//Block function to handle main search input and link
/**
 *This function set listener to link which should on fire event  show box with search input
 */
function showSearchLink(){
    $bs('.container_search_link').live('mouseover', function(e){
    		displaySearchInput(true);

    });
}
/**
 *This function set listener to link which should on fire event and hide box with search input
 */
function hideSearchLink(){
    $bs('.container_search_link').live('mouseout', function(e){
    	
    	// google chrome bug for treats mouseout when hovering on child element
    	if (e.relatedTarget.className !== 'searchfield') {
    		displaySearchInput(false);
    	}

    });
}
/**
 * This function hide or show box wiht search input
 * @var boolean show - this varabile branch by show or hide searchInput 
 */
function displaySearchInput(show){
    var searchInput = $bs('.search_input');
    
    if(!show){
        $bs(searchInput).hide();
    } else {
        $bs(searchInput).show();
    }
    
}
//end block function to handle main search input and link

