﻿$(function(){	
		   
    correctPNG();
	externallinks();
    $("#info p a:eq(0)").addClass("on");
	$("#info p a").click(function() {							 
       $("#info p a").removeClass("on");
	   $(this).addClass("on");
	});
	
	//菜单切换
	$("#left ul li a").hover(
	  function () {
		var n= $(this).parent().index();
		$("#left ul li a").removeClass("on");  
	    $(this).addClass("on");
		$("#company_logo span").hide();
		$("#company_logo span:eq("+n+")").fadeIn(0);
	  },function () {

	  }
	);
	
   //图片处理	
   showImg();
	
   function showImg(){
	  var obj=$("#right");
	  $.post("/ajax_img.asp", function(data){
		data = data.replace(/^\s+|\s+$/g,"");  
        obj.html(data);
		
		jQuery('#right ul').jcarousel({
		  auto: 1,
		  wrap: "last",
		  speed:0.5,
		  scroll: 1 /* 每次滚动的个数 */
		});
		
      });

   }
	
	//图片滚动
/*	var m=0,count=0;
	var html=$("#right ul").html();
	var total=$("#right ul li").size();
	$.extend({
	   show_img:function(){
		 var obj=$("#right ul li:eq("+m+")").clone();
		 $("#right ul li:last").after('<li>'+obj.html()+'<\/li>');
		 $("#right ul").animate({left:-84*(count++)}, 1000);
		 if(++m>=total){
			m=0;
			$("#right ul").html(html);
		 }
		 //if(++count) ;
	   }
	});
	var big_imgID=setInterval("$.show_img()",2000);
	

	
	$("#right ul").hover(
	  function () {
		clearInterval(big_imgID);
	  },function () {
		big_imgID=setInterval("$.show_img()",2000);
	  }
	);*/
	
	//Menu高亮处理
	var menu_num=0;
	var body_class=$('body').attr("class").substr(1);
	if(body_class!="") menu_num=body_class;
	if(menu_num==null) menu_num=0;
    $("#menu ul li:eq("+menu_num+")").addClass("on");
	
	//招贤纳士
	$('#header').append('<div id="job"><a href="job.asp">&nbsp;</a></div>');

});
	
//文字滚动
(function($){
	$.fn.extend({
	Scroll:function(opt,callback){
	if(!opt) var opt={};
	var _this=this.eq(0).find("ul:first");
	var lineH=_this.find("li:first").height(),
	line=opt.line?parseInt(opt.line,15):parseInt(this.height()/lineH,10),
	speed=opt.speed?parseInt(opt.speed,10):3000, //卷动速度，数值越大，速度越慢（毫秒）
	timer=opt.timer?parseInt(opt.timer,13):5000; //滚动的时间间隔（毫秒）
	if(line==0) line=1;
	var upHeight=0-line*lineH;
	scrollUp=function(){
	_this.animate({
	marginTop:upHeight
	},speed,function(){
	for(i=1;i<=line;i++){
	_this.find("li:first").appendTo(_this);
	}
	_this.css({marginTop:0});
	});
	}
	_this.hover(function(){
	clearInterval(timerID);
	},function(){
	timerID=setInterval("scrollUp()",timer);
	}).mouseout();
	}
	})
	})(jQuery);
	$(document).ready(function(){$("#bulletin").Scroll({line:1,speed:500,timer:1000});
});

//plugin
jQuery.fn.topLink = function(settings) {
	settings = jQuery.extend({
		min: 1,
		fadeSpeed: 200
	}, settings);
	return this.each(function() {
		//listen for scroll
		var el = $(this);
		el.hide(); //in case the user forgot
		$(window).scroll(function() {
			if($(window).scrollTop() >= settings.min){
				el.fadeIn(settings.fadeSpeed);
			}
			else{
				el.fadeOut(settings.fadeSpeed);
			}
		});
	});
};


function externallinks() {   
    if (!document.getElementsByTagName) return;   
    var anchors = document.getElementsByTagName("a");   
    for (var i=0; i<anchors.length; i++){   
       var anchor = anchors[i];   
       if (anchor.getAttribute("href") && anchor.getAttribute("rel")=="external") anchor.target="_blank";
    }   
}   
window.onload = externallinks;

