/*!
 * Copyright (C) 2004-2009 Giant Interective Group, Inc. All rights reserved.
 * 版权所有 2009-2011 e7工作室
 *
 * version #version, #date by Cailijuan
 * Depend on jQuery 1.3.x
 */
if (typeof Easy == 'undefined') {
	var Easy = function() {
	};
}

( function($) {

	Easy.loading = function(divId) {
		$('#' + divId + '').html('正在加载......');
	};

	Easy.sethome = function() {
		alert(giant.B.msie);

		if (giant.B.msie) {
			document.body.style.behavior = 'url(#default#homepage)';
			document.body.setHomePage(Path.domain + '/index');
		} else {
			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', Path.domain + '/index');
			}
		}
	};
	
	Easy.loadNewPage = function(url){
		GiantAjax.requestHtml( {
			url : url,
			before: function() {
				Easy.loading('div_list'); 
			},
			success : function(html) {
				$('#div_list').html(html);
			}
		});
	};
	
	/**
	 * 菜单效果。
	 */
	Easy.showChindMenu = function(id) {
		var menu = $('#' + id +'');
		if (menu.css('display') == 'none') {
			menu.show('fast');
		} else {
			menu.hide('fast');
		}
	};
	
	/**
	 * 搜索
	 */
	Easy.search = function(code) {
		var url = '/search';
		var kw = $('#input_search_value').val();
		if(typeof kw == 'undefined' || kw == ''){
			kw = $('#main_search_value').val();
		}
		if(typeof kw != 'undefined' && kw != ''){
			url += '?kw=' + encodeURI(kw);
			if(typeof code != 'undefined'){
				url += '&code=' + code;
			}
		}
		window.location = url;
	};

})(jQuery);
