

function popupResize(w, h, wmax, hmax)

{

    var ret = false;

    var pad = 0;

    var ea = document.getElementById('popup_movie_align');

    var em = document.getElementById('popup_movie');  

    var ec = document.getElementById('popup_content');  

    var et = document.getElementById('popup_top');  

    var eb = document.getElementById('popup_bottom');  

    var el = document.getElementById('popup_left');  

    var er = document.getElementById('popup_right');      



    if (undefined == wmax) wmax = 850;

    if (undefined == hmax) hmax = 500;



    if (w >= wmax || h >= hmax) // 800 x 454

    {

        w = wmax;

        h = hmax;

        ret = true;

    }



    var hs = getScroll();

    var hh = window.innerHeight ? window.innerHeight : screen.height;			

    em.style.top = hs + (hh/2) - ((h+144+pad)/2) > 0 ? hs + (hh/2) - ((h+144+pad)/2) + 'px' : '0px';



    ec.style.width = w + 'px';

    ec.style.height = h + 'px';



    em.style.width = w + pad + 130 + 'px';

    em.style.height = h + pad + 144 + 'px';    



    et.style.width = w + pad + 'px';

    eb.style.width = w + pad + 'px';

    el.style.height = h + pad + 'px';

    er.style.height = h + pad + 'px';    



    if (ea.style.display != 'block') ea.style.display = 'block';



    return ret;

}



function popupShow()

{

    var e = document.getElementById('popup_movie_align');

    e.style.marginLeft = '0px';

    setTimeout ("popupShowTimer(8,4)", 10);

}





function popupShowString(s, wmax, hmax) {

    var e = $('#popup_movie_align');

    e.hide();

    $('#popup_content').html('<div style="width:850px; height:454px; border:1px solid #BBB; background-color:#CCC; line-height:600px; text-align:center; font-size:72px;"></div>');

    e.css('margin-left', '0px');

    setTimeout ("popupShowTimerString('" + s + "', 8, 4, " + wmax + ", " + hmax + ")", 10);

}



function popupShowSel(sel) {

    var e = $('#popup_movie_align');

    e.hide();

    $('#popup_content').html('<div style="width:850px; height:454px; border:1px solid #BBB; background-color:#CCC; line-height:600px; text-align:center; font-size:72px;"></div>');

    e.css('margin-left', '0px');

    setTimeout ("popupShowTimerSel('" + sel + "',8,4)", 10);

}



function popupShowD6()

{

    var e = document.getElementById('popup_movie_align');

    e.style.marginLeft = '0px';

    setTimeout ("popupShowTimerD6(8,4)", 10);

}



function popupShowSpunky()

{

    var e = document.getElementById('popup_movie_align');

    e.style.marginLeft = '400px';

    setTimeout ("popupShowTimerSpunky(8,4)", 10);

}



function popupShowTimerD6(w, h)

{

    if (popupResize(w, h)) 

	{



		var fo = new SWFObject( "/img/tours/dolphin/dolphin6_controller.swf", "/img/tours/dolphin/dolphin6_controller.swf", "850", "500", "8", "#FFFFFF", false, "best");

		fo.addVariable( "csConfigFile", "/img/tours/dolphin/dolphin6_config.xml"  ); 

		fo.addVariable( "csColor"     , "FFFFFF"           );

		fo.addVariable( "csPreloader" , "/img/tours/dolphin/dolphin6_preload.swf" );

		if( args.movie )

		{

			fo.addVariable( "csFilesetBookmark", args.movie );

		}

		fo.write("popup_content");

        document.getElementById("popup_content").innerHTML = '<div style=\"position:absolute; top:5px; left:0; width:100%; text-align:center;\">This video tour is for Dolphin 6.0. The new version is even more advanced and exciting.</div>' + document.getElementById("popup_content").innerHTML;

		return;

	}

    h += 100;

    w += 100*1.762;

    setTimeout ("popupShowTimerD6("+w+","+h+")", 10);

}



function popupShowTimerString(s, w, h, wmax, hmax)

{

    if (popupResize(w, h, wmax, hmax)) 

	{

        $('#popup_content').html (s);

		return;

	}

    h += 100;

    w += 100*1.762;

    setTimeout ("popupShowTimerString('" + s + "', " + w + ", " + h + ", " + wmax + ", " + hmax + ")", 10);

}



function popupShowTimerSel(sel, w, h)

{

    if (popupResize(w, h)) 

	{

        $('#popup_content').html ($(sel).html());

		return;

	}

    h += 100;

    w += 100*1.762;

    setTimeout ("popupShowTimerSel('"+sel+"',"+w+","+h+")", 10);

}



function popupShowTimerSpunky(w, h)

{

    if (popupResize(w, h, 200, 114)) 

	{

		document.getElementById("popup_content").innerHTML = "Every major release of Dolphin has a code-name same as a real name of a real dolphin BoonEx adopts through <a href=\"https://secure.wdcs.org.au/secure/adopt_a_dolphin.php\">WDSC dolphin adoption program</a>. Dolphin 6.0 code-name is \"Lightning\", and 6.1 is \"Spunky\".";

		return;

	}

    h += 20;

    w += 20*1.762;

    setTimeout ("popupShowTimerSpunky("+w+","+h+")", 10);

}



function popupShowTimer(w, h)

{

    if (popupResize(w, h)) 

	{



		var fo = new SWFObject( "/img/tours/ray/ray3tour_controller.swf", "/img/tours/ray/ray3tour_controller.swf", "850", "500", "8", "#FFFFFF", false, "best");

		fo.addVariable( "csConfigFile", "/img/tours/ray/ray3tour_config.xml"  ); 

		fo.addVariable( "csColor"     , "FFFFFF"           );

		fo.addVariable( "csPreloader" , "/img/tours/ray/ray3tour_preload.swf" );

		if( args.movie )

		{

			fo.addVariable( "csFilesetBookmark", args.movie );

		}

		fo.write("popup_content");

        document.getElementById("popup_content").innerHTML = '<div style=\"position:absolute; top:5px; left:0; width:100%; text-align:center;\">This video tour is for Ray 3.1. The new version is even more advanced and exciting.</div>' + document.getElementById("popup_content").innerHTML;

		return;

	}

    h += 100;

    w += 100*1.762;

    setTimeout ("popupShowTimer("+w+","+h+")", 10);

}



function popupHide()

{

    document.getElementById('popup_movie_align').style.display='none';

    document.getElementById('popup_content').innerHTML = '';

}



function getScroll()

{

	return navigator.appName == "Microsoft Internet Explorer" ? document.documentElement.scrollTop : window.pageYOffset;

}

