$(document).ready(function(){
 if (swfobject.hasFlashPlayerVersion('8')) {
    var params = {menu: "false", wmode: "opaque"};
    swfobject.embedSWF("/flash/jdph_logo.swf", "logo", "196", "156", "8.0.0", null, null, params);
  } else {
    $('#head img').css('display', 'block');
  }
});

var curLogoPos = 1;

var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
  var c = ca[i];
  while (c.charAt(0)==' ') c = c.substring(1,c.length);
  if (c.indexOf('curLogoPos') == 0) {
    curLogoPos=parseInt(c.substring(11,c.length));
    break;
  }
}

function logopos(flashMovie, num, fast) {
  var coords = getCoords(num);
  if (fast != undefined && fast == true) {
    flashMovie.resetPos(coords);
  } else {
    expire = new Date();
    expire.setTime(expire.getTime()+(365*24*60*60*1000));
    var expires = "; expires="+expire.toGMTString();
    document.cookie = "curLogoPos=" + num + ";path=/;"+expires;
    flashMovie.move(coords);
  }
  
}


function logoinit() {
  document.getElementById("logo").resetPos(getCoords(curLogoPos));
}

function getCoords (num) {
  var rings = new Array;
  switch (num) {
    case 1:
      rings[0] = {targetDegree:0, duration:3};
      rings[1]  = {targetDegree:0, duration:3};
      rings[2]  = {targetDegree:0, duration:3};
      rings[3]  = {targetDegree:0, duration:3};
      rings[4]  = {targetDegree:0, duration:3};
      return rings;
    break;
    case 2:
      rings[0] = {targetDegree:435, duration:3};
      rings[1]  = {targetDegree:-435, duration:3};
      rings[2]  = {targetDegree:75, duration:3};
      rings[3]  = {targetDegree:-255, duration:3};
      rings[4]  = {targetDegree:435, duration:3};
      return rings;
    break;
    
    case 3:
      rings[0] = {targetDegree:45, duration:3};
      rings[1]  = {targetDegree:-390, duration:3};
      rings[2]  = {targetDegree:-35, duration:3};
      rings[3]  = {targetDegree:-395, duration:3};
      rings[4]  = {targetDegree:-400, duration:3};
      return rings;
    break;
    
    case 4:
      rings[0] = {targetDegree:555, duration:3};
      rings[1]  = {targetDegree:205, duration:3};
      rings[2]  = {targetDegree:200, duration:3};
      rings[3]  = {targetDegree:200, duration:3};
      rings[4]  = {targetDegree:195, duration:3};
      return rings;
    break;
    
    case 5:
      rings[0] = {targetDegree:-110, duration:3};
      rings[1]  = {targetDegree:-90, duration:3};
      rings[2]  = {targetDegree:-460, duration:3};
      rings[3]  = {targetDegree:-100, duration:3};
      rings[4]  = {targetDegree:-105, duration:3};
      return rings;
    break;
  }
  return false;
}


function rotateLogo() {
  curLogoPos++;
  if (curLogoPos >= 6) curLogoPos = 1;
  if (document.getElementById("logo") && !($('#logo').is('img'))) {
    logopos(document.getElementById("logo"), curLogoPos);
  }
}

setInterval("rotateLogo()", 15000);

