// JavaScript Document
function fnSubmit()
{
	name.onfocus = function()
	{
	    if(this.value=="企业搜索")
		{
		    this.value="";
		}
	}
    var sKey = document.getElementById("name").value;
    if(sKey && sKey.length>1 && sKey!="企业搜索")
    {
	    //var sor = getSort();
		var sURL = "http://"+KF_BIZAPP+'.'+KF_DOMAINNAME+"/sc.htm?key="+sKey+"&t=0" + "&r=search&p=0&i=0";
		document.location.href = sURL;
		return;
	}
	else if(sKey="企业搜索")
	{
	    alert("请输入企业名称！")
	}
    else
    {
        alert("查询条件太短，请输入企业名称！")
    }
}
function KeyDown()
{
    if (event.keyCode == 13)
    {
        event.returnValue=false;
        event.cancel = true;
        fnSubmit();
    }
}

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("抱歉！您的浏览器不支持直接设为首页。请在浏览器地址栏输入“about:config”并回车然后将[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);
        }
    }
}

function doFocus()
{
    var name = document.getElementById("name");
	if(name.value=="企业搜索")
	{
	    name.value="";
		name.style.color = "#333333";
	}
}
function doBlur()
{
    var name = document.getElementById("name");
	if(name.value=="企业搜索" || name.value=="")
	{
	    name.value="企业搜索";
		name.style.color = "#9e9e9e";
	}
}
function bn_over()
{
    document.getElementById("search").style.backgroundPosition = "0 -24px";
}
function bn_out()
{
    document.getElementById("search").style.backgroundPosition = "0px 0px";
}

//导航输出
var g_IndexNode = 0;
var g_bTencentIP = 0;
var CGI_TXC = 'cgi/txc?';

function crm_creat_head(inode)
{
    g_IndexNode = inode;
    var sContent = "<div id=div_head name=div_head></div>";
    document.write (sContent) ; 
    crm_creat_head_act(g_IndexNode);   
    if(g_IndexNode ==0 &&　(window.location.href == "http://bizapp.qq.com/index.htm" || window.location.href == "http://bizapp.qq.com/") )
    {
        TXC_Sumit();
    }
}

function crm_creat_head_act(inode)
{
    var i=0;
    var sHead_Array = new Array(
    ["首 页", "index.htm","0"],
    //["产品特性", "product.htm","6"],
    ["产品特性", "texing.htm","1"],
    //["企业资源", "home_webpres.htm","2"],
	//["成功案例", "case.htm","7"],
    ["如何购买", "buy.htm","2"],
    ["产品帮助", "help.htm","3"],
	["腾讯客服", "http://service.qq.com/category/qqcrm.html","4"],
    ["统  计", "http://bizapp.oa.com/abcde.htm","5"]
    );
    
    var iLength = sHead_Array.length - 1 ;
    if(inode ==0 )
    {
        iLength += g_bTencentIP;
    }
    
    var sWidth = "33%";
    if(g_bTencentIP ==1)
    {
        sWidth = "22%"
    }

var sContent= '<div class="topi">';
sContent+= '<div class="area"><span class="s1"><a href="javascript:void(0)" onClick="SetHome(this,window.location)" target="_top">设为首页</a></span><span class="s2"><a href="http://www.qq.com" target="_blank">腾讯QQ</a></span><span><a href="http://3gqq.qq.com/" target="_blank">手机门户</a></span><span><a href="http://game.qq.com/index.shtml" target="_blank">游戏中心</a></span><span><a href="http://service.qq.com/category/qqcrm.html" target="_blank">腾讯客服</a></span></div>';
sContent+= '</div>';   

sContent+= '<div class="head">';
sContent+=    '<div class="area">';
sContent+=         '<div id="logo"><h1><a href="index.htm"><img src="img/090507/logo.jpg" alt="企业QQ" /></a></h1></div>';
sContent+=    '</div>';
sContent+= '</div>';

sContent+= '<div class="area">';
sContent+=    '<div class="nav">';
sContent+=       '<div class="nav_l"></div>';
sContent+=        '<div class="nav_c">';

for(i = 0; i < iLength; i++)
{
		if(inode == sHead_Array[i][2])
        {
			if(i==0)
			{
			sContent += "<a hidefocus='true' class='s1 ls' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
			}
			else if(i==4)
		    {
			sContent += "<a hidefocus='true' class='s1' target='_blank' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
		    }
			else
			{
            sContent += "<a hidefocus='true' class='s1' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
			}
        }
		else
		{
			if(i==0)
			{
            sContent += "<a hidefocus='true' class='ls' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
			}
			else if(i==4)
		    {
			sContent += "<a hidefocus='true' target='_blank' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
		    }
			else
			{
			sContent += "<a hidefocus='true' href='"
            sContent += sHead_Array[i][1];
            sContent += "'>";
            sContent += sHead_Array[i][0];
			sContent += '</a>';
			}
		}

}

sContent+=        '</div>';
sContent+=        '<div class="search" id="search"><input class="search_text" type="text" id="name" onfocus="doFocus()" onblur="doBlur()" onkeydown="KeyDown();" value="企业搜索" /><a class="bn" id="Submit1" href="#" onmouseover="bn_over()" onmouseout="bn_out()" onclick="fnSubmit();return false"></a></div>';
sContent+=        '<div class="nav_r"></div>';
sContent+=    '</div>';
sContent+= '</div>';
		
    document.getElementsByTagName("div").div_head.innerHTML = sContent;
}

function TXC_Sumit()
{
	var sURL="";
	SendAJAXRequest(CGI_TXC,"POST", TXC_OnSumitReturn,sURL);  
}

function TXC_OnSumitReturn(xmlobj)
{
	var xmlDoc = new ActiveXObject("Microsoft.XMLDOM"); 
	xmlDoc.async = false ;
	xmlDoc.loadXML(xmlobj.responseText);
	
	var value = xmlDoc.selectSingleNode("//root/r");
	var r=parseInt(value.text);

    crm_creat_head_act(g_IndexNode);
}