/*
 * This file is part of EC-CUBE
 *
 * Copyright(c) 2000-2007 LOCKON CO.,LTD. All Rights Reserved.
 *
 * http://www.lockon.co.jp/
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
// FLASH TOP用JS
function resizeAgent1(){
    
    var windowWidth = getWindowWidth();
    var windowHeight = getWindowHeight();
    var swfElement = document.getElementsByTagName("embed");
    var upperHeight = 40;
    var leftWidth = 170;
    var newSwfHeight = 0;
    var newSwfWidth = 0;
    
    if(swfElement[0] == null){
        swfElement = document.getElementsByTagName("object");
        if(swfElement[0] == null){
            return;
        }
    }
    
    
    newSwfWidth = windowWidth - leftWidth;
    newSwfHeight = windowHeight - upperHeight;
    
    if(newSwfWidth <= 500){
        newSwfWidth = 500;
    }
    if(newSwfHeight <= 450){
        newSwfHeight = 450;
    }
    
    if(swfElement[0].width != newSwfWidth || swfElement[0].height != newSwfHeight){
        swfElement[0].width = newSwfWidth;
        swfElement[0].height = newSwfHeight;
    }
}
function resizeAgent2(){
    
    var windowWidth = getWindowWidth();
    var windowHeight = getWindowHeight();
    var swfElement = document.getElementsByTagName("embed");
    var itemElement = document.getElementById("item")
    var recomElement = document.getElementById("recommend");
    var upperHeight = 38;
    var leftWidth = 470;
    var newSwfHeight = 0;
    var newSwfWidth = 0;
    
    if(swfElement[0] == null){
        swfElement = document.getElementsByTagName("object");
        if(swfElement[0] == null){
            return;
        }
    }
    newSwfWidth = windowWidth - leftWidth;
    newSwfHeight = windowHeight - upperHeight;
    
    if(newSwfWidth <= 510){
        newSwfWidth = 510;
    }
    
    if(newSwfHeight <= 510){
        newSwfHeight = 510;
    }
    
    swfElement[0].width = newSwfWidth;
    swfElement[0].height = newSwfHeight;
    
    if(itemElement != null){
        itemElement.style.width = newSwfWidth + "px";
    }
    if(recomElement != null){
        recomElement.style.width = newSwfWidth + "px";
    }
}

function getWindowHeight() 
{
     var ua = navigator.userAgent;
     var nHeight;
     var nHit = ua.indexOf("MSIE");
     var bIE = (nHit >=  0);
     var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");
     var bStd = (document.compatMode && document.compatMode=="CSS1Compat");
     
     if (bIE) {
          if (bVer6 && bStd) {
               nHeight = document.documentElement.clientHeight;
          } else {
               nHeight = document.body.clientHeight;
          }
     } else {
          nHeight = window.innerHeight;
     }
     return nHeight;
}

function getWindowWidth() 
{
     var ua = navigator.userAgent;
     var nWidth;
     var nHit = ua.indexOf("MSIE");
     var bIE = (nHit >=  0);
     var bVer6 = (bIE && ua.substr(nHit+5, 1) == "6");
     var bStd = (document.compatMode && document.compatMode=="CSS1Compat");
     
     if (bIE) {
          if (bVer6 && bStd) {
               nWidth = document.documentElement.clientWidth;
          } else {
               nWidth = document.body.clientWidth;
          }
     } else {
          nWidth = window.innerWidth;
          nWidth -= 19;
     }
     return nWidth;
}
var _CollectNewsNumber = 0;
var _CollectNewsTImerId;
var _CollectNewsGlobalTimer;
var _CollectNewsMax;
function fnNewsTImerEvent(){
    if(_CollectNewsMax >= 2){
        _CollectNewsNumber ++;
        _CollectNewsTImerId = setInterval('fnNewsScroll()' , 30);
        clearInterval(_CollectNewsGlobalTimer);
    }
}

function fnNewsScroll(){
    var tmpDoc = document.getElementById("newsItem");
    var topTmp = tmpDoc.style.top.replace("px" , "");
    topTmp = parseInt(topTmp);
    topTmp -= 1;
    if(topTmp <= -25 * _CollectNewsNumber){
        clearInterval(_CollectNewsTImerId);
        if(_CollectNewsNumber == _CollectNewsMax){
            _CollectNewsNumber = 0;
            topTmp = 0;
        }
        _CollectNewsGlobalTimer = setInterval('fnNewsTImerEvent()' , 5000);
    }
    tmpDoc.style.top = topTmp + "px";
}
function fnNewsInitaize(){
    _CollectNewsMax = document.getElementById("newsItem").getElementsByTagName("br").length;
    var tmpDoc = document.getElementById("newsItem");
    tmpDoc.style.top = "0px";
}
