// DAMD Inc.

function pickUpPhotoThumb(alternate, carId, photo)
{
  var str = '<li><a href="javascript:void(0);" onclick="document.getElementById(\'photoTarget\').src=\'../imagesCars/' + carId + '_pickup_' + photo + '\'; document.getElementById(\'photoTarget\').alt=\'' + alternate + '\'; return false;"><img alt="' + alternate + '" src="../imagesCars/' + carId + '_pickup_navigation_' + photo + '" /></a></li>';
  return str;
}

function pickUpPhoto(posId, photoId)
{
  var newWindow = window.open("about:blank", "pickUpPhoto", "location=no, menubar=no, status=no, scrollbars=yes, resizable=yes, toolbar=no, left=0, top=0, width=" + window.screen.width + ", height=" + window.screen.height);
  newWindow.document.open();
  newWindow.document.write('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="ja" lang="ja"><head><meta http-equiv="content-type" content="text/html; charset=shift_jis" /><meta http-equiv="content-script-type" content="text/javascript" /><meta http-equiv="content-style-type" content="text/css" /><title>Styling Effect : ' + carTitle + ' | DAMD Inc.</title><link rel="stylesheet" href="../../common/css/pickup.css" type="text/css" /></head><body><div id="wrapper"><div id="close"><a href="#" onclick="window.close(); return false;"><img alt="Close" src="../images/pickup_close.gif" /></a></div><div id="photo"><img id="photoTarget" alt="' + alternateList[posId][photoId] + '" src="../imagesCars/' + carId + '_pickup_' + photoList[posId][photoId] + '" /></div><div id="indicator">');
  
  if (!photoList[3])
    newWindow.document.write('<div id="info"><div id="damdLogo"><a href="http://www.damd.co.jp/" target="_blank"><img alt="DAMD" src="../images/pickup_logo_damd.gif" /></a></div><div id="copyright"><img alt="&copy;1999-2009 DAMD Inc. All Rights Reserved." src="../images/pickup_copyright.gif" /></div></div><div id="navigation"><h1><img alt="Pick Up Photo" src="../images/pickup_navigation_title.gif" /></h1><ul id="navigationFront" class="navigationPosition">' + pickUpPhotoThumb(alternateList[0][0], carId, photoList[0][0]));
   else
    newWindow.document.write('<div id="navigation2"><h1><img alt="Pick Up Photo" src="../images/pickup_navigation2_title.gif" /></h1><ul id="navigationFront" class="navigationPosition">' + pickUpPhotoThumb(alternateList[0][0], carId, photoList[0][0]));
  
  if (photoList[0][1])
    newWindow.document.write(pickUpPhotoThumb(alternateList[0][1], carId, photoList[0][1]));
  
  if (photoList[0][2])
    newWindow.document.write(pickUpPhotoThumb(alternateList[0][2], carId, photoList[0][2]));
  
  newWindow.document.write('</ul><ul id="navigationSide" class="navigationPosition">' + pickUpPhotoThumb(alternateList[1][0], carId, photoList[1][0]));
  
  if (photoList[1][1])
    newWindow.document.write(pickUpPhotoThumb(alternateList[1][1], carId, photoList[1][1]));
  
  if (photoList[1][2])
    newWindow.document.write(pickUpPhotoThumb(alternateList[1][2], carId, photoList[1][2]));
  
  newWindow.document.write('</ul><ul id="navigationRear" class="navigationPosition">' + pickUpPhotoThumb(alternateList[2][0], carId, photoList[2][0]));
  
  if (photoList[2][1])
    newWindow.document.write(pickUpPhotoThumb(alternateList[2][1], carId, photoList[2][1]));
  
  if (photoList[2][2])
    newWindow.document.write(pickUpPhotoThumb(alternateList[2][2], carId, photoList[2][2]));
  
  if (!photoList[3])
    newWindow.document.write('</ul></div></div></div><div id="pinkBorder">&nbsp;</div></body></html>');
   else {
    newWindow.document.write('</ul><ul id="navigationOther" class="navigationPosition">' + pickUpPhotoThumb(alternateList[3][0], carId, photoList[3][0]));
    
    if (photoList[3][1])
      newWindow.document.write(pickUpPhotoThumb(alternateList[3][1], carId, photoList[3][1]));
    
    if (photoList[3][2])
      newWindow.document.write(pickUpPhotoThumb(alternateList[3][2], carId, photoList[3][2]));
    
    newWindow.document.write('</ul></div></div></div><div id="pinkBorder">&nbsp;</div><div id="copyright2"><img alt="&copy;1999-2009 DAMD Inc. All Rights Reserved." src="../images/pickup_copyright.gif" /></div></body></html>');
  }
  
  newWindow.document.close();
}

// Flash呼び出し
function loadFlash(uri, w, h, bgcolor)
{
  str = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="' + w + '" height="' + h + '" align=""><param name="movie" value="' + uri + '"><param name="quality" value="high"><param name="bgcolor" value="' + bgcolor + '"><embed src="' + uri + '" quality="high" bgcolor="' + bgcolor + '" width="' + w + '" height="' + h + '" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"></embed></object>';
  document.writeln(str);
}

// トップページのラインアップ更新日生成
function showUpdate(date, cat)
{
  var catname = ["imperial", "blackmetal", "lionheart", "stylingeffect", "muffler", "wheel", "accessories", "ancel"];
  var str = '<div class="date">';
  
  if (date == '')
    str += "</div>";
   else {
    for (var i = 0; i < date.length; i++) {
      str += (date.charAt(i) == '.') ? '<img src="images/d_dot_' + catname[cat] + '.gif" height="11" alt=".">':
                                       '<img src="images/d_' + date.charAt(i) + '_' + catname[cat] + '.gif" height="11" alt="' + date.charAt(i) + '">';
    }
    
    str += '<img src="images/d_updated_' + catname[cat] + '.gif" height="11" alt=" UPDATED"></div>';
  }
  
  document.writeln(str);
}

// テーブルを縞模様にする
function doZebra()
{
  var tables = document.getElementsByTagName("table");
  
  for (var i = 0; i < tables.length; i++)
    if (tables[i].className.match(/zebra/))
      zebra(tables[i]);
}

function zebra(table)
{
  var current = "odd";
  var trs = table.getElementsByTagName("tr");
  
  for (var i = 0; i < trs.length; i++) {
    trs[i].className += " " + current;
    current = current == "even" ? "odd": "even";
  }
}

// 画像のロールオーバー
function smartRollover()
{
  if (document.getElementsByTagName) {
    var images = document.getElementsByTagName("img");
    
    for (var i = 0; i < images.length; i++)
      if (images[i].getAttribute("src").match(/_off\./)) {
        images[i].onmouseover = function() {
          this.setAttribute("src", this.getAttribute("src").replace("_off.", "_on."));
        }
        images[i].onmouseout = function() {
          this.setAttribute("src", this.getAttribute("src").replace("_on.", "_off."));
        }
      }
  }
}

if (window.addEventListener)
  window.addEventListener("load", smartRollover, false);
 else if (window.attachEvent)
  window.attachEvent("onload", smartRollover);

window.onload = doZebra;
