﻿var topblank = 0;
function getCurStyle(obj, attribute) { return obj.currentStyle ? obj.currentStyle[attribute] : document.defaultView.getComputedStyle(obj, false)[attribute]; }
var pageModule = new Array();
//计算页脚的top,显示备案页脚
var ShowBeiAn = function() {
    var maxtop = 0;
    for (var i = 0; i < pageModule.length; i++) {
        if (pageModule[i].offsetTop + pageModule[i].offsetHeight > maxtop)
            maxtop = pageModule[i].offsetTop + pageModule[i].offsetHeight;
    }
    ID$("foot").style.top = maxtop + 330 + "px";
}
var SetToModule = function() {
    var moduleDiv = ID$("con").getElementsByTagName("div");
    for (var i = 0, j = 0; i < moduleDiv.length; i++) {
        if (moduleDiv[i].id.indexOf("con") > -1) {
            if (moduleDiv[i].getElementsByTagName("ul").length > 0) {
                var mImg = moduleDiv[i].getElementsByTagName("img");
                if (mImg.length > 0) {
                    moduleDiv[i].style.height = (mImg[0].className == "img") ? 295 * (mImg.length / 4 == 0 ? mImg.length / 4 : mImg.length / 4 + 1) + "px" : "500px";
                } else {
                    var mli = moduleDiv[i].getElementsByTagName("li");
                    if (mli.length > 0) {
                        moduleDiv[i].style.height = 30 * mli.length + 20 + "px";
                        if (moduleDiv[i].getElementsByTagName("textarea").length > 0) moduleDiv[i].style.height = "auto";
                        if (mli.length == 1) moduleDiv[i].style.height = "140px";
                    }
                }
            } else {
                if (moduleDiv[i].getElementsByTagName("div").length > 1) moduleDiv[i].style.height = 260 * moduleDiv[i].getElementsByTagName("div").length + "px";
            }
            pageModule.push(moduleDiv[i]);
        }
    }
}
//向上吸附
var SetToUp = function() {
    var maxtop = 0;
    for (var i = 0; i < pageModule.length; i++) {
        var md = pageModule[i];
        var top = GetUpObj(md.id, parseInt(md.offsetLeft), parseInt(md.offsetTop), md.offsetHeight, i);
        md.style.top = ((i > 0 && pageModule[i].offsetLeft == md.offsetLeft && parseInt(pageModule[i].offsetTop) == top) ? 6 + parseInt(pageModule[i].offsetTop) + parseInt(pageModule[i].offsetHeight) + "px" : parseInt(topblank + top)) + "px";
        if (parseInt(md.offsetTop) + parseInt(md.offsetHeight) > maxtop) maxtop = parseInt(md.offsetTop) + parseInt(md.offsetHeight);
    }
    ShowBeiAn();
}
//返回原点垂直位置 top
var GetUpObj = function(id, left, top, index) {
    var maxtop = 0;
    for (var i = 0; i < pageModule.length; i++) {
        var md = pageModule[i];
        if (md.id != id && parseInt(md.offsetLeft) >= left && Math.abs(parseInt(md.offsetLeft) - left) <= parseInt(ID$(id).offsetWidth) && parseInt(md.offsetTop) <= top && parseInt(md.offsetTop) >= maxtop) {
            maxtop = 6 + parseInt(md.offsetTop) + parseInt(md.offsetHeight);
        }
    }
    return maxtop;
}
var isIE = (document.all) ? true : false;
styleObj = function(sname, index) {
    var rules = isIE ? document.styleSheets[index].rules : document.styleSheets[index].cssRules;
    if (sname.indexOf("H") > -1 && !isIE) sname = sname.toLowerCase();
    for (var j = 0; j < rules.length; j++) {
        if (rules[j].selectorText == sname) {
            return rules[j].style;
        }
    }
    return null;
}

function setstyle(sname) {
    var obj;
    if (document.styleSheets.length > 2) obj = styleObj(sname, 2);
    if (obj == null) obj = styleObj(sname, 1);
    return obj;
}

function insertFlash(elm, url) {
    var w = setstyle("#" + elm).width, h = setstyle("#" + elm).height;
    var str = '';
    if (url.indexOf('.flv') > 0) {
        var partUrl = 'http://com.qididai.com';
        str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0" width="' + w + '" height="' + h + '">' +
    '<param name="movie" value="http://www.cnzz.cc/Flv/Flvplayer.swf" /><param name="quality" value="high" /><param name="allowFullScreen" value="true" />' +
    '<param name="FlashVars" value="vcastr_file=' + partUrl + url + '" />' +
    '<embed src="http://www.cnzz.cc/Flv/Flvplayer.swf" allowfullscreen="true" flashvars="vcastr_file=' + partUrl + url + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="' +
    w + '" height="' + h + '"></embed></object>';
    } else {
        str += '<object width="' + w + '" height="' + h + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">';
        str += '<param name="movie" value="' + url + '">';
        str += '<param name="wmode" value="transparent">';
        str += '<param name="quality" value="autohigh">';
        str += '<embed width="' + w + '" height="' + h + '" src="' + url + '" autostart=true loop=true quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
        str += '</object>';
    }
    ID$(elm).innerHTML = str;
}
var pageDisplayModule = new Array();

var SetPositions = function() {
    var moduleDiv = ID$("con").getElementsByTagName("div");
    for (var i = 0, j = 0; i < moduleDiv.length; i++) {
        if (moduleDiv[i].id.indexOf("con") > -1) {
            pageDisplayModule.push(moduleDiv[i]);
        }
    }
}
Date.prototype.format = function(format) {
    var o = {
        "M+": this.getMonth() + 1, //month
        "d+": this.getDate(),    //day
        "h+": this.getHours(),   //hour
        "m+": this.getMinutes(), //minute
        "s+": this.getSeconds(), //second
        "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
        "S": this.getMilliseconds() //millisecond
    };
    if (/(y+)/.test(format)) { format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); }
    for (var k in o) {
        if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    }
    return format;
}
var submessage = function() {
    if (ID$("mtitle").value.isSpChar() && ID$("mName").value.isChinaOrNumbOrLett() && ID$("mcontent").value.isSpChar()) {
        objectReturn2("/AjaxServer.ashx?ajaxflag=fmessage&title=" + escape(ID$("mtitle").value) + "&name=" + escape(ID$("mName").value) + "&content=" + escape(ID$("mcontent").value), function() {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                if (xmlhttp.responseText > 0) {
                    alert("留言成功");
                    ID$("fmdiv_con").innerHTML = "<FIELDSET><LEGEND>网友<strong>" + ID$("mName").value + "</strong>留言标题：" + ID$("mtitle").value + "(" + new Date().format("yyyy/MM/dd hh:mm:ss") + ")</LEGEND><p>内容：" + ID$("mcontent").value + "</p></FIELDSET>" + ID$("fmdiv_con").innerHTML;
                    ID$("mtitle").value = ID$("mName").value = ID$("mcontent").value = "";
                    ID$("foot").style.top = parseInt(document.documentElement.scrollHeight) + 20 + "px";
                    var el = ID$("fmdiv").getElementsByTagName("FIELDSET");
                    if (el.length > 10) window.location.reload();
                }
                else { alert("已存在相同的标题"); ID$("mtitle").focus(); }
            }
        });
    }
    return false;
}

function bindMap(x, y, z, maptitle, div) {
    var maps = new LTMaps(div);
    var point = new LTPoint(x, y);
    maps.centerAndZoom(point, z);
    var c = new LTSmallMapControl();
    maps.addControl(c);
    var point = new LTPoint(x, y); //福建3G
    var marker = new LTMarker(point);
    maps.addOverLay(marker);
    var text = new LTMapText(marker);
    text.setLabel(maptitle);
    maps.addOverLay(text);
}

