﻿function login() 
{
            var userName = document.getElementById("ctl00_txtUserName");
            var password = document.getElementById("ctl00_txtPassWord");
            if (userName.value == "") {
                alert("输入用户名吧... -_-");
                userName.focus();
                return false;
            }
            if (password.value == "") {
                alert("输入密码吧... -_-");
                password.focus();
                return false;
            }
}

String.prototype.Trim = function()    {    return this.replace(/(^\s*)|(\s*$)/g, "");    }  

function comment(){
    
    var name=document.getElementById("ctl00_cphContent_txtComment");
    var mail=document.getElementById("ctl00_cphContent_txtMail");
    var content=document.getElementById("ctl00_cphContent_txtContent");
       if (name.value == "") {
                alert("请输入您的昵称吧... -_-");
                name.focus();
                return false;
        }
        if (mail.value == "") {
            alert("请输入您的邮箱吧... -_-");
            mail.focus();
            return false;
        }   if (content.value == "") {
            alert("请输入您要评论的内容吧... -_-");
            content.focus();
            return false;
        }
       if(content.value.Trim().length<5){
        alert("请认真评论.内容不得少于5个字符.谢谢... -_-");
            content.focus();
            return false;
        }
}

function search() {
    var type = document.getElementById("selecttype").value;
    var keyword = document.getElementById("keyword");
    if (keyword.value == "") {
        alert("关键字都不输入,怎么搜索呀?  -_-");
        keyword.focus();
        return false;
    }
    if (type == "title") {
        location.href = "Search.aspx?type=title&key=" + encodeURI(keyword.value);
    } if (type == "content") {
        location.href = "Search.aspx?type=content&key=" + encodeURI(keyword.value);
    }

}


function copy_code(text) {
  if (window.clipboardData) {
    window.clipboardData.setData("Text", text)
	alert("已经成功复制到剪贴板！");
  } else {
	var x=prompt('你的浏览器可能不能正常复制\n请你手动进行：',text);
  }
  //return false;
}





