var zW = jQuery;
var zWM = $;

zW('document').ready( function () {
   zW ('#acc1').accordion ({change: function(event, ui) { onChange (zW('#acc1').accordion ("option", "active")) }});
   goMap24();
//    goPlayer();
});

function onChange (idx) {
   if (idx == 4) { goPlayer ()} else {goMap24 ()};
}

function goMap24() {
   //Load core API and wrapper classes
   Map24.loadApi( ["core_api", "wrapper_api"] , map24ApiLoaded );
}

//Center the map view on the given map coordinates. The MinimumWidth parameter
//defines the minimal width of the new map view in meters.
function centerOnCoordinate() {
   Map24.MapApplication.center( {Longitude:442.052978515625, Latitude:2954.55859375, MinimumWidth: 5000} );
}

//If function name was defined in the loadApi() function,
//this function is called when the API was loaded
function map24ApiLoaded(){
   //Initialize mapping client
   Map24.MapApplication.init( { NodeName: "maparea" } );
   centerOnCoordinate();
}

function goPlayer () {
   var playlist = 'http://sopcast.dyndns.tv/werbung.flv';
   playerOne = new FAVideo("maparea", playlist, 700, 500,{ autoLoad:true, autoPlay:true, skinAutoHide: true,clickToTogglePlay: false });
   playerOne.addEventListener("playheadUpdate",this,myHandler);
   playerOne.addEventListener("complete",this,onComplete);

//    playerOne.removeEventListener("playheadUpdate",this,myHandler);
}

function show_wait (container, style_class) {
   zW (container).html ('<p class="' + style_class + '"><img src="gif/ajax-loader.gif" title="Bitte warten" alt="Bitte warten" /></p>');
}

function login_submit (p) {
   show_wait ('#user_login', 'login_wait');
   zW.ajax ({
      type: "POST",
      url: "login.php",
      data: "passwd=" + p.passwd.value + "&user=" + p.user.value,
      success: function (data) { zW('#user_login').html (data); }
   });
}

function myHandler() {
}

function onComplete() {
//    console.dir (playerOne);
   playerOne.videoPath = 'http://sopcast.dyndns.tv/1220947160.BB05-09-08.wmv.flv';
//    playerOne.videoPath = 'http://sopcast.dyndns.tv/Album2009.flv';
   playerOne.load ();
   playerOne.play ();
}

function file_upload () {
   var swf_upload = new Swiff.Uploader ({
                        upload_url: "scripts/php/upload.php",
                        flash_url: "scripts/upload/Swiff.Uploader.swf",
                        file_size_limit: "5 GB"
                    });
//    console.dir (swf_upload);
}

