var normal  = new Array;
var w_glow    = new Array;
normal[0]   = new Image;
normal[1]   = new Image;
normal[2]   = new Image;
normal[3]   = new Image;
normal[4]   = new Image;
w_glow[0]   = new Image;
w_glow[1]   = new Image;
w_glow[2]   = new Image;
w_glow[3]   = new Image;
w_glow[4]   = new Image;
normal[0].src   = "/images/home_off.gif";
normal[1].src   = "/images/shopping_off.gif";
normal[2].src   = "/images/display_cart_off.gif";
normal[3].src   = "/images/contact_off.gif";
normal[4].src   = "/images/links_off.gif";
w_glow[0].src   = "/images/home_on_mouse.gif";
w_glow[1].src   = "/images/shopping_on_mouse.gif";
w_glow[2].src   = "/images/display_cart_on_mouse.gif";
w_glow[3].src   = "/images/contact_on_mouse.gif";
w_glow[4].src   = "/images/links_on_mouse.gif";

var buy_on  = new Image;
var buy_off = new Image;
buy_on.src  = "/images/buy_btn_on.gif";
buy_off.src = "/images/buy_btn.gif";

function glow(index) {
    document.images[index + 1].src = w_glow[index].src;
}
function end_glow(index) {
    document.images[index + 1].src = normal[index].src;
}
function new_window() {
	new_window = window.open("", "nw", "width=400,height=250,resizable=yes,scrollbars=yes,status=yes");
	new_window.focus();
}

function delete_item(id) {
    if (confirm('この商品をショッピングカートから削除して宜しいですか？')) {
        window.location.href = '/cart.php?cmd=delete&id=' + id;
    }
}

function validate_qty(form) {
    index = form.qty.selectedIndex;
    if (!form.qty.options[index].value) {
        alert('数量を選択してください。');
        return false;
    }
    return true;
}

function buy_btn_on(button) {
    button.src = buy_on.src;
}

function buy_btn_off(button) {
    button.src = buy_off.src;
}

function show_lovejet_desc(event) {
    var y = getMouseY(event) + getScrollingOffset();
    if (navigator.appName == 'Netscape' || navigator.appName == 'Microsoft Internet Explorer') {
        y = getMouseY(event);
    }
    if (y - getScrollingOffset() > 400) {
        y -= 180;
    }
    else {
        y += 10;
    }
    //alert('scrollingOffset is ' + getScrollingOffset());
    var x = getMouseX(event);
    $('lovejet_description').style.left         = x + 'px';
    $('lovejet_description').style.top          = y + 'px';
    $('lovejet_description').style.visibility   = 'visible';
}
function hide_lovejet_desc() {
    $('lovejet_description').style.left         = '-1000px';
    $('lovejet_description').style.top          = '-1000px';
    $('lovejet_description').style.visibility   = 'hidden';
}
    
function getScrollingOffset() {
    if (self.pageYOffset) // all except Explorer
    {
    	y = self.pageYOffset;
    }
    else if (document.documentElement && document.documentElement.scrollTop)
    	// Explorer 6 Strict
    {
    	y = document.documentElement.scrollTop;
    }
    else if (document.body) // all other Explorers
    {
    	y = document.body.scrollTop;
    }
    return y;
}
function getMouseX(e){
  if(window.opera)   
          return e.clientX
  else if(document.all)   
          return document.body.scrollLeft+event.clientX
  else if(document.layers||document.getElementById)
          return e.pageX
}
function getMouseY(e){
  if(window.opera)   
          return e.clientY
  else if(document.all)   
          return document.body.scrollTop+event.clientY
  else if(document.layers||document.getElementById)
          return e.pageY
}
