/*
 * Fray'z
 * 2008
 */

$(document).ready(function()
{

	if($("#switcher")[0]){
	$("#switcher").click(function() {
			$("#topbn").toggle();
			$("#topbanner").toggle();
			$(".switcher_span").toggleClass("closed");
			$.getJSON("/adv_info.php", {action: 'close'});
	});
	}

	if($(".mbutton_toggle")[0]){
	$(".mbutton_toggle").click(function() {

			$(this).parent().parent().find(".menu_box_unit_c").toggle();
			$(this).toggleClass("rbutton_up");
			$(this).toggleClass("rbutton_down");

			$(this).parent().parent().toggleClass("menu_box_unit_closed");
			$(this).parent().parent().find(".menu_box_unit_b").toggle();
	});
	}

	if($(".rtext")[0]){
	$(".rtext").click(function() {

			$(this).parent().parent().find(".r_panel_box_unit_c").toggle();
			$(this).parent().find(".rbutton_toggle").toggleClass("rbutton_up");
			$(this).parent().find(".rbutton_toggle").toggleClass("rbutton_down");

			$(this).parent().parent().toggleClass("r_panel_box_unit_closed");
	});
	}

	if($(".rbutton_toggle")[0]){
	$(".rbutton_toggle").click(function() {

			$(this).parent().parent().find(".r_panel_box_unit_c").toggle();
			$(this).toggleClass("rbutton_up");
			$(this).toggleClass("rbutton_down");

			$(this).parent().parent().toggleClass("r_panel_box_unit_closed");
	});
	}

	if($(".cbutton_toggle")[0]){
	$(".cbutton_toggle").click(function() {

			$(this).parent().parent().find(".led").toggleClass("led_closed");
			$(this).parent().parent().find("#column_adv_u").toggleClass("column_adv_u_closed");
			$(this).parent().parent().find(".column_adv_header").toggle();
			$(this).parent().parent().find(".column_adv_content_text").toggle();
			$(this).parent().parent().toggleClass("column_adv_closed");
	})
	}

	if($("tr")[0]){
	$("tr:nth-child(odd)").addClass("oddrow");
	}

	if($("#topline")[0]){
		$("#topline").scrollable({

		size:5,
        interval: 10000,
        loop: true,
        //speed: 600,
		speed: 1,
		keyboard: false,
		easing:	'swing',
		hoverClass: 'topline_hov'
        //onBeforeSeek: function() {
		//	if(!jQuery.browser.msie)
        //    	this.getItems().fadeTo(500, 0.5);
        //},
        //onSeek: function() {
        //    if(!jQuery.browser.msie)
		//		this.getItems().fadeTo(500, 1);
        //}
    	}).unmousewheel();

	}

		var mainplayer_settings = {

		key: '@f862a6188dc6644e225',

		logo:
			{
				url: 'http://gameslife.ru/pics/player_logo.png',
        		fullscreenOnly: false,
				top: 8,
				right:5,
				linkUrl: 'http://gameslife.ru'
			},

		//onMouseOver: function() {
			//if(this.getClip().isInStream){
			//if(this.getClip().completeUrl=="http://gameslife.ru/video/skorost_online_preroll_final.flv"){
        //    	this.getPlugin("content").css({backgroundImage: 'http://gameslife.ru/pics/skorost_player.png'}).fadeIn(500)
			//}
    	//},

    	//onMouseOut: function() {
		//		this.getPlugin("content").fadeOut(500)
    	//},

     	clip:
	   		{
				scaling:'fit',

        		onStart: function(clip) {
            		google._trackEvent("Videos", "Play", clip.url)
        		},

        		onFinish: function(clip) {
          		  	google._trackEvent("Videos", "Finish", clip.url)
        		}
				//,

				//playlist:
				//	[
        		//		{
				//			url: 'http://gameslife.ru/video/posilka.flv',
				//	 		position: 0,
				//			autoBuffering: true,

				//			controls: {
                //   			enabled: {scrubber: false}
                //			}
				//		}
		        //	]

				//onCuepoint: [[
            	//	{time: 1000, image: 'http://gameslife.ru/pics/player_logo.png', url: 'http://zzima.com/so'}
        		//],

        			// the function that makes those ads visible
        		//	function(clip, ad) {

            			// get a handle to the content plugin
            	//		var p = this.getPlugin("content");

            			// change it's background image and gradually show it in 1000 seconds
            	//		p.css({backgroundImage: ad.image}).fadeIn(1000);

            			// set plugin's adUrl property to be used in it's onClick handler
            	//		p.adUrl = ad.url;

            			// gradually hide the plugin after 4 seconds
            	//		setTimeout(function() { p.fadeOut(1000); }, 4000);
        		//}]

			},

			//onStart: function(clip) {
        		//$(".player_panel").expose({color:"#000", zIndex:2000});
    		//},

			//onResume: function(clip) {
        		//$(".player_panel").expose({color:"#000", zIndex:2000});
    		//},

			//onStop: function(clip) {
        		//$.expose.close();
    		//},

			//onPause: function(clip) {
        		//$.expose.close();
    		//},

			//onFinish: function(clip) {
        		//$.expose.close();
    		//},

	   canvas:
	   		{
				backgroundColor: '#000000',
				backgroundGradient: 'none'
			},

	   play: {
	   		opacity: 1,
            label: null,
            replayLabel: 'Åù¸ ðàç'
    	},

		plugins:  {
        controls: {

			url: 'http://gameslife.ru/flowplayer/flowplayer.controls-skinless-3.1.1.swf', skin: 'customskin',

            fullscreen:true,
            backgroundGradient: 'none',
			backgroundColor: 'transparent',

			border: 'none',

            all:false,
            scrubber:true,
			volume:true,
            play:true,
            mute:true,
			playlist:false,

            height: 30,

            autoHide: 'always',

            bottom: 5,
            left: '50%'

        },
		customskin: { url: "http://gameslife.ru/flowplayer/gameslife_buttons.swf", type: "classLibrary" }
		//,

		//content: {
        // 	url: 'http://gameslife.ru/flowplayer/flowplayer.content-3.1.0.swf',
   // 	url: 'http://gameslife.ru/flowplayer/flowplayer.content-3.1.0.swf',

         	// plugin is initially hidden
        // 	display: 'none',

         	// no background and decorations
        // 	backgroundGradient: 'none', backgroundColor: 'transparent', border: 0,

         	// position and dimensions
        // 	top: 15, left: 12,  width: 158, height: 30,

         	// click on the image goes to certain place
        // 	onClick: function() {
		//		window.open ('http://gameslife.ru/link.php?addr=http%3A%2F%2Fwww.zzima.com%2F%3Fref%3D065601%26redirect%3Dso%2F');
        // 	}
      	//}
       }

	};

	var player_settings = {

	key: '@f862a6188dc6644e225',

     clip:
	   		{
				scaling:'fit',
				autoPlay: true,
				autoBuffering: false,

				onStart: function(clip) {
            		google._trackEvent("Videos", "Play", clip.url)
        		},

        		onFinish: function(clip) {
          		  	google._trackEvent("Videos", "Finish", clip.url)
        		}

				//,

				//playlist:
				//	[
        		//		{
				//			url: 'http://gameslife.ru/video/posilka.flv',
				//	 		position: 0,
				//			autoBuffering: true,

				//			controls: {
                //   			enabled: {scrubber: false}
                //			}
				//		}
		        //	]
			},

	   canvas:
	   		{
				backgroundColor: '#000000',
				backgroundGradient: 'none'
			},

	   play: {
	   		opacity: 1,
            label: null,
            replayLabel: 'Åù¸ ðàç'
       },

	   plugins:  {
        controls: {

			url: 'http://gameslife.ru/flowplayer/flowplayer.controls-skinless-3.1.1.swf', skin: 'customskin',

            fullscreen:true,
            backgroundGradient: 'none',
			backgroundColor: 'transparent',

			border: 'none',

            all:false,
            scrubber:true,
			volume:true,
            play:true,
            mute:true,
			playlist:false,

            height: 30,

            autoHide: 'always',

            bottom: 5,
            left: '50%'

        },
		customskin: { url: "http://gameslife.ru/flowplayer/gameslife_buttons.swf", type: "classLibrary" }
       }

	};

	if($("#player1")[0]){

		$(".playlist").scrollable({size: 3,vertical:true,next:'a.down',prev:'a.up'});

		$(".clips a").click(function() {
        	$(this).fadeOut().fadeIn();
    	});

		$f("player1", {src: "http://gameslife.ru/flowplayer/flowplayer.commercial-3.1.1.swf", wmode: 'opaque'},  mainplayer_settings).playlist("div.mainplayer", {scaling:'fit', loop:false});

	}

	if($("a.player_centered")[0]){
		$f("a.player_centered", "http://gameslife.ru/flowplayer/flowplayer.commercial-3.1.1.swf", player_settings);
		$(".player_centered").show();
	}
});