large = ["/i/fyi/IYNF2009_EN.jpg", "/i/fyi/IYNF2009_AR.jpg", "/i/fyi/IYNF2009_CH.jpg", "/i/fyi/IYNF2009_RU.jpg"];
medium = ["/i/fyi/IYNF2009_EN_medium.jpg", "/i/fyi/IYNF2009_AR_medium.jpg", "/i/fyi/IYNF2009_CH_medium.jpg", "/i/fyi/IYNF2009_RU_medium.jpg"];
small =  ["/i/fyi/IYNF2009_EN_small.jpg", "/i/fyi/IYNF2009_AR_small.jpg", "/i/fyi/IYNF2009_CH_small.jpg", "/i/fyi/IYNF2009_RU_small.jpg"];
hangTime = [4000,8000,4000,4000];
currentSize ="";
src = large;
logos=[];
count=0;
width=0;

function winWidth() {
if (window.innerWidth) {
width = window.innerWidth;
} else if (document.getElementsByTagName) {
var html = document.getElementsByTagName('html');
if (html[0].offsetWidth) {
width = html[0].offsetWidth;
}
}
}

function scaleImage() {
if (i<25) {
scaleWidth = scaleWidth + (currentWidth - scaleWidth)/(25-i);
scaleHeight = scaleHeight + (currentHeight - scaleHeight)/(25-i);
document["Logo_Image"].width = scaleWidth;
document["Logo_Image"].height = scaleHeight;
i++;
if (i<25) {
delayTime = parseInt(150*Math.sin(Math.PI*i/(2*25)));
setTimeout("scaleImage()",delayTime);
} else {
document["Logo_Image"].width = currentWidth;
document["Logo_Image"].height = currentHeight;
}
}
}

function nextLogo() {
winWidth();
if ((width>1100) && (currentSize != "large")) {
if (currentSize!="") {
sizeChange = "y";
previousSize = currentSize;
} else {
sizeChange = "i";
}
currentSize = "large";
src = large;
} else if ((width<=1100) && (width>=900) && (currentSize != "medium")) {
if (currentSize!="") {
sizeChange = "y";
previousSize = currentSize;
} else {
sizeChange = "i";
}
currentSize = "medium";
src = medium;
} else if ((width<900) && (currentSize != "small")) {
if (currentSize!="") {
sizeChange = "y";
previousSize = currentSize;
} else {
sizeChange = "i";
}
currentSize = "small";
src = small;
}
var n=(count+1)%src.length;
if (logos[n] && (logos[n].complete || logos[n].complete==null)) {
document["Logo_Image"].src = logos[count=n].src;
}
logos[n=(count+1)%src.length] = new Image;
logos[n].src = src[n];
if ((sizeChange == "i") || (sizeChange == "y")) {
if (currentSize == "large") {
currentWidth = 487;
currentHeight = 374;
} else if (currentSize == "medium") {
currentWidth = 365;
currentHeight = 280;
} else if (currentSize == "small") {
currentWidth = 244;
currentHeight = 188;
}
if (sizeChange == "i") {
sizeChange = "n";
document["Logo_Image"].width = currentWidth;
document["Logo_Image"].height = currentHeight;
setTimeout("nextLogo()",hangTime[n]);
} else if (sizeChange == "y") {
sizeChange = "n";
if (previousSize == "large") {
initialWidth = 487;
initialHeight = 374;
} else if (previousSize == "medium") {
initialWidth = 365;
initialHeight = 280;
} else if (previousSize == "small") {
initialWidth = 244;
initialHeight = 188;
}
scaleWidth = initialWidth;
scaleHeight = initialHeight;
i = 0;
//delayLog = "";
scaleImage();
setTimeout("nextLogo()",4000);
}
} else {
setTimeout("nextLogo()",hangTime[n]);
}
}
onload = function(){
if (document.images)
nextLogo();
}