/*
 * PoP Public V1.0.
 * By yangzihui
 * Copyright (c) 2009
 * MSN & Mail: cx-game@hotmail.com
*/


// jquery.tooltips  读title
  this.tooltip = function(){
    /* CONFIG */
        xOffset = -22;
        yOffset = -10;
        // these 2 variable determine popup's distance from the cursor
        // you might want to adjust to get the right result
    /* END CONFIG */
    $("a.tooltip,#right .menu2 dd a,#right .right-menu dd a,.page a").hover(function(e){
        this.t = this.title;
        this.title = "";
        $("body").append("<p id='tooltip'>"+ this.t +"</p>");
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px")
            .fadeIn("fast");
    },
    function(){
        this.title = this.t;
        $("#tooltip").remove();
    });
    $("a.tooltip,#right .menu2 dd a,#right .right-menu dd a,.page a").mousemove(function(e){
        $("#tooltip")
            .css("top",(e.pageY - xOffset) + "px")
            .css("left",(e.pageX + yOffset) + "px");
    });
};

$(document).ready(function(){
    tooltip();
});



// 字符截断...
jQuery.fn.limit=function(number){
    var self=$(this);
    self.each(function(){
        var objString = $(this).text();
        var objLength = $(this).text().length;
        var num = number;
        if(objLength > num){
        $(this).attr("title",objString);
            objString = $(this).text(objString.substring(0,num) + "...");
        }
    })
}
$(function(){
    $(".index-news a").limit(31);
	$(".index-img span").limit(17);
	$(".index-news1 a").limit(37);
    $(".index-news2 a").limit(31)
	$(".index-list a").limit(17);
	$(".index-img4 span").limit(20);
	$(".t4 dd a").limit(20);
	$("#highlight .word h3").limit(17);
	$("#highlight .word p").limit(17);
	$(".label div a").limit(8);
    $(".index-news li a").limit(28);
})


// 去连接虚线
$(document).ready(function(){
    $(".page a,.choice a").bind("focus",function(){
        if(this.blur){ //如果支持 this.blur
            this.blur();
         }
    });
});


// 鼠标掠过
$(document).ready(function(){  //这个就是传说的ready
        $("#index-list dl,#index-job .job li,.main dl,.main2 dl,.list,.bigView li,.bigView-list li,.main-zazhi li,.sszz-list,.down_list li,.report-list").mouseover(function(){ //如果鼠标移到class为stripe的表格的tr上时，执行函数
        $(this).addClass("over");}).mouseout(function(){//给这行添加class值为over，并且当鼠标一出该行时执行函数
        $(this).removeClass("over");})  //移除该行的class
});


// 隔行鼠标掠过
$(document).ready(function(){
			$(".data-list tr").mouseover(function(){
			$(this).addClass("over");}).mouseout(function(){
			$(this).removeClass("over");})
			$(".data-list tr:even").addClass("alt");
});


//jQuery Scroll News--single
function AutoScroll(obj){
        $(obj).find("ul:first").animate({
                marginTop:"-45px"
        },500,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}
$(document).ready(function(){
setInterval('AutoScroll("#scrollDiv")',4000)
});
function AutoScroll(obj){
        $(obj).find("ul:first").animate({
                marginTop:"-27px"
        },500,function(){
                $(this).css({marginTop:"0px"}).find("li:first").appendTo(this);
        });
}
$(document).ready(function(){
setInterval('AutoScroll("#index-scroll")',4000)
});


// refresh_check_code
function refresh_check_code(){
	window.document.getElementById("checkimg").src="./inc/checkimg.php?refresh=1&temp="+ (new Date().getTime().toString(36));
}

function form_check(){
	if(document.loginForm.account.value==""){
		alert("请输入用户名");
		return false;
	}else if(document.loginForm.passwd.value==""){
		alert("请输入密码");
		return false;
	}else if(document.loginForm.check_code.value==""){
		alert("请输入验证码");
		return false;
	}
	return true;
}

function   GetCookieVal(offset)
//获得Cookie解码后的值
{
    //alert(offset);
    var endstr = document.cookie.indexOf (";",offset);
    if (endstr == -1)
    endstr = document.cookie.length;
    return unescape(document.cookie.substring(offset,endstr));
}

function   SetCookie(name, value) {
    var   today = new Date();
    var   expires = new Date();
    expires.setTime(today.getTime() + 1000*60*60*24*365);
    document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString();
}

function   DelCookie(name)
//删除Cookie
{
    var exp = new Date();
    exp.setTime (exp.getTime() - 1);
    var cval = GetCookie (name);
    document.cookie = name + "=" + cval + ";expires="+exp.toGMTString()+";path=/";
}

function   GetCookie(name)
//获得Cookie的原始值
{
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j = i + alen;
        if (document.cookie.substring(i, j) == arg)
        return GetCookieVal(j);
        i = document.cookie.indexOf(" ", i) + 1;
        if (i == 0) break;
    }
    return null;
}


function submitForm(){
    if(document.loginForm.checkbox1.checked){
		//alert(44);
        SetCookie("password",document.loginForm.passwd.value);
        SetCookie("username",document.loginForm.account.value);
    }else{
    }
}
function   GetUserNameCookie()
//获得Cookie的用户名原始值
{
    var name="username";
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
	//var kk = document.cookie;
	//alert(kk);
    while (i < clen)
    {

        var j = document.cookie.indexOf(name)+alen;
        if(document.cookie.indexOf(name) > 0){
            document.loginForm.account.value=GetCookieVal(j);
        }
        if   (document.cookie.substring(i,j) == arg)
        {
			//alert('33');
            //document.loginForm.account.value=1234;
			document.loginForm.account.value=GetCookieVal(j);
            document.loginForm.account.focus();
            return GetCookieVal   (j);
        }
        i = document.cookie.indexOf("",i) + 1;
        if   (i == 0) break;
    }
    return   null;
}

function   GetPassWordCookie()
//获得Cookie的密码原始值
{

    var name="password";
    var arg = name + "=";
    var alen = arg.length;
    var clen = document.cookie.length;
    var i = 0;
    while (i < clen)
    {
        var j =  document.cookie.indexOf(name)+alen;
        if(document.cookie.indexOf(name) > 0){
            document.loginForm.passwd.value=GetCookieVal(j);
        }
        if   (document.cookie.substring(i,j) == arg)
        {
            document.loginForm.passwd.value=GetCookieVal(j);
            document.loginForm.passwd.focus();
            return GetCookieVal(j);
        }
        i = document.cookie.indexOf("",i) + 1;
        if (i == 0) break;
    }
    return null;
}

//ajax_login_info
function ajax_login_info(backurl){
	$.ajax({
		type:"GET",
		url:"ajax_login_info.php",
		data:"backurl="+backurl,
		cache:false,
		async: false,
		success:function(msg){
			login_callback(msg);
		}
	});
}
function login_callback(msg){
    document.getElementById('ajax_login').innerHTML = msg;
}