function shareto(id){

	if (typeof(shareto_img)=='undefined'){
		var pic="";
	}else{
		var pic=shareto_img;
	}


	var url=encodeURIComponent(document.location.href);
	var title=encodeURIComponent(document.title);
	if(id=="fav"){
		addBookmark(document.title);
		return;
	}else if(id=="qzone"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'QZone', 1]);
		window.open('http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url='+url);
		return;
	}else if(id=="twitter"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'Twitter', 1]);
		window.open('http://twitter.com/home?status='+title+encodeURIComponent(' ')+url,'_blank');
		return;
	}else if(id=="sina"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'SinaT', 1]);
		//window.open('http://v.t.sina.com.cn/share/share.php?title='+title+'&url='+url+'&source=bookmark','_blank');
		//window.open("http://v.t.sina.com.cn/share/share.php?url="+url+"&appkey=610475664&title="+title+"&pic="+pic,"_blank","width=615,height=505");
		window.open("http://service.weibo.com/share/share.php?url="+url+"&appkey=923264048&title="+title+"&pic="+pic+"&ralateUid=1785405365","_blank","width=615,height=505");
		return;
	}else if(id=="qqshuqian"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'QQShuqian', 1]);
		window.open('http://shuqian.qq.com/post?from=3&jumpback=2&noui=1&uri='+url+'&title='+title,'_blank','width=930,height=570,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');
		return;
	}else if(id=="baidu"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'Baidu', 1]);
		window.open('http://cang.baidu.com/do/add?it='+title+'&iu='+url+'&fr=ien#nw=1','_blank','scrollbars=no,width=600,height=450,left=75,top=20,status=no,resizable=yes');
		return;
	}else if(id=="googlebuzz"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'GoogleBuzz', 1]);
		window.open('http://www.google.com/buzz/post?url='+url+'&imageurl='+pic,'_blank');
		return;
	}else if(id=="douban"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'Douban', 1]);
		var d=document,e=encodeURIComponent,s1=window.getSelection,s2=d.getSelection,s3=d.selection,s=s1?s1():s2?s2():s3?s3.createRange().text:'',r='http://www.douban.com/recommend/?url='+e(d.location.href)+'&title='+e(d.title)+'&sel='+e(s)+'&v=1',x=function(){if(!window.open(r,'douban','toolbar=0,resizable=1,scrollbars=yes,status=1,width=450,height=330'))location.href=r+'&r=1'};
		if(/Firefox/.test(navigator.userAgent)){setTimeout(x,0)}else{x()}
		return;
	}else if(id=="renren"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'RenRen', 1]);
		window.open('http://www.connect.renren.com/share/sharer?url='+url+'&title='+title,'_blank','resizable=no');
		return;
	}else if(id=="xianguo"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'XianGuo', 1]);
		window.open('http://xianguo.com/service/submitdigg/?link='+url+'&title='+title,'_blank');
		return;
	}else if(id=="digu"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'Digu', 1]);
		window.open('http://www.diguff.com/diguShare/bookMark_FF.jsp?title='+title+'&url='+url,'_blank','width=580,height=310');
		return;
	}else if(id=="mail"){
		_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'Mail', 1]);
		window.open('mailto:?subject='+title+'&body='+encodeURIComponent('这是我看到了一篇很不错的文章，分享给你看看！\r\n\r\n')+title+encodeURIComponent('\r\n')+url);
		return;
	}else if(id=="tqq"){
	
	
	var _t = encodeURI(document.title);
		var _url = encodeURIComponent(document.location);
		var _assname = encodeURI("aaipan8");
		var _appkey = encodeURI("1c255390b2d2416aa8a1e9f61593d998");//你从腾讯获得的appkey
		var _pic = encodeURI('');//（例如：var _pic='图片url1|图片url2|图片url3....）
		var _site = 'http://www.chenpan.name';//你的网站地址
		var _u = 'http://v.t.qq.com/share/share.php?url='+_url+'&appkey='+_appkey+'&site='+_site+'&pic='+_pic+'&title='+_t+'&assname='+_assname;
		
		window.open( _u,'', 'width=700, height=680, top=0, left=0, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no' );
		
		//_gaq.push(['_trackEvent', 'SocialShare', 'Share', 'TQQ', 1]);
		//var tqq_appkey = encodeURI("1c255390b2d2416aa8a1e9f61593d998");
		//var _assname = encodeURI("aaipan8");
		//window.open('http://v.t.qq.com/share/share.php?appkey='+tqq_appkey+'&title='+title+'&assname='+_assname+'&site=http://www.chenpan.name&url='+url+encodeURI(" (来自 @aaipan8)"));
		return;
	}
}

function ShareButtons(){
	document.write('<div class="social_share">');
	document.write('<a class="sharebutton" id="share_qzone" href="javascript:shareto(\'qzone\');" title="分享到QQ空间"></a>');
	document.write('<a class="sharebutton" id="share_tqq" href="javascript:shareto(\'tqq\');" title="分享到 QQ 腾讯微博"></a>');
	document.write('<a class="sharebutton" id="share_sina" href="javascript:shareto(\'sina\');" title="分享到新浪微博"></a>');
	document.write('<a class="sharebutton" id="share_qqshuqian" href="javascript:shareto(\'qqshuqian\');" title="收藏到QQ书签"></a>');
	document.write('<a class="sharebutton" id="share_twitter" href="javascript:shareto(\'twitter\');" title="分享到Twitter"></a>');
	document.write('<a class="sharebutton" id="share_renren" href="javascript:shareto(\'renren\');" title="分享到人人网"></a>');
	document.write('<a class="sharebutton" id="share_baidu" href="javascript:shareto(\'baidu\');" title="收藏到 - 百度搜藏"></a>');
	document.write('<a class="sharebutton" id="share_googlebuzz" href="javascript:shareto(\'googlebuzz\');" title="分享到 Google Buzz"></a>');
	document.write('<a class="sharebutton" id="share_douban" href="javascript:shareto(\'douban\');" title="分享到豆瓣"></a>');
	//document.write('<a class="sharebutton" id="share_xianguo" href="javascript:shareto(\'xianguo\');" title="分享到鲜果网"></a>');
	document.write('<a class="sharebutton" id="share_digu" href="javascript:shareto(\'digu\');" title="分享到嘀咕"></a>');
	document.write('<a class="sharebutton" id="share_mail" href="javascript:shareto(\'mail\');" title="发送邮件分享给朋友"></a>');
	document.write('</div>');
}