function addcom(){
	var idmax=3;
	if(document.getElementById("anonymous").checked == true){
        document.getElementById("id1").style.display='none';
		document.getElementById("id2").style.display='none';
        document.getElementById("id3").style.display='';
	}else{
        document.getElementById("id1").style.display='';
		document.getElementById("id2").style.display='';
        document.getElementById("id3").style.display='none';
	}
}

function SetFont(size){
	$("#txt").css({ "fontSize": size });
}

function bookmark(){
	var title=document.title;
	var url=document.location.href;
	if (window.sidebar) window.sidebar.addPanel(title, url, "");
	else if( window.opera && window.print ){
	  var mbm = document.createElement('a');
	  mbm.setAttribute('rel','sidebar');
	  mbm.setAttribute('href',url);
	  mbm.setAttribute('title',title);
	  mbm.click();
	}else if(document.all) window.external.AddFavorite( url, title);
}

function copyToClipBoard(){ 
    var txt=""; 
    txt+=document.title; 
    txt+=""; 
    txt+=this.location.href;
    if (window.clipboardData) {   
        window.clipboardData.clearData();   
        window.clipboardData.setData("Text", txt);   
    } else if (navigator.userAgent.indexOf("Opera") != -1) {   
        window.location = txt;   
    } else if (window.netscape) {   
        try {   
            netscape.security.PrivilegeManager   
                    .enablePrivilege("UniversalXPConnect");   
        } catch (e) {   
            alert("你使用的FireFox浏览器,复制功能被浏览器");   
            return;   
        }   
        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 = txt;   
        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);   
    }  
    alert("复制成功，请粘贴到你的QQ/MSN上推荐给你的好友"); 
} 

jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') {
   options = options || {};
   if (value === null) {
    value = '';
    options = $.extend({}, options);
    options.expires = -1;
   }
   var expires = '';
   if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
    var date;
    if (typeof options.expires == 'number') {
     date = new Date();
     date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
    } else {
     date = options.expires;
    }
    expires = '; expires=' + date.toUTCString();
   }
   var path = options.path ? '; path=' + (options.path) : '';
   var domain = options.domain ? '; domain=' + (options.domain) : '';
   var secure = options.secure ? '; secure' : '';
   document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else {
   var cookieValue = null;
   if (document.cookie && document.cookie != '') {
    var cookies = document.cookie.split(';');
    for (var i = 0; i < cookies.length; i++) {
     var cookie = jQuery.trim(cookies[i]);
     if (cookie.substring(0, name.length + 1) == (name + '=')) {
      cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
      break;
     }
    }
   }
   return cookieValue;
}
};

function correctPNG() // correctly handle PNG transparency in Win IE 5.5 & 6. 
{ 
    var arVersion = navigator.appVersion.split("MSIE") 
    var version = parseFloat(arVersion[1]) 
    if ((version >= 5.5) && (document.body.filters)) 
    { 
       for(var j=0; j<document.images.length; j++) 
       { 
          var img = document.images[j] 
          var imgName = img.src.toUpperCase() 
          if (imgName.substring(imgName.length-3, imgName.length) == "PNG") 
          { 
             var imgID = (img.id) ? "id='" + img.id + "' " : "" 
             var imgClass = (img.className) ? "class='" + img.className + "' " : "" 
             var imgTitle = (img.title) ? "title='" + img.title + "' " : "title='" + img.alt + "' " 
             var imgStyle = "display:inline-block;" + img.style.cssText 
             if (img.align == "left") imgStyle = "float:left;" + imgStyle 
             if (img.align == "right") imgStyle = "float:right;" + imgStyle 
             if (img.parentElement.href) imgStyle = "cursor:hand;" + imgStyle 
             var strNewHTML = "<ins " + imgID + imgClass + imgTitle 
             + " style=\"" + "width:" + img.width + "px; height:" + img.height + "px;" + imgStyle + ";" 
             + "filter:progid:DXImageTransform.Microsoft.AlphaImageLoader" 
             + "(src=\'" + img.src + "\');\"></ins>" 
             img.outerHTML = strNewHTML 
             j = j-1 
          } 
       } 
    }     
} 
//window.attachEvent("onload", correctPNG);


//google统计
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-27253741-1']);
_gaq.push(['_trackPageview']);

(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();


