﻿var expandable_player;
var box;
var width = 276; // Festlegen der Ursprungsbreite
var height = 207; // Festlegen der Ursprungshöhe
var video;
var time;
var boxid;
var clear;

window.onload = function() {
	loaded = true;
}

function expandBox(id, backroundimage, flashvideo, flashplayer, flashtime) {

    if (loaded == true) {
        if (width == 276 & height == 207) {
            boxid = id;
            video = flashvideo;
            time = flashtime;
			expandable_player = flashplayer;  
			box = document.getElementById('expandableBox' + boxid);
            box.style.display = 'block';
            box.style.backgroundImage = 'url(' + backroundimage + ')';
            box.style.backgroundRepeat = 'no-repeat';
            box.style.backgroundPosition = 'center';
            slideUp();
        }
    }
}

function slideUp() {

    if (width < 385 & height < 328) {
        box.style.width = width + 'px';
        box.style.height = height + 'px';
        pause('slideUp');
        width += 5; height += 5.5;
        //alert(width + " " + height);
    }
    else if (width >= 385 & height >= 328) {
        width = 385;
        height = 328;
        box.style.width = width + 'px';
        box.style.height = height + 'px';
        var content = "<div class='boxclose'><p><a href='javascript:void(0);' onclick='shrinkBox();'><img src='http://hearing.siemens.com/_resources-re/files/04-products/21-pure/_resources/images/close.gif' alt='close window' title='close window' width='14' height='16' border='0'/></a></p></div><div id='flashcontent'></div>"
        document.getElementById('expandableBox' + boxid).innerHTML = content;
        flash(video);
    }
}

function pause(slide) {
    window.setTimeout(slide+"()", 1);
}


function shrinkBox() {
    if (loaded == true) {
        if (width == 385 & height == 328) {
            slideDown();
        }
    }
}

function slideDown() {

    document.getElementById('expandableBox' + boxid).innerHTML = "";
    window.clearTimeout(clear);


    if (width > 256 & height > 187) {
        box.style.width = width + 'px';
        box.style.height = height + 'px';
        pause('slideDown');
        width -= 5; height -= 5.5;
        //alert(width + " " + height);

    }
    else {
        width = 276;
        height = 207;
        box.style.width = width + 'px';
        box.style.height = height + 'px';
        box.style.display = 'none';
    }
}

function flash(video) {

    var params = {};
    params.allowFullscreen = "true";

    var flashvars = {};
    flashvars.width = 385;
    flashvars.height = 308;
    flashvars.flv_path = video;
    flashvars.flv_start_img = /*VIPURL*/"../files/04-products/21-pure/_resources/images/StartImage.jpg";
    flashvars.flv_start_btn = true;
    flashvars.flv_smoothing = true;
    flashvars.flv_autoplay = true;
    flashvars.flv_repeat = false;
    flashvars.flv_show_speaker = true;
    flashvars.flv_show_control = true;
    flashvars.flv_autohidecontrol = true;
    flashvars.flv_autohidecontroldelay = 2;
    flashvars.flv_allow_fullscreen = true;
    flashvars.flv_fullscreen_bg = "";
    flashvars.flv_fullscreen_bg_alpha = 1;
    flashvars.flv_volume = 1;
    flashvars.flv_error_message = "Video nicht gefunden";

    swfobject.embedSWF(expandable_player, "flashcontent", flashvars.width, flashvars.height, "9.0.0", "", flashvars, params);
    clear = window.setTimeout("slideDown()", time*1000);
}