var preloaded = new Array();
function preload_images() {
    for (var i = 0; i < arguments.length; i++){
        preloaded[i] = document.createElement('img');
        preloaded[i].setAttribute('src',arguments[i]);
    };
};

playerstate = 0;

/*
preload_images(
    '/css/cssimg/item_listing/vli_top.gif',
    '/css/cssimg/item_listing/vli_bottom.gif',
    '/css/cssimg/item_listing/vli_active_top.gif',
    '/css/cssimg/item_listing/vli_active_bottom.gif',
    '/css/cssimg/main_layout/plasma_box_gallery_top_demon.gif'
);
*/

function sh( elem, display )
{
	var elemObj = document.getElementById( elem );		
	if ( elemObj ) elemObj.style.display = display;
}

function op( divnum )
{

	if ( divnum >= work.samples.length ) {
		divnum = (work.samples.length - 1);
	} else if ( divnum < 0 ) {
		divnum = 0;
	} else {
		divnum = divnum;	
	}
	
	var optitle = document.getElementById("optitle");		
	var opsubtitle = document.getElementById("opsubtitle");				
	var oparrow = document.getElementById("oparrow");				
	
	optitle.innerHTML = work.samples[divnum].title;
	opsubtitle.innerHTML = work.samples[divnum].subtitle;		
	oparrow.style.display = ( divnum == 0 )?"":"none";
	
	
	for ( var i=0; i<8; i++ ) {	// hide all
		sh( "op"+i.toString(), "none" );
	}
	
	sh( "op"+divnum.toString(), "" );
	
	ws_current = divnum;	
	ws_counter( divnum );	
}

function ws( wsnum )
{
	sendEvent('jsradio','stop'); 
	if ( document.movie1 ) { 
		try { document.movie1.Stop(); } catch(err) {};
	}
	
	var wslink = document.getElementById("ws_link");			
	var img = document.getElementById("ws_image");	
	var imgtitle = document.getElementById("ws_title");		
	var maincontent = document.getElementById("maincontent");

	if ( maincontent ) {			// clear all specified media divs and reset the maincontent div
		for ( var s=0; s<work.samples.length; s++ ) {
			if ( work.samples[s].div ) {
				var mediadiv = document.getElementById( work.samples[s].div );	
				mediadiv.style.display = "none";
			}
		}
		maincontent.style.display = "";
	}

	if ( wsnum >= work.samples.length ) {
		wsnum = (work.samples.length - 1);
	} else if ( wsnum < 0 ) {
		wsnum = 0;
	} else {
		wsnum = wsnum;	
	}
			
	//ws_current = ( wsnum >= work.samples.length || wsnum < 0 ) ? 0 : wsnum;
	//if ( wsnum > work.samples.length || wsnum < 0 ) {
	//	return;
	//}
	
	ws_current = wsnum;
	
	img.src = work.samples[ws_current].image;
	imgtitle.innerHTML = work.samples[ws_current].title;

	if ( work.samples[ws_current].link ) { 
		wslink.innerHTML = "<a href=\"" + work.samples[ws_current].link[0].linkurl + "\" target=\"_blank\">" + work.samples[ws_current].link[0].linktitle + "</a>";
	} else {
		wslink.innerHTML = " ";
	}

	if ( work.samples[ws_current].div ) {

		var mediadiv = document.getElementById( work.samples[ws_current].div );	
		maincontent.style.display = "none";
		mediadiv.style.display = "";		
	}

	
	ws_counter( wsnum );
}

function ws_counter( wsnum )
{
	for( var i=0 ;i<15; i++ ) {
		var current = document.getElementById("wsc"+i.toString());					
		if ( current ) {
			current.style.backgroundColor = ( i == wsnum ) ? "#00457C":"#58595B";
		} else {
			
		}
	}
	
}

function ma( wsnum )
{
	var maincontent = document.getElementById("ma_cbase");
	var sevencontent = document.getElementById("ma_cextra");	
	
	if ( wsnum >= 0 && wsnum <= 5 ) {
		maincontent.style.display = "";
		sevencontent.style.display = "none";		
	} else if ( wsnum == 6 ) {
		maincontent.style.display = "none";
		sevencontent.style.display = "";		
	}
	
	var img = document.getElementById("ws_image");	
	var imgtitle = document.getElementById("ma_title");		
	var desc = document.getElementById("ma_desc");
	
	if ( wsnum >= work.samples.length ) {
		ws_current = (work.samples.length - 1);
	} else if ( wsnum < 0 ) {
		ws_current = 0;
	} else {
		ws_current = wsnum;	
	}

	img.src = work.samples[ws_current].image;
	imgtitle.innerHTML = work.samples[ws_current].title;
	desc.innerHTML = work.samples[ws_current].description;
	
	ws_counter( ws_current );		
	
}


function sendEvent(swf,typ,prm) { 
//  if ( thisMovie(swf) ) {
	  try { 
	  	thisMovie(swf).sendEvent(typ,prm); 
	  } catch (err) { };
//  }
};

function getUpdate(typ,pr1,pr2,swf) { };

function thisMovie(swf) {
  if(navigator.appName.indexOf("Microsoft") != -1) {
    return window[swf];
  } else {
    return document[swf];
  }
};
