// Setup JS events when the DOM is ready
$(document).ready(function(){
    $("#search_box").focus(clearbox);
    $("#search_box").blur(clearbox);
	productOverview();
	$("a.popup").click("this.target='_blank'");
});

// Reset default text in input box
function clearbox(){
    if (!this.default_value) this.default_value = this.value;
    
    if (this.value == ''){
        this.value = this.default_value;
    } else if (this.value == this.default_value){
        this.value = '';
    }
}

// Product overview page
function productOverview(){
	
	if ($("#panel_products #body h3").get().length > 0){
		var opts = '<option value="top">Jump to...</option>';
		$("#body h2").after('<p><select id="quickjump"></select></p>');
	
		$("#panel_products #body h3").each(function(i){
			this.id = "type" + i;
			if( i > 0 ) $(this).before('<a href="#top" class="back2top">Top</a>');
			opts += '<option value="' + i + '">'+ this.innerHTML + '</option>';
			});
		$("#quickjump").get(0).innerHTML = opts;
		$("#quickjump").bind("change",function(){location.href = "#type" + this.value;});
	}
}
