// JavaScript Document 

// JavaScript Document 设置首页
function SetHome(obj,vrl){ 
    try{ 
       obj.style.behavior='url(#default#homepage)';obj.setHomePage(vrl); 
    } 
    catch(e){ 
        if(window.netscape) {
            try { 
                netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
            } 
            catch (e) { 
                alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。"); 
            } 
            var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch); 
            prefs.setCharPref('browser.startup.homepage',vrl); 
         } 
    } 
} 


// JavaScript Document 鼠标触发按钮
function SetBtn(preFix, idx){
    for(var i=1;i<4;i++){
        document.getElementById("web_btn_"+i).className = "btn_off";
        document.getElementById("web_con_"+i).style.display = "none";
    }
    document.getElementById("web_btn_"+idx).className = "btn_on";
    document.getElementById("web_con_"+idx).style.display = "block";
    if(idx==2)
    {
        ChangeSearchMenu(10);
    }
}


// JavaScript Document 类别

var Options=[
[["投资决策顾问"],["专项投资委托"],["投资运行服务"],["投资咨询"],["投资理财咨询"],["投资理财策划"]],
[["授信贷款"],["专项贷款"],["贸易贷款"],["中小企业无抵押贷款"],["抵押贷款"],["质押贷款"],["保证融资"],["保函融资"],["金融租赁"],["经营租赁融资"],["典当融资"],["票据贴现"],["质押融资"],["应付账款融资"],["商业票据融资"],["应收账款融资"],["企业间借贷融资"],["公司并购融资"],["企业债券"],["短期融资券"],["可转换证券融资"],["可交换债券融资"],["认股权证融资"],["项目抵押融资"],["项目股权合作融资"],["项目合作投资——固定"],["BOT（建设-经营-移交)"],["BT（建设-移交）"],["风险投资"],["战略投资"],["私募融资"],["并购重组"],["产权交易"],["股权质押融资"],["IPO上市股票融资"],["单一信托："],["集合信托"],["不动产投资信托(REIT)"],["金融资产证券化"],["金融资产证券化"],["贸易信用证融资"],["备用信用证融资"],["买方信贷"],["卖方信贷"],["委托贷款"],["来料加工"],["来料加工"],["来料加工"],["来样加工"],["来件装配"],["补偿贸易"],["产业发展基金"],["政府补助"],["政府贴息贷款"],["科技三项经费"],["环保专项治理资金"],["综合授信"],["信用担保贷款"],["买方贷款"],["异地联合协作贷款"],["项目开发贷款"],["出口创汇贷款"],["自然人担保贷款"],["个人委托贷款"],["其他融资方式"],["短期资金拆借"],["小额贷款"],["房地产融资"],["中大型矿产转让"]],
[["网络招商"],["承接产业转移"],["招商委托"],["“龙头企业”引进"],["产业规划与产业招商"],["高效招商活动支持"],["区域投资环境评测"],["招商宣传策划"],["招商培训"],["招商咨询"]],
[["公司清算与破产"],["国有企业股份制改造"],["购并策划"]],
[["审计"],["资本验资"],["专项审计"]],
[["会计服务"],["税务服务"],["工商服务（内外资）"],["财务顾问"]],
[["外资公司注册"],["内资公司注册"],["股份公司注册"],["香港公司注册"],["商标代理"],["专利代理"],["市场调查"],["营销策划"],["工程监理"],["会展服务"]],
[["房地产事务"],["民商诉讼业务"],["金融类服务"],["公司事务,涉外法律服务"]],
];

// ------------------------

function ChangeKeyWord(theKeyWord,KeyName){
	var str = theKeyWord.value;
	document.getElementById("hideKey").value = KeyName;
	if (str.substring(str.length-7,str.length)=="关键字进行搜索" || str ==""){
		if(KeyName.length == 0){KeyName = "";}
		theKeyWord.helptext="输入" + KeyName + "关键字进行搜索";
		theKeyWord.value="输入" + KeyName + "关键字进行搜索";
	}
}

function ChangeSearchKeyword(index){
	var PostURL = "";
	var theKeyWord = document.getElementById("txtKeyWord");
	switch(index)
	{
		case 0 : //全部
			PostURL = "http://search.topfo.com/SearchAllResult.aspx";
			document.getElementById("form_Search").action = PostURL;
			ChangeKeyWord(theKeyWord,"");
			break;
		case 1 : //投资
			PostURL = "http://search.topfo.com/SearchResultCapital.aspx";
			document.getElementById("form_Search").action = PostURL;
			ChangeKeyWord(theKeyWord,"资本");
			break;
		case 2 : //融资
			PostURL = "http://search.topfo.com/SearchResultProject.aspx";
			document.getElementById("form_Search").action = PostURL;
			ChangeKeyWord(theKeyWord,"企业项目");
			break;
		case 3 : //招商
			PostURL = "http://search.topfo.com/SearchResultMerchant.aspx";
			document.getElementById("form_Search").action = PostURL;
			ChangeKeyWord(theKeyWord,"政府项目");
			break;
		case 4 : //资讯
			PostURL = "http://search.topfo.com/SearchResultNews.aspx";
			document.getElementById("form_Search").action = PostURL;
			ChangeKeyWord(theKeyWord,"资讯");
			break; 
		default:
			break;
	}
}

