
$(document).ready(function() {
	if($.cookie("toggle_ddl_filters") == 1) { swap('ddl_filters','ddl_filters_img', true); };
	if($.cookie("toggle_fundhouse_info") == 1) { swap('fundhouse_info','fundhouse_img', true); };
	if($.cookie("toggle_edit_options") == 1) { swap('edit_options','editoptions_img', true); };
});


var fadeInSuggestion = function(suggestionBox, suggestionIframe) 
{
	$(suggestionBox).fadeTo(300,1);
};

var fadeOutSuggestion = function(suggestionBox, suggestionIframe) 
{
	$(suggestionBox).fadeTo(300,0);
};


function selectItem(row){
    //alert("sel item");
    return row[1];
}

function formatItem(row){
    //alert("format item");
    return row[1] + " (" + row[0] + ")";
}

function navigate(sURL){
	document.location.href = sURL;
}

function doSearch(sender) {
	var newUrl = jsBaseSearchURL;
	if(sender == null || sender.id != "CompanyTypeDropDownList") {
    	var company = document.form1.CompanyDropDownList[document.form1.CompanyDropDownList.selectedIndex].value;
    	newUrl += '&company='     + company;
    }
	newUrl += '&domicile='    + document.form1.DomicileDropDownList[document.form1.DomicileDropDownList.selectedIndex].value;  
    newUrl += '&companytype=' + document.form1.CompanyTypeDropDownList[document.form1.CompanyTypeDropDownList.selectedIndex].value;  
    newUrl += '&lang=' + QSlang;

    //because subfond selector might be disabled we make this check
    if(document.form1.FundDropDownList.disabled == false){
	    newUrl += '&fund='   + document.form1.FundDropDownList[document.form1.FundDropDownList.selectedIndex].value;  
	}

    if(company == jsOldCompanyArg) {
	    newUrl += '&search='      + document.form1.SearchTextBox.value;
    }

	navigate(newUrl);
}

function resetForm(){
    document.form1.SearchTextBox.value = "";
    document.form1.CompanyDropDownList.selectedIndex = 0;
    document.form1.DomicileDropDownList.selectedIndex = 0;
    //document.form1.CompanyTypeDropDownList.selectedIndex = 0;
    document.form1.FundDropDownList.selectedIndex = 0;
}


