// list available movies here
//default - var movies = new Array('avaf', 'avaf2', 'saak', 'pelin');
var movies = new Array('saak', 'pelin', 'plankton', 'bush', 'LHC', 'obama');

// the path to our flash, 
// don't forget the ending slash!
// (chorus)
// la-la-la, la-la-la,
// don't forget the slash!
var path = '/s/roleg/';

var img_width = 180;
var img_height = 135;

var movie_name;
var window_width;
var window_height;
var scroll_offset;

div_name = 'movie_preview';
prev_name = 'preview_placeholder';
large_swf_div = 'movie_popup';
movie_div = 'movie_placeholder';

var flashparams1 = {
	  allowscriptaccess: "always",
	  wmode: "opaque"
};
var flashparams2 = {
	  allowscriptaccess: "always",
	  wmode: "transparent"
};
var flashvars = {};

function run_random() {
	num = Math.floor(Math.random()*movies.length);
	movie_name = movies[num];
	small_swf_init();
}

function movie_init() {
	//swfobject.embedSWF('control.swf', prev_name, img_width, img_height, "6.0.0", "expressInstall.swf", flashvars, flashparams1);
	if (el = document.getElementById(div_name)){

	el.innerHTML = '<div id="preview_placeholder"><img src="' + path + 'clickme.gif" width="' + img_width + '" height="' + img_height + '" alt="Click me!" style="cursor:pointer;" /></div>';
	el.onclick = function() { run_random(); }
	}
}

function small_swf_init() {
	swfobject.embedSWF(path + movie_name + '.swf', prev_name, img_width, img_height, "6.0.0", "expressInstall.swf", flashvars, flashparams1);
}

function last_frame_show() {
	el = document.getElementById(div_name);
	if (el) {el.innerHTML = '<div id="preview_placeholder"><img src="' + path + movie_name + '_lastframe.gif" width="' + img_width + '" height="' + img_height + '" alt="" /></div>'}
}

function large_swf_show() {
	//last_frame_show();	
	get_window_dimensions();
	get_scroll_offset();
	el = document.getElementById(large_swf_div);	
	
	// trying to set the div 100% in size
	//el.style.width = '100%';
	//el.style.height = '100%';
	//swfobject.embedSWF(movie_name + '_large.swf', movie_div, '100%', '100%', "6.0.0", "expressInstall.swf", flashvars, flashparams2);
	
	//What the fuck о_О? 6-th Osleg doesn't like this :()
    el.style.top = scroll_offset + 'px';
	
  // setting the div size to abs. X&Y values
	el.style.width = window_width - 1;
	el.style.height = window_height - 1;
	//el.style.zIndex=100;
	swfobject.embedSWF(path + movie_name + '_large.swf', movie_div, window_width, window_height, "6.0.0", "expressInstall.swf", flashvars, flashparams2);
	
	el.style.display = 'block';
	
	toggleAll('div.embed_video');
	toggleAll('div.bigpic');

}



function large_swf_hide() {
	el = document.getElementById(large_swf_div);
	el.style.display = 'none';
	toggleAll('div.embed_video');
	toggleAll('div.bigpic');
	if ($('embed_onairvideo')){onair_reload()}
	movie_init();
}

function get_window_dimensions() {
	if (typeof window.innerWidth != 'undefined') {
		// browsers for human beings (standarts-compliant)
		window_width = window.innerWidth,
		window_height = window.innerHeight
	} else if (typeof document.documentElement != 'undefined' && typeof document.documentElement.clientWidth != 'undefined' && document.documentElement.clientWidth != 0) {
		// the browser for M$ customers (IE6)
		window_width = document.documentElement.clientWidth,
		window_height = document.documentElement.clientHeight
	} else {
		// older versions of IE
		window_width = document.getElementsByTagName('body')[0].clientWidth,
		window_height = document.getElementsByTagName('body')[0].clientHeight
	}
}

function get_scroll_offset() {
  if( typeof( window.pageYOffset ) == 'number' ) {
    //Netscape compliant
    scroll_offset = window.pageYOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    //DOM compliant
    scroll_offset = document.body.scrollTop;
  } else {
    // last f@$#ing resort
    scroll_offset = document.documentElement.scrollTop;
  }
}

