﻿var CurPicType = '';
var CurCookieName_pictype = 'pictype';
// index.aspx  专用JS
$(document).ready(function () {
    //获取cookie的值
    if ($.cookie(CurCookieName_pictype)) {
        CurPicType = $.cookie(CurCookieName_pictype);
        //alert("取到cookie "+CurPicType);
    }
    else {
        CurPicType = '1';
    }
    

  
});

function LoadingTimer() {
    
    $("#leftlogo").position({
        my: "left top",
        at: "left top",
        of: "#PicBasic",
        offset: "0 0",
        collision: "none none"//, "flip", "fit", "fit flip". 
    });
	
    $("#bottominfo").css( "opacity", 0.4 ).position({
        my: "left bottom",
        at: "left bottom",
        of: "#PicBasic",
        offset: "0 -30",
        collision: "none none"//, "flip", "fit", "fit flip". 
    });
	
    $("#bottominfo_wenzi").position({
        my: "left bottom",
        at: "left bottom",
        of: "#PicBasic",
        offset: "0 -30",
        collision: "none none"//, "flip", "fit", "fit flip". 
    });

    //alert("resized!");
}


function ChangePic() {
	//alert(getRootPath());
    //$("#leftlogo").attr('style',"background-image:url('images/jsq.png'); width:71px; height:57px;");
    $.ajax({
        type: "post",
        url: getRootPath() + "soisotemp/getPicJSON.php?flash=" + Math.random(),
        data: $.param({ ToCs_pictype: CurPicType }),
        dataType: 'json',
        cache: false,
        beforeSend: function () {
            $("#PicBasic").html("<img src='" + getRootPath() + "soiso/ResourceElements/ClockPhoto/644_417/loading644_417.gif'  width='644' height='417' />");
        }
    })
    .success(function (personinfo) {
        if (personinfo.state == "ok") {
            //显示个人基本信息
             $('#ufo_Name').html("<a href='space.php?uid="+personinfo.usernum+"' target='_blank'>"+personinfo.name+"</a>");
             $('#ufo_BirthDate').html(personinfo.birthdate);
             $('#ufo_RecSite').html(personinfo.recsite);
			 $('#visitspace').html("<a href='space.php?uid="+personinfo.usernum+"' target='_blank'><img src='images/visit.jpg' /></a>");
			 $('#addfriend').html("<a href='cp.php?ac=friend&op=add&uid="+personinfo.usernum+"' target='_blank'><img src='images/concern.jpg' /></a>");
            //$("#tcss").attr("value",personinfo.curSec);
            //$('#ufo_PsHeight').html(personinfo.PsHeight);
            //$('#ufo_Job').html(personinfo.Job);
            //$('#ufo_like').html(personinfo.like);
            //$('#ufo_MingXing').html(personinfo.MingXing);
            //$('#ufo_head1').attr("src", getRootPath() + "ResourceElements/UserHeader/" + personinfo.Head1 + "?" + Math.random());
            
        }
        else if (personinfo.state == "error") {
            //不做处理
            $('#ufo_Name').html('err');
            $('#ufo_RecSite').html('err');
        }
        else { 
            //不做处理
        }
        $("#PicBasic").html("<img src=\"" + getRootPath() + "soiso/ResourceElements/ClockPhoto/644_417/" + personinfo.clockphoto + "\"  width=\"644\" height=\"417\" />").hide().fadeIn(500, function () { });
    })
    .complete(function () {

    });
}
var constss = 60;
var curss = 60;
var first = true;

function InitClock (GO)
{
    curss = GO;
    $("#leftlogo").html(GO);

    ChangePic();
}
function RunningClock() {
    if (curss > 0 ) {
        if (curss != constss) {
            $("#leftlogo").html(curss);
        }
        else {
            if (first) {
                $("#leftlogo").html(constss);
                first = false;
            }
        }
        curss = curss - 1;
    }
    else {
        $("#leftlogo").html(constss);

        ChangePic();
        curss = constss-1;
    }
}


function ShowColorPics(sourceObj) {
    $('#' + sourceObj).mouseover(function () {
        if ($(this).css("opacity") != 1 && $(this).css("opacity") != 0) {
            $('#' + sourceObj).css("opacity", 0).stop(true);
        }
        $('#' + sourceObj).animate({ opacity: 1 }, { duration: 350 });

    }).mouseout(function () {
        if ($(this).css("opacity") != 0 && $(this).css("opacity") != 1) {
            $('#' + sourceObj).css("opacity", 1).stop(true);
        }
        $('#' + sourceObj).animate({ opacity: 0 }, { duration: 350 });
    })
}

function OC_cpic(p_clocktype) {
    //保存cookie
    $.cookie(CurCookieName_pictype, p_clocktype, { expires: 7000, path: '/' });
    //$.cookie(CurCookieName_pictype, p_clocktype);
    //alert("设置cookie " + p_clocktype);
    //更新全局变量
    CurPicType = p_clocktype;
    //调用更新幻灯片函数
    ChangePic();
}
