// JavaScript Document

var screenWidth,screenHeight;
var kstarWidth = 177, kstarHeight = 791;
var sushiWidth = 238, sushiHeight = 782;
var sugiWidth = 239, sugiHeight = 791;
var freeSpace = 0.95;


$(document).ready(function(){
  screenWidth = GetWidth();
  screenHeight = GetHeight();

  //resize ble ble!
  
  if (screenHeight < (sushiHeight /freeSpace))
  {
    var factor = screenHeight / kstarHeight * freeSpace;
    kstarWidth *=  factor;
    kstarHeight *= factor;
    $("#kstar").css("width",kstarWidth + "px");
    $("#kstar").css("height",kstarHeight + "px");
    
    factor = screenHeight / sushiHeight * freeSpace;
    sushiWidth *=  factor;
    sushiHeight *= factor;
    $("#sushi").css("width",sushiWidth + "px");
    $("#sushi").css("height",sushiHeight + "px");
    
    factor = screenHeight / sugiHeight * freeSpace;
    sugiWidth *=  factor;
    sugiHeight *= factor;
    $("#sugi").css("width",sugiWidth + "px");
    $("#sugi").css("height",sugiHeight + "px");
  }

  $("#center").css("width", (kstarWidth + sushiWidth + sugiWidth + 5 ) + "px");
   
  $("#kstar").css("top", "-" + kstarHeight + "px");
  $("#sushi").css("top", "-" + sushiHeight + "px");
  $("#sugi").css("top", "-" + sugiHeight + "px");
  
  $("#kstar").delay(500).delay(400).animate({
       top: "0px"
     }, 800);
  $("#sushi").delay(500).animate({
       top: "0px"
     }, 800);
  $("#sugi").delay(500).delay(740).animate({
       top: "0px"
     }, 800);

  $("a img").click(function(){
    $("a img").not(this).animate({
       opacity: "0"
     }, 1000);
    var id = $(this).attr("id");
    var addr = "";
    if(id == "kstar")
      addr = "http://www.kstarkaraoke.com/index2.php";
    if(id == "sushi")
      addr = "http://www.sushiislands.com/index2.php";
    if(id == "sugi")
      addr = "http://www.sugidamasake.com";
    
     setTimeout("window.location = '"+addr+"';", 1000);
    return false;
  });  
});

function GetHeight()
{
        var y = 0;
        if (self.innerHeight)
        {
                y = self.innerHeight;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                y = document.documentElement.clientHeight;
        }
        else if (document.body)
        {
                y = document.body.clientHeight;
        }
        return y;
}

function GetWidth()
{
        var x = 0;
        if (self.innerHeight)
        {
                x = self.innerWidth;
        }
        else if (document.documentElement && document.documentElement.clientHeight)
        {
                x = document.documentElement.clientWidth;
        }
        else if (document.body)
        {
                x = document.body.clientWidth;
        }
        return x;
}
