// JavaScript Document
var siteDir = 'chinayude.cn';

function initGradient()
{
	$('#board').gradient({
		from:      'ffffff',
		to:        '43c5f3',
		direction: 'horizontal' //vertical
	});
}

function initScrollImg()
{
	$(".scrollable").scrollable({circular: true}).autoscroll({autoplay:true});
}

function btnShowInfo(strtype,obj)
{
	$(".btns-index > a:not(.more)").attr('className','btn-index-change');
	obj.className = 'btn-index-change-on';
	
	switch(strtype)
	{
		case "company":
			$("#company-info").show(200);
			$("#news-center").hide();
			break;
		case "news":
			$("#company-info").hide();
			$("#news-center").show(200);		
			break;
	}
}

function sycheight()
{
	if( $(".AreaL").height() > $(".AreaR").height() )
		$(".AreaR").height($(".AreaL").height());
	else
		$(".AreaL").height($(".AreaR").height());
}

function onLineSearch()
{
	$("#btnsearch").click(function(){
		if($("#searchkey").val()=="")
		{
			alert("请输入查询关键字！");
			return false;
		}
		else
		{
		window.location = "http://"+window.location.host+"/" + siteDir + "/?cn-s-l-"+ escape($("#searchkey").val()) +".html";
		}
	});
}


function onLineSearchSidebar()
{
	$("#btnsearch1").click(function(){
		if($("#searchkey1").val()=="")
		{
			alert("请输入查询关键字！");
			return false;
		}
		else
		{
		window.location = "http://"+window.location.host+"/" + siteDir + "/?cn-s-l-"+ escape($("#searchkey1").val()) +".html";
		}
	});
}

function addLoadEvent(func) {
    var oldonload = window.onload;
    if (typeof window.onload != 'function') {
        window.onload = func;
    } else {
        window.onload = function() {
           oldonload();
           func; 
       }
    }
}

function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
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);
                 }
        }
}

/*
<a onclick="AddFavorite(window.location,document.title)">加入收藏</a>
<a onclick="SetHome(this,window.location)">设为首页</a>
*/
