$("<link rel='shortcut icon' href='http://www.myday.com.tw/myday09/images/myday-shortcut.gif'/>").appendTo("head");

/* Yahoo Tree Japan 點擊數 处理 沈大伟   type ：1 (yahoo) 2:(ebay)*/

function clickcounter_bid(w_categoryid,w_cc)   
{
	$.get('ajax/click_change.php',{w_cc:w_cc,w_categoryid:w_categoryid},
		  function(data)
		  {
		  });
}




function subString(str, len, hasDot){ 
    var newLength = 0; 
    var newStr = ""; 
    var chineseRegex = /[^\x00-\xff]/g; 
    var singleChar = ""; 
    var strLength = str.replace(chineseRegex,"**").length; 
    for(var i = 0;i < strLength;i++) 
    { 
        singleChar = str.charAt(i).toString(); 
        if(singleChar.match(chineseRegex) != null) 
        { 
            newLength += 2; 
        }     
        else 
        { 
            newLength++; 
        } 
        if(newLength > len) 
        { 
            break; 
        } 
        newStr += singleChar; 
    } 
     
    if(hasDot && strLength > len) 
    { 
        newStr += "..."; 
    } 
    return newStr; 
} 
//$(function(){
//	$("a[href^=http]").attr("target","_blank");
//	
//	$("body.outside a[href^=http]").click(function(){
//		var tar = $(this).attr("href");
//		if(tar.match('myday')||tar.match('goo')||tar.match('bidbomb')){
//			/*	alert('站內');	*/
//			return true;
//		}
//		else {
//			//alert('目前您即將連結到國外網站，\n1.請記得複製網址並回填至詢價單\n2.填寫完畢即可依步驟完成詢價。');			
//
//			$( ".dialog" ).bind( "dialogbeforeclose", function() {
//				  location.href=tar;
//				  window.open('http://www.myday.com.tw/myday09/order_buy.php');
//			});
//			$( ".dialog" ).dialog({
//				modal: true,
//				width: 450,
//				buttons: {
//				Ok: function() {
//					$( this ).dialog( "close" );
//					}
//				}
//			});
//
//		//return false;
//		//location.href='http://www.myday.com.tw/myday09/order_buy.php';
//		}
//		return false;
//	});
//
//	
//});



/*	自動評價百分比	*/
$(function(){
	var b = $("#bids").html();
	var w = $("#wins").html();
	var t = w / b;
	$("#total").html(Math.round(t*100)+"%");
});

$("#NavCt li a").click(function(){
	$("#NavCt li a").removeClass("focus");
	//$(this).addClass("focus");
});

// 右上角高亮 新手上路/填委託單 RollOver效果
$("#HLlink1").hover(function(){
	$(this).find("img").attr("src","images/button_beginner_hover.gif");
},function(){
	$(this).find("img").attr("src","images/button_beginner.gif");
	});	
$("#HLlink2").hover(function(){
	$(this).find("img").attr("src","images/button_request_hover.gif");
},function(){
	$(this).find("img").attr("src","images/button_request.gif");
});

$("#HeadType1 #NavSub ul#NavJp li a:eq(0)").css("paddingLeft","10px");

// 首頁系的左側分類 js 效果	
$(function(){					 
	$("#MenuJp li").hover(
	function(){
		var index = $("#MenuJp li").index(this);
		$(this).find(".MenuJp_2nd").show();
	},
	function(){
		$(this).find(".MenuJp_2nd").hide();
	});
});
//	排行榜的RollOver效果 修正版
$("div.TabsTypeA ul").each(function(){
	var style = new Array("0px 0px","0px -30px","0px -60px","0px -90px")
	var links = $(this).find("a");
	links.mouseover(function(){
		var index = links.index(this);
		//$(this).parent("li").parent("ul").parent("div.TabsTypeA").css("background-position",style[index]);
		$(this).parents(".TabsTypeA").css("background-position",style[index]);
	});
});
$("div.TabsTypeB ul li a:eq(0)").mouseover(function(){
	$(this).parent("li").parent("ul").parent("div.TabsTypeB").css("background-position","0px 0px");
	});
$("div.TabsTypeB ul li a:eq(1)").mouseover(function(){
	$(this).parent("li").parent("ul").parent("div.TabsTypeB").css("background-position","0px -30px");
	});

// 代購網站內容切換	
$("#Stores").find("a").attr("target","new");
$("#Stores .TabsTypeA ul li a").hover(function(){
    var i = $("#Stores .TabsTypeA ul li a").index(this);
	$("#Stores").find("div.inner").hide().eq(i).show();
	
	},function(){		
});

/*	國際時間	*/							
function GetTime() { 
var dt = new Date();
var def = dt.getTimezoneOffset()/60;
var gmt = (dt.getHours() + def);
var ending = ":" + IfZero(dt.getMinutes()) + ":" +  IfZero(dt.getSeconds());
//日本
var jp =check24(((gmt + 9) > 24) ? ((gmt + 9) - 24) : (gmt + 9));
var la =check24(((gmt - 7) < 24) ? ((gmt - 7) + 24) : (gmt -7));
var ny =check24(((gmt - 28) < 24) ? ((gmt - 28) + 24) : (gmt -28));
if($("#WorldTime").size() !=0) // 有國際時間版塊才去RUN這一支
{
	document.getElementById("timenowTk").innerHTML = (IfZero(jp) + ending);
	document.getElementById("timenowLa").innerHTML = (IfZero(la) + ending);
	document.getElementById("timenowNy").innerHTML = (IfZero(ny) + ending);
	document.getElementById("timenowKr").innerHTML = (IfZero(jp) + ending);
}
//setInterval("GetTime()", 1000);
setTimeout("GetTime()", 1000);
}
function IfZero(num) {
return ((num <= 9) ? ("0" + num) : num);
}
function check24(hour) {
return (hour >= 24) ? hour - 24 : hour;
}

function init(){
	GetTime();
}
window.onload = init;

$("#PromotePop, #PromoteHot").find("a").attr("target","new")/*.css("lineHeight","25px")*/;		/*	人氣商品, 海外限定 連結都開窗	*/

/*	↓eBay商品頁面,自動微調左側內容高度	*/
$(function(){
	var minH = $("#HdrImg").height();
	var minH2 = $("#HdrInfo").height();
	var finalHeight;
});

$(document).ready(function(){
	$("#mask").hide();
	$("#maskImg").hide();

	$("#HotKeys").css("width","180px").css("text-overflow","ellipsis");
//	$("#HotKeys a").css("float","left").css("padding","3px 8px 0px 0px");

//	$("#tbar").slideDown("slow");
//	$("a.close_me").click(function(){	$("#tbar").hide();		});
//	$("#tbar").delay(8000).hide('fast');


});		

$("#mask, #maskImg").bind("click", 
	function(){	$(this).hide();	
});

$(function(){
	$("#tbar").slideDown("slow");
	$("a.close_me").click(function(){	$("#tbar").hide();		});
	$("#tbar").delay(8000).hide('fast');
	
});


$(document).ready(function()	/*	表單,預設字串功能	*/
{
    $(".defaultText").focus(function(srcc)
    {
        if ($(this).val() == $(this)[0].title)
        {
            $(this).removeClass("defaultTextActive");
            $(this).val("");
        }
    });    
    $(".defaultText").blur(function()
    {
        if ($(this).val() == "")
        {
            $(this).addClass("defaultTextActive");
            $(this).val($(this)[0].title);
        }
    });    
    $(".defaultText").blur();

	/*	↓費用試算, 彈出小視窗	*/
	function trycal(url)
	{
		window.open(url,'_blank','width=750,status=no,titlebar=no,toolbar=no,resizable=yes,height=750','');
	}	
});

$(function(){	$('.st_box a').attr('target','_blank');	});



var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));

try {
var pageTracker = _gat._getTracker("UA-2882406-2");
pageTracker._trackPageview();
} catch(err) {}