function focusEdit(theKeyWord){
	if ( theKeyWord.value == theKeyWord.helptext ){
		theKeyWord.value = "";
		theKeyWord.helptext ="";
	}
	return true;
}
function blurEdit(theKeyWord){
	var KeyName = "";
	KeyName = document.getElementById("hideKey").value;
	if ( theKeyWord.value.length == 0 ){
		theKeyWord.value = "输入" + KeyName + "关键字进行搜索";
		theKeyWord.helptext = "输入" + KeyName + "关键字进行搜索";
	}
}
function ClearEdit(theKeyWord){
  	theKeyWord.value ="";
	theKeyWord.helptext ="";
}

function ChangeSearchMenu(index){
	var objs = document.getElementsByName("searchmenu");
	var spobjs = document.getElementsByName("searchmenusp");
	if(Number(index)<10)
	{
	    var num = objs.length;
	    var preMenuIndex = index - 1;
	    for(i=0;i<5;i++)
	    {
		    objs[i].className = "";
		    spobjs[i].className = "";
	    }//alert(index);
	    objs[num - 1].className = "nolast";
	    if(index == 0 || index == 1)
		    objs[index].className = "on1";
	    else if(index == (num - 1))
		    objs[index].className = "nolast on1";
	    else
		    objs[index].className = "on2";
    		
	    spobjs[index].className = "";
    	
	    ChangeSearchKeyword(index);	
	}
	else
	{
	    for(i=5;i<13;i++)
	    {
		    objs[i].className = "";
		    spobjs[i].className = "";
	    }
	    initOptions(index);
	    index=Number(index)-5;
	    objs[index].className = "on21";
	    spobjs[index].className = "";
	}
}

//---------------------------------
var Options1 = Options[0];
function initOptions(selnum)
{
    var temp_index = (Number(selnum)-10);
    Options1 = [];
    Options1 = Options[temp_index];
	document.getElementById("searchType2").value=selnum;
    document.getElementById("search2").value="请选择类别进行搜索";
    if(document.getElementById("_li_search2")!=null)
    {
        document.getElementById("_li_search2").innerHTML="";
        document.getElementById("_li_search2").style.display="none";
    }
    $.dmSelect("search2","sel_search2",Options1);
}

//---------------------------------

$.dmSelect = function(name,value,data){
    $("#" + name).attr("readonly","readonly");  //设置控件只读
    var top = $("#" + name).offset().top;   //获取控件top、left位置和width、height
    var left = $("#" + name).offset().left;
    var height = $("#" + name).height();
    var width = $("#" + name).width()-50;
    var option_open = false;      //标记是否打开下拉option
    function __dropheight(l){var h;if(l>10 || l<1){h = 10 * 20;}else{h = l * 20; h += 2;}return h;}  //计算下拉option显示高度
    var div_html = "<div id='_li_"+name+"' style='position:absolute;background-color:#FFFFFF;top:"+(top+height+5)+"px;left:"+left+"px;width:"+((width<30)?30:width)+"px;height:"+__dropheight(data.length)+"px;border:1px #666666 solid;overflow-x:hidden;overflow-y:auto;display:none;z-index:1000;'>";
    //for循环填充option
    for(var i = 0;i < data.length; i++){div_html += "<div style='text-align:left;padding-left:5px; text-indent:10px;line-height:25px;' value='" + data[i][1] + "'>" + data[i][0] + "</div>";}
    div_html += "</div>";
    $("#" + name).after(div_html);  //添加到input控件后面
    function __open_option(){$("div[id^='_li_']").hide();$("#_li_" + name).show();option_open=true;}  //显示下拉option
    function __hide_option(){$("#_li_" + name).hide();option_open=false;$(document).unbind("click",__hide_option);}  //隐藏下拉option
    $("#" + name).click(function(event){if(option_open){__hide_option();}else{__open_option();$(document).bind("click",__hide_option)}event.stopPropagation();});
    $("#_li_" + name + " > div").hover(function(){$(this).css({"background-color":"#CCCCCC"});},function(){$(this).css({"background-color":"#FFFFFF"});})
    .click(function(){
        $("#" + name).val($(this).html());
        $("#" + value).val($(this).attr("value")); 
        //alert($("_li_"+name).css);
    });
};

$(document).ready(function(){
    $.dmSelect("search2","sel_search2",Options1);
    
});

function getURL(type)
{
    var bid=document.getElementById("searchType2").value;
    var mid=document.getElementById("search2").value;
    if(mid=='请选择类别进行搜索')
    {
        mid="";
    }
    var myurl="http://union.topfo.com/searchAgencies.aspx";
    if(type==2)
    {
         myurl="http://union.topfo.com/searchService.aspx";
    }
    window.open(myurl+"?t="+bid+"&m="+escape(mid));
}