// JavaScript Document
$(function (){	
	var week; 
	if(new Date().getDay()==0)          week="星期日"
	if(new Date().getDay()==1)          week="星期一"
	if(new Date().getDay()==2)          week="星期二" 
	if(new Date().getDay()==3)          week="星期三"
	if(new Date().getDay()==4)          week="星期四"
	if(new Date().getDay()==5)          week="星期五"
	if(new Date().getDay()==6)          week="星期六"		
	var year = new Date().getFullYear()+"年" ;
	var month = (new Date().getMonth()+1)+"月" ;
	var date = new Date().getDate()+"日 " ;
	var timehtml=year+month+date+week;
	$('#time').html(timehtml);
	$(".top_navi:last").hide();
	$(".top_navi:first").children("ul").remove();
	$(".top_navi:eq(8)").css("background","none");
	$(".top_navi:eq(8) a").each(function(){
		$(this).attr("href","/html/scene/index.html");
		})
	$(".top_navi").hover(function(){
				$(this).children("ul:animated").stop(false,true);
				$(this).children("a").addClass("thisclass");
				$(this).children("ul").slideDown();},
			function(){
				$(this).children("ul:animated").stop(false,true); 
				$(this).children("a").removeClass("thisclass");
				$(this).children("ul").slideUp();
			})
	var thisname=$(".left h1:first").text();
	if(thisname=='创新论坛'){
		$(".subnav ul li").each(function(){
		$(this).children("a").attr("href","/html/scene/index.html");
		})
		}		
	$("#gotop").click(function(){
		$('html,body').animate({scrollTop:0},1000);
		$(this).hide();
		});
	$(window).scroll(function(){
		var offset=$(window).scrollTop();
		if(offset>50){$("#gotop").show();}
		else{$("#gotop").hide();}
		});

	$(".newslist .news,.ca_menu li").each(function(){
		var thislink=$(this).children("a").attr("href");
		var ifpdf=thislink.split(".")[1];
		if(ifpdf=='pdf'){
			$(this).children("a").after('<img src=/Templets/images/pdftag.jpg>');
			$(this).children("a").attr("target","_blank")
			}
		})

	$(".catelist > li").each(function(){
		var morelink=$(this).children("a").attr('href');
		var morepic='<a class=morelink href='+morelink+'><img src="/Templets/images/morelink.jpg" /></a>'
		$(this).children("a").append(morepic);
	});
	var imglength=$(".imglist .img").size();
	if((imglength%4)==0){
		for(i=0;i<imglength;i++){
			$(".imglist .img").eq(i).css("border-bottom","1px dashed #ccc")
			} 
		}	
	//checkLogesd()
	var thisname=$("#thisname").text();
	if(thisname=='友情链接'){
		$(".linklist:first").show();
		}
	if(thisname=='分子公司'){
		$(".linklist:last").show();
		}		
});

function checkLogesd(){ 	
	var login="<form  action='/bbs/login.aspx?referer=forumindex.aspx' id='lsform' autocomplete='off' method='post'><div class='login_name'><img src='/Templets/images/login1.png'><input type='text' tabindex='901'  id='ls_username' name='username' class='txt'  /></div><div class='login_name'><img src='/Templets/images/login2.png'><input type='password'  tabindex='902' autocomplete='off' id='ls_password' name='password'  class='txt'  /></div><div class='login_button'><input type='submit' name='but_LoginSubmit' value='登录' ><input type='reset' name='Loginreset' value='重置'></div><div class='login_other'><a target='_blank' href='/bbs/getpassword.aspx'>忘记密码 ？</a><a target='_blank' href='/bbs/register.aspx'>立即注册 ！</a></div></form>"
	var logined="<div class='user_c'>欢迎您登陆！</div><div class='user_c'><a href='/bbs/usercp.aspx' target='_blank'>用户中心</a></div><div class='user_c'><a href='/bbs/index.aspx' target='_blank'>论坛</a></div><div class='user_c'><a href='/bbs/logout.aspx' target='_blank'>退出</a></div>"
    var cookieString = new String(document.cookie);
    var cookieHeader = "dnt="
    var beginPosition = cookieString.indexOf(cookieHeader); 
    if (beginPosition != -1){
		beginPosition += cookieHeader.length;
		end = cookieString.indexOf(";", beginPosition);
		if(end == -1){end = cookieString.length;}
		var dnt= unescape(cookieString.substring(beginPosition, end));
		var newdnt=dnt.split('&');
		var password=newdnt[1].substr(9);
		var userkey=password.toString().substring(4,8);
		$("#login").html(logined);return true;}
    else{$("#login").html(login);return false;};
		  
}
function tabox(name,namex){
	$(name).click(
		function(){
			$(namex).hide();
			$(this).addClass("thisclass");
			$(this).siblings().removeClass("thisclass");
			indexthis=$(name).index(this);
			$(namex).eq(indexthis).fadeIn();
			});			
	$(namex).hide();
	$(name).eq(0).addClass("thisclass");
	$(namex).eq(0).show();
};

function addCookie(){　 // 加入收藏夹   
    if (document.all){   
        window.external.addFavorite('http://8.demo2.cn/', '中国技术创业孵化联盟');   
    }else if (window.sidebar){   
       window.sidebar.addPanel('中国技术创业孵化联盟', 'http://8.demo2.cn/', "");   
    }   
} 

function setHomepage(){　 // 设置首页   
    if (document.all){   
       document.body.style.behavior = 'url(#default#homepage)';   
        document.body.setHomePage('http://8.demo2.cn/');   
   }else if (window.sidebar){   
        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', 'http://8.demo2.cn/');   
    }   
}
	


