﻿var tips; var theTop; /*这是默认高度,越大越往下*/var old;
var pos;
function initFloatTips(top,obj)
{
    theTop = top;
    old = theTop;
    function getAbsoluteLeft(obj)
    { var s_el = 0; el = obj; while (el) { s_el = s_el + el.offsetLeft; el = el.offsetParent; }; return s_el }
            
    pos = document.getElementById('head');
    tips = document.getElementById(obj);
    tips.style.position = 'absolute';
    //tips.style.left = getAbsoluteLeft(pos) + 1024 - 400 + "px";
    tips.style.width = '79px';
    if (window.screen.width > 1024)
    {
        tips.style.left = getAbsoluteLeft(pos) + 894 + "px";
    }
    else
    {
        tips.style.right = 0 + "px";
    }
    tips.style.top = 2670 + 'px';
    moveTips();
    
};

var flag = 0;
function moveTips()
{
    function getAbsoluteLeft(obj)
    { var s_el = 0; el = obj; while (el) { s_el = s_el + el.offsetLeft; el = el.offsetParent; }; return s_el }
    if (flag == 1)
    {
        if (window.screen.width > 1024)
        {
            tips.style.left = getAbsoluteLeft(document.getElementById('head')) + 904 - 400 + 90  + "px";
        }
        else
        {
            tips.style.right = 0  + "px";
        }
        tips.style.width = '380px';  
        tips.style.top = 267 + 'px'; flag = 0;return;
    }
    var tt = 50;

    if (window.innerHeight)
    {

        pos = window.pageYOffset

    }

    else if (document.documentElement && document.documentElement.scrollTop)
    {

        pos = document.documentElement.scrollTop

    }

    else if (document.body)
    {

        pos = document.body.scrollTop;

    }

    pos = pos - tips.offsetTop + theTop;

    pos = tips.offsetTop + pos / 10;

    if (pos < theTop) pos = theTop;

    if (pos != old)
    {

        tips.style.top = pos + "px";

        tt = 10;

    }

    old = pos;

    setTimeout(moveTips, tt);

}

function closeDiv(obj)
{
    document.getElementById(obj).style.display = 'none';
}
function showDivInCenter()
{
    alert(document.body);
}

//灰色层

function G(id)
{
    return document.getElementById(id);
};
function GC(t)
{
    return document.createElement(t);
};
String.prototype.trim = function()
{
    return this.replace(/(^\s*)|(\s*$)/g, '');
};
function isIE()
{
    return (document.all && window.ActiveXObject && !window.opera) ? true : false;
}



function popCoverDiv()
{
    if (G("cover_div"))
    {
        G("cover_div").style.display = '';
    } else
    {
        var coverDiv = GC('div');
        coverDiv.innerHTML = "<iframe width=100% height=100%></iframe>";
        document.body.appendChild(coverDiv);
        coverDiv.id = 'cover_div';
        with (coverDiv.style)
        {
            position = 'absolute';
            background = '#CCCCCC';
            left = '0px';
            top = '0px';
            var bodySize = getBodySize();
            width = bodySize[0] + 'px'
            height = bodySize[1] + 'px';
            zIndex = 98;
            if (isIE())
            {
                filter = "Alpha(Opacity=60)";
            } else
            {
                opacity = 0.6;
            }
        }
    }
}
function getBodySize()
{
    var bodySize = [];
    with (document.documentElement)
    {
        bodySize[0] = (scrollWidth > clientWidth) ? scrollWidth : clientWidth;
        bodySize[1] = (scrollHeight > clientHeight) ? scrollHeight : clientHeight;
    }
    return bodySize;
}


function getScroll()
{
    var t, l, w, h;

    if (document.documentElement && document.documentElement.scrollTop)
    {
        t = document.documentElement.scrollTop;
        l = document.documentElement.scrollLeft;
        w = document.documentElement.scrollWidth;
        h = document.documentElement.scrollHeight;
    } else if (document.body)
    {
        t = document.body.scrollTop;
        l = document.body.scrollLeft;
        w = document.body.scrollWidth;
        h = document.body.scrollHeight;
    }
    return { t: t, l: l, w: w, h: h };
}

function showAdd()
{
    function getAbsoluteTop(obj) {
    var s_el=0;el=obj;
    while(el){s_el=s_el+el.offsetTop ;el=el.offsetParent;};
    return s_el
    }
    function getAbsoluteLeft(obj)
    {var s_el=0;el=obj;while(el){s_el=s_el+el.offsetLeft;el=el.offsetParent;}; return s_el}
    var add = G('addDiv');
    add.style.left = getAbsoluteLeft(G('investWill')) - 90 + 'px';
    add.style.top = getAbsoluteTop(G('investWill')) + 'px';
    add.style.display = 'block';
}
function showForm()
{
    popCoverDiv();
    var bodySize = getBodySize();
    width = bodySize[0];
    height = bodySize[1];
    var srcollSize = getScroll();
    G('formDiv').style.position = 'absolute';
    G('formDiv').style.left = (width - 677) / 2 + 'px';
    G('formDiv').style.top = (srcollSize.t + 200) + 'px';
    G('formDiv').style.display = 'block';
}

function checkWillForm()
{
    if (G('txtName').value == '')
    {
        G('emptyName').innerHTML = '姓名不能为空';
        G('txtName').focus();
        return false;
    }
    if (G('txtContact').value == '')
    {
        G('emptyContact').innerHTML = '联系方式不能为空';
        G('txtContact').focus();
        return false;
    }
    if (G('txtContent').value == '')
    {
        G('emptyContent').innerHTML = '内容不能为空';
        G('txtContent').focus();
        return false;
    }
    return true;
}

function showDiv(obj)
{
    G(obj).style.display = 'block';
    flag = 1;
}

function setRightPartSize() {
    //if (G('contentArea') == null) return;
    //G('contentArea').style.overflow = 'auto';
    //G('contentArea').style.height = G('leftpart').clientHeight;
}
