﻿/*Recently:jiafei Updated Date: 2009-6-1 9:50*/
var duk = {};
duk.__init__ = function() {
	duk.initSearch();
}

duk.search = function(text, type) {
	text = encodeURIComponent(text);
	var searchUrl;
	if (type == 'search_title') {
		searchUrl = "http://eazy.bz/search/" + text;
	} else if (type == 'search_body') {
		searchUrl = "http://eazy.bz/search/" + text + "/a0-b2.html";
	} else if (type == 'search_all') {
		searchUrl = "http://eazy.bz/search/" + text + "/a0-b0.html";
	} else if (type == 'search_user') {
		// TODO
		searchUrl = "http://eazy.bz/search/";
	} else if (type == 'search_problem') {
		searchUrl = "http://eazy.bz/search/" + text + "/a3-b0.html";
	}
	window.open(searchUrl);
}

duk.initSearch = function() {
	duk._initSearchBox();
	jQuery("#opt, #searchoption").bind('mouseover', function(event) {
		if (jQuery("#searchoption").is(':hidden')) {
			var offset = jQuery("#opt").offset();
			var left = offset.left - 6 + 'px';
			var top = offset.top - 44 + 'px';
			jQuery("#searchoption").css('top', -40).css('left', 180).show();
		}
	});

	jQuery("#searchoption").bind('mouseout', function() {
		jQuery("#searchoption").hide();
	});
}

duk._initSearchBox = function() {
	jQuery("#search_keywords").keypress( function(e) {
		if (e.which == 13) {
			duk.search(jQuery("#search_keywords").val(), "search_all");
			jQuery("#search_keywords").blur();
		}
	});
	
	jQuery("#searchoption").click( function(e) {
		var text = jQuery("#search_keywords").val();
		var type = e.target.className;
		duk.search(text, type);
	});
}

duk.initSecondaryNavigation = function() {
	duk._initSearchBox();
	jQuery("#brandopt span").css({cursor:"pointer",fontSize:"12px"});
	jQuery("#brandopt span, #brandopt a:first").click( function(e) {
		var text = jQuery("#search_keywords").val();
		if (text == "請輸入搜索關鍵詞...") {
			alert("輸入搜索關鍵詞...");
			return ;
		}
		duk.search(text, "search_all");
	});
	
	jQuery("#brandopt, #searchoption").bind('mouseenter', function(){
		jQuery("#brandopt").children(":first").addClass("mouseover");
		jQuery("#searchoption").show();
	});
	
	jQuery("#brandopt, #searchoption").bind('mouseleave', function(){
		jQuery(this).prev().removeClass("mouseover");
		jQuery("#searchoption").hide();
	});

	jQuery("#pbobj > a, #pbtar").bind('mouseenter', function(){
		jQuery("#pbtar").show();
		jQuery("#pbobj a").addClass('mouseover');
	});
	
	jQuery("#pbobj, #pbtar").bind('mouseleave', function(){
		jQuery("#pbtar").hide();
		jQuery("#pbobj a").removeClass('mouseover');
	});
	
	jQuery("#ppobj a, #pptar").bind('mouseenter', function(){
		jQuery("#ppobj a").addClass('mouseover');
		jQuery("#pptar").show();
	});
	
	jQuery("#ppobj, #pptar").bind('mouseleave', function(){
		jQuery("#ppobj a").removeClass('mouseover');
		jQuery("#pptar").hide();
	});

	if (!jQuery.cookie('visited')) {
		var date = new Date();
		date.setTime(date.getTime() + (365 * 24 * 60 * 60 * 1000));
		jQuery.cookie('visited', '1', { path: '/', domain: 'eazy.bz', expires: date });
		jQuery("#tips_cfloor").show();
		jQuery("#tips_cfloor a").click(function(){
			jQuery("#tips_cfloor").hide();
			return false;
		});
	}
	
	jQuery('#notice').cycle({
	  	pause:1,
	  	timeout: 4000,
	  	speed: 400,
	  	height: 8,
	  	fx: 'scrollUp'
	});
	
	if(jQuery(".dktemp").width() < 1006) jQuery(".dktemp").css("width","1006px");
}

duk.footer = function() {
	 document.write('<div id="bottomInfo"><div class="bottomInfo"><a href="#" target="_blank">公司簡介</a>|<a href="#" target="_blank">公司動態</a>|<a href="#" target="_blank">產品和服務</a>|<a href="#" target="_blank">合作夥伴</a>|<a href="#" target="_blank">團隊建設</a>|<a href="#" target="_blank">誠聘英才</a>|<a href="#" target="_blank">法律聲明</a>|<a href="#" target="_blank">聯繫我們</a>|<a href="#" target="_blank">幫助中心</a>|<a href="#" target="_blank">友情鏈接</a></div>');
	 document.write('<div class="bottomcopyright">&copy;2008-2010   <a href="http://eazy.bz/" target="_blank">幸福生活空間(eazy.bz)</a>版權所有<br />幸福生活真實，溫暖，豐富的網絡家園。<br /><a href="http://www.discuz.net/" target="_blank">discuz!技術支持</a>&nbsp;&nbsp;<div class="police"><a href="/" target="_blank"><img src="http://eazy.bz/ui//pingping.gif" height="53" border="0" /></a>&nbsp;<a href="/" target="_blank"><img src="http://eazy.bz/ui/police_station.gif" border="0" /></a>&nbsp;<a href="/" target="_blank"><img src="http://eazy.bz/ui/anan.gif" height="53" border="0" /></a></div><div class="logo_foot"><a href="http://eazy.bz/ui/" target="_blank"><img src="http://eazy.bz/ui/logo_foot.gif" border="0" /></a></div></div></div>');
}

duk.util = {};
duk.util.setHomepage = function(obj, url) {
	if (_dk.client.isIE) {
		obj.style.behavior = "url(#default#homepage)";
		obj.setHomePage(url);
	} else {
		return false;
	}
}

duk.util.setCopy = function(_sTxt) {
	if (navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
		clipboardData.setData('Text', _sTxt);
		alert("網址「" + _sTxt + "」\n已經複製到您的剪貼板中\n您可以使用Ctrl+V快捷鍵粘貼到需要的地方");
	} else {
		prompt("請複製網站地址:", _sTxt);
	}
}

duk.util.addBookmark = function(site, url) {
	if (navigator.userAgent.toLowerCase().indexOf('ie') > -1) {
		window.external.addFavorite(url, site)
	} else if (navigator.userAgent.toLowerCase().indexOf('opera') > -1) {
		return;
	} else {
		return;
	}
}

jQuery(window).resize(function(){	
	if(document.documentElement.clientWidth <= 1006){
		jQuery(".dktemp").css({width:"1006px"});
	}else{
		jQuery(".dktemp").css({width:"98%"});
	}
})
