/**
 * @Name    Youki Okuyama
 * @Desc    use for all contents
 * @Author  Nissan GHQ
 * @Date    2009/08/05 17:55
 **/

function loadSwfFile(path, width, height)
{
  document.write("<div id=\"changeFlash\">");
  document.write("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"" + width + "\" height=\"" + height + "\" id=\"flashImage\" align=\"middle\">");
  document.write("<param name=\"allowScriptAccess\" value=\"sameDomain\" />");
  document.write("<param name=\"movie\" value=\"/EN/COMPANY/HQ" + path + ".swf\" />");
  document.write("<param name=\"quality\" value=\"high\" />");
  document.write("<param name=\"bgcolor\" value=\"#FFFFFF\" />");
  document.write("<param name=\"wmode\" value=\"transparent\" />");
  document.write("<embed src=\"/EN/COMPANY/HQ" + path + ".swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#FFFFFF\" width=\"" + width + "\" height=\"" + height + "\" name=\"flashImage\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" />");
  document.write("</object>");
  document.write("</div>");
}

function changeFlash()
{
  //for IE
  if(navigator.userAgent.indexOf("MSIE") != -1)
  {
    cflash=document.all("changeFlash");
    cflash.innerHTML="<div id=\"changeflash\"><object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" width=\"964\" height=\"350\" id=\"flashImage\" align=\"middle\"><param name=\"allowScriptAccess\" value=\"sameDomain\" /><param name=\"movie\" value=\"./IMAGES/top_EN.swf\" /><param name=\"quality\" value=\"high\" /><param name=\"bgcolor\" value=\"#000000\" /><param name=\"wmode\" value=\"transparent\" /><embed src=\"./IMAGES/top_EN.swf\" quality=\"high\" wmode=\"transparent\" bgcolor=\"#000000\" width=\"964\" height=\"350\" name=\"flashImage\" align=\"middle\" allowScriptAccess=\"sameDomain\" type=\"application/x-shockwave-flash\" /></object></div>";
  }
  //other
  else
  {
    cflash=document.getElementById("changeFlash");
    cflash.removeChild(document.getElementsByTagName("object").item(0));
    object=document.createElement("object");
    param=document.createElement("param");
    embed=document.createElement("embed");
    object.setAttribute("classid","clsid:D27CDB6E-AE6D-11cf-96B8-444553540000");
    object.setAttribute("width","964");
    object.setAttribute("height","350");
    object.setAttribute("id","flashImage");
    object.setAttribute("align","middle");
    param.setAttribute("name","allowScriptAccess");
    param.setAttribute("value","sameDomain");
    param.setAttribute("name","movie");
    param.setAttribute("value","./IMAGES/top_EN.swf");
    param.setAttribute("name","quality");
    param.setAttribute("value","high");
    param.setAttribute("name","bgcolor");
    param.setAttribute("value","#000000");
    param.setAttribute("name","wmode");
    param.setAttribute("value","transparent");
    embed.setAttribute("src","./IMAGES/top_EN.swf");
    embed.setAttribute("quality","high");
    embed.setAttribute("wmode","transparent");
    embed.setAttribute("bgcolor","#000000");
    embed.setAttribute("width","964");
    embed.setAttribute("height","350");
    embed.setAttribute("name","flashImage");
    embed.setAttribute("align","middle");
    embed.setAttribute("allowScriptAccess","sameDomain");
    embed.setAttribute("type","application/x-shockwave-flash");
    object.appendChild(param);
    object.appendChild(embed);
    cflash.appendChild(object);
  }
}



function setCookie()
{
  document.cookie = "nissanGhq=nissanGHQopeningMovie";
}

function getCookie()
{
  var nissanCookie = document.cookie;
  return nissanCookie;
}

function deleteCookie()
{
  //dTime = new Date();
  //dTime.setYear(dTime.getYear() - 1);
  //document.cookie = "nissanGhq=nissanGHQopeningMovie; expires=" + dTime.toGMTString();
  document.cookie = "nissanGhq=nissanGHQopeningMovie; expires=Mon, 1-Jan-1900 00:00:00 GMT.";
  setTimeout("changeFlash()",0);
}



var sourceReplace = function(off,on)

{
  img = document.getElementsByTagName("img");
  p = [];
  off_reg=new RegExp(off+"(\.[a-z]+$)","i");
  on_reg=new RegExp(on+"(\.[a-z]+$)","i");
  
  for(var x=0,i;i=img[x];x++)
  {
    if(i.src.match(off_reg))
    {
      p[x]=new Image();p[x].src=i.src.replace(off_reg,on+"$1");
      i.onmouseover=function()
      {
        this.src=this.src.replace(off_reg,on+"$1");
      };
      i.onmouseout=function()
      {
        this.src=this.src.replace(on_reg,off+"$1");
      };
    };
  };
};

window.onload = function()
{
 sourceReplace( "_off" , "_on" );
};