function zoom(x, y, z, maptitle) {
    InncludeCss("stydiv", "/css/photo.css");
    var map = document.createElement("div");
    map.id = "map";
    map.style.width = "794px";
    map.style.height = "578px";
    alertWin("公司地理位置", map, 800, 600);
    bindMap(x, y, z, maptitle, 'map');
}

function Artwork(obj, num) {
    InncludeCss("stydiv", "/css/photo.css");
    AjaxPage("phid", "/js/Div1.js", function() {
        var art = new Image();
        art.src = obj.src;
        art.id = "art" + num;
        art.title = "下一张";
        art.style.cursor = "url(/images/next.cur),auto";
        art.onclick = function() {
            var id = parseInt(this.id.replace("art", "")) + 1;
            this.src = ID$(id).src;
            msgObj.style.width = parseInt(art.width) + 6 + "px";
            msgObj.style.height = parseInt(art.height) + 30 + "px";
            this.id = "art" + id;
        }
        art.style.margin = "2px";
        alertWin("原图", art, parseInt(art.width) + 6, parseInt(art.height) + 30);
    });
}

function AjaxPage(sId, url, fun) {
    objectReturn2(url, function() {
        if (xmlhttp.readyState == 4) {
            if (xmlhttp.status == 200 || xmlhttp.status == 304) {
                IncludeJS(sId, url, xmlhttp.responseText);
                fun();
            } else {
                alert('XML request error: ' + xmlhttp.statusText + ' (' + xmlhttp.status + ')');
            }
        }
    });
}

function IncludeJS(sId, fileUrl, source) {
    if ((source != null) && (!document.getElementById(sId))) {
        var oHead = document.getElementsByTagName('HEAD').item(0);
        var oScript = document.createElement("script");
        oScript.language = "javascript";
        oScript.type = "text/javascript";
        oScript.id = sId;
        oScript.defer = true;
        oScript.text = source;
        oHead.appendChild(oScript);
    }
}

function InncludeCss(sid, fileUrl) {
    if (ID$(sid) == undefined) {
        var head = document.getElementsByTagName('HEAD').item(0);
        var style = document.createElement('link');
        style.id = sid;
        style.href = fileUrl;
        style.rel = 'stylesheet';
        style.type = 'text/css';
        head.appendChild(style);
    }
}
var aCue = document.createElement("div");
function yulangFlash(url) {
    var str = '';
    str += '<object width="' + parseInt(fW) + '" height="' + parseInt(fH) + '" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0">';
    str += '<param name="movie" value="' + url + '">';
    str += '<param name="wmode" value="transparent">';
    str += '<param name="quality" value="autohigh">';
    str += '<embed id="flashem" width="' + parseInt(fW) + '" height="' + parseInt(fH) + '" src="' + url + '" quality="autohigh" wmode="opaque" type="application/x-shockwave-flash" plugspace="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash"></embed>';
    str += '</object>';
    aCue.className = "scycle";
    aCue.innerHTML = fC;
    aCue.title = "点击跳过入场动画,进入首页";
    ID$("adsonFlash").innerHTML = str;
    ID$("adsonFlash").appendChild(aCue);
    document.body.style.background = fB;
    ID$("adsonFlash").style.display = "block";
    ID$("bodyCon").style.display = "none";
    setTimeout("stopFlash()", parseInt(fM + "000"));
    aCue.onclick = function() {
        ID$("adsonFlash").style.display = "none";
        ID$("bodyCon").style.display = "block";
        document.body.style.background = bgn;
    }
}
var stopFlash = function() {
    ID$("adsonFlash").style.display = "none";
    ID$("bodyCon").style.display = "block";
    document.body.style.background = bgn;
}

var search = function(key) {
window.location.href = '/search--' + encodeURI(key).replace(/%20/g, '+') + '.html';
}