init();$(function(){$(".allunfold span").toggle(function(){$(this).toggleClass('close').text('全部收起');$('.content:hidden').parent().find(".title1 a").attr("title","收起");$('.content:hidden').show();$('.content').parent().find(".title1").addClass('title2');},function(){$(this).toggleClass('close').text('全部展开');$('.content:visible').parent().find(".title1 a").attr("title","展开");$('.content:visible').hide();$('.content').parent().find(".title1").removeClass('title2');});$('input[value=开始查看]').click(function(){var p='',month=$('#hright select[name=m]').val(),day=$('#hright select[name=d]').val();month=parseInt(month)<10?'0'+month:month;day=parseInt(day)<10?'0'+day:day;p=month+day;location.href='http://'+location.host+location.pathname+'?'+p;});$('input[value="复制本页链接 发给你的好友"]').click(function(){CopyToClipboard(location.href);$(this).after('<p style=\'color:red;text-align:center;\'>复制成功！现在就发给你QQ、MSN上的好友吧！</p>');var t=this;setTimeout(function(){$(t).siblings('p').hide();},3000);});});function init(){var hash=location.search.substr(1);if(!hash){var d=new Date();var m=d.getMonth()+1,day=d.getDate();var u=m<10?"0"+m.toString():m.toString();u+=day<10?"0"+day.toString():day.toString();hash=u;}
document.title=hash.substr(0,2)+'月'+hash.substr(2,2)+'日 历史上发生的事件'+document.title;$('#htitle span.red').text(hash.substr(0,2)+'月'+hash.substr(2,4)+'日 ');var id=new Date(),iy=id.getFullYear(),im=(!!hash)?parseInt(hash.substr(0,2),10):id.getMonth()+1;var currDays=new Date(iy,im,0).getDate();var m='',d='';for(var i=1;i<=12;i++){m+='<option value='+i+((parseInt(hash.substr(0,2),10)==i)?' selected=true':'')+'>'+i+'月</option>';}
if(im!=2){for(var i=1;i<=currDays;i++){d+='<option value='+i+((parseInt(hash.substr(2,2),10)==i)?' selected=true':'')+'>'+i+'日</option>';}}else{for(var i=1;i<=29;i++){d+='<option value='+i+((parseInt(hash.substr(2,2),10)==i)?' selected=true':'')+'>'+i+'日</option>';}}
$('#hright select[name=m]').html(m).change(function(){var newDay=new Date(iy,$(this).val(),0).getDate();var t='';if($(this).val()!='2'){for(var i=1;i<=newDay;i++){t+='<option value='+i+'>'+i+'日</option>';}}else{for(var i=1;i<=29;i++){t+='<option value='+i+'>'+i+'日</option>';}}
$('#hright select[name=d]').html(t);});$('#hright select[name=d]').html(d);if(hash){var url='./grab/history/'+hash+'_c.js';$.get(url,function(d){if(d){eval(d);var t=$(contents),currIndex=1;if(location.hash&&location.hash!="#"){currIndex=parseInt(location.hash.substr(1));}
t.each(function(index){insertItem(this,index+1,currIndex)});if(currIndex>1){var h=$("a[name="+currIndex+"]").offset().top;if(!$.browser.msie)h-=15;scroll(0,h);}}});}
function insertItem(item,i,currIndex){var y=item[0].substr(0,item[0].length-4)+'.'+item[0].substr(item[0].length-4,2)+'.'+item[0].substr(item[0].length-2,2);var s='<li>'
+'<div class="'+(i==currIndex?'title1 title2':'title1')+'"><a onclick="itemClick(this)" name="'+i+'" title="'+(i==currIndex?'收起':'展开')+'">'+i+') '+y+':'+item[1]+'</a></div>'
+(i==currIndex?'<div class=content style="display:block;">':'<div class=content style="display:none;">')
+((item[2].length)?'<table style="width:'+item[2][2]+'px"><tr><td><img src="./grab/history/'+item[2][0]+'" alt="'+item[5]+'" title="'+item[5]+'"></td></tr><tr><td><span>'+item[5]+'</span></td></tr></table>':'')
+makeContent(item[4])
+'  <p class="gjc">关键词：<span class=red style="font-weight:normal;font-size:12px;">'+makeKeywords(item[3])+'</span></p>'
+'</div>'
+'</li>';$('#hleft').append(s);}
function makeContent(s){var t=s.split('##'),re='';if(t.length){re='<p>';for(var i=0;i<t.length;i++){re+=t[i];re+=i%2==0?'</p><p>':'</p>';}}
return re.replace(/#/g,'<br/>');}
function makeKeywords(s){var t=s.split('&nbsp;'),re='';if(t.length){for(var i=0;i<t.length;i++){re+='<a href="http://s.1616.net/?kw='+encodeURIComponent(t[i])+'" target=_blank>'+t[i]+'</a> ';}}
return re;}}
function itemClick(obj){var title=$(obj).attr("title")=="收起"?"展开":"收起";$(obj).attr("title",title);$(obj).parent().toggleClass('title2').siblings('div').toggle();}
function search(ev){var e=ev||window.event;if(e){var key=window.event?e.keyCode:e.which;if(key==13)do_s()}}
function do_s(){var v=$.trim($("#keyword").val());if(v)
window.open("http://s.1616.net/?kw="+encodeURIComponent(v));}
function CopyToClipboard(meintext){try{if(window.clipboardData){window.clipboardData.setData("Text",meintext);}
else if(window.netscape){netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');var clip=Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);if(!clip)return;var trans=Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);if(!trans)return;trans.addDataFlavor('text/unicode');var str=new Object();var len=new Object();var str=Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);var copytext=meintext;str.data=copytext;trans.setTransferData("text/unicode",str,copytext.length*2);var clipid=Components.interfaces.nsIClipboard;if(!clip)return false;clip.setData(trans,null,clipid.kGlobalClipboard);}
else{return false;}}catch(e){return false;}
return false;}
(function(){var _location=window.location.href;var regex=/([^.]+)\.(?:com|net)\/?.*$/i;var homePath='http://history.1616.net/';if(regex.test(_location)&&(RegExp.$1.indexOf('1616')==-1)){var _path=RegExp.$1,homePath='http://www.'+_path+'.com';document.title=document.title.replace('1616',_path);$('#logo').html('<a href="http://www.'+_path+'.com/"><img alt="返回首页" src="http://www.'+_path+'.com/img/logo.gif" /></a>');$('#adviceHref').hide();$('#homeHref, #pathl>a').attr('href','http://www.'+_path+'.com');if(!document.all){$('#pathr > a:first').hide();}}
$('#logo').show();$('#pathr > a:eq(0)').click(function(){J1616.Util.setHome(this,homePath)});})();
