var SearchApi = {
    search_in: 'casino',
    status: 'closed',
    search_in_target: function (target)
    {   
        this.search_in = target;
    },
    
    open : function (event,open_only)
    {
        this.stop(event);
        if (SearchApi.status == 'open' && open_only) {
            return true;
        }
        
        var targetDiv = document.getElementById('srcopt');
            targetDiv.style.zIndex = 9998;
		var a = targetDiv.style.display;
		if ( a == 'none') {
            targetDiv.style.display = 'block';
            SearchApi.status = 'open';
	 		document.onclick = function(e) {
	 		    if (! e) { e = window.event; }
				SearchApi.stop(e);
                SearchApi.status = 'closed';
				targetDiv.style.display = 'none';
			}
		} else {
            SearchApi.status = 'closed';
	 		targetDiv.style.display = 'none';
	 		document.onclick = null;
	 	}
	},
    stop : function (ev) {
		if (typeof ev.stopPropagation == "function") {
			ev.stopPropagation();
		} else {
			ev.cancelBubble = true;
		}
	},
   
	go : function (form,base_url)
    {
        switch (this.search_in) {
		
           case 'jeu' :
                            form.action = base_url + '/rechercher.php?section=2&search='+encodeURI(form.search_terms.value);
                            return true;
							
			 case 'news' :
                            form.action = base_url + '/rechercher.php?section=3&search='+encodeURI(form.search_terms.value);
                            return true;
            case 'article' :           
                            form.action = base_url + '/rechercher.php?section=4&search='+encodeURI(form.search_terms.value);
                            return true;
							
			case 'casino' :
			default:
                            form.action = base_url + '/rechercher.php?section=1&search='+encodeURI(form.search_terms.value);
                            return true;
			
        }
        return false;
    }
    
	
}
var clear_search_fields = true;
function on_focus_search(e,input)
{
    if (clear_search_fields) {
	    input.value = "";		
		clear_search_fields = false;
    }
    return true;
}

