/** global vars **/
var WIN_WIDTH = 0;
var WIN_HEIGHT = 0;


var init = function () {	
	
	/** content layer pos **/
	$('#content-slider')
		.children('li')
		.each(function(index, element) {
            $(this).css({'left':(100*index)+'%', 'display':'block'});
        });


	ph.init();
	gallery.init();
	
	/** bind window resize**/
	$(window)
		.resize(onWindowResize)
		.mousemove(function (e) {e.preventDefault();});
	onWindowResize();
	
	
	/** init objects **/
	events.init();
	/** init objects end **/
	
	
	/** add scollers **/
	$('.scoller, .scroller')
		.moveScroller();
	


	/** new trigger **/
	$('#start-news')
		.find('a')
		.click(function () {
			var config = $.extend(fancyboxDefaults,{href:'templates/news_detail.php',type:'ajax'});
			$.fancybox(config);
		})

	
	/** location hover effect**/
	$('.area-glosy')
		.hover (function () {
				$(this).parent().find('.location-hover').stop().animate({backgroundPosition:'0 0'},300);
				$(this).parent().find('img').animate({opacity:1},500);
			},
			function () {
				$(this).parent().find('.location-hover').stop().animate({backgroundPosition:'0 -135'},300);
				$(this).parent().find('img').animate({opacity:0},500);
				});
	
	
	$('#location-vip')
		.hover(function () {
			$(this).find('.container-content > img').animate({opacity:1},500);
			}, function () {
				$(this).find('.container-content > img').animate({opacity:0},500);
				});
	
	
	$('#fb-login').hover(function () {
		$(this).stop().animate({top:0, left:0},300);
		}, function () {
			$(this).stop().animate({top:-78, left:-115},300);
			});
			
	$('#fb-login-pannel').load('fb-ceck-login.php');


	/** bind hover layers **/
	$('.hover-layer').closest('.container').hover (function () {
			$(this).find('.hover-layer').stop().css('display','block').fadeTo(500,1);
		}, function () {
			$(this).find('.hover-layer').stop().fadeTo(500,0, function () {
				$(this).css('display','none');
				});
			});
	
	//init facebook
	fb.init();
	
	
	delete init;	
}
$(document).ready(init);






function onWindowResize () {
	$win = $(window);
	
	/** set window width / height */
	WIN_WIDTH = $win.width();
	WIN_HEIGHT = $win.height();
	
	
	ph.onResize();
}



var initFB = function () {
	FB.init({
		appId   : '162685450503256',
		status     : true, 
		cookie     : true, 
		oauth      : true,
		xfbml      : true 
	});                 
				 
	FB.Event.subscribe('auth.statusChange', function() {
		$('#fb-login-pannel').load('fb-ceck-login.php');
	});	
}
$(window).ready(initFB);



var fancyboxDefaults = {
	autoDimensions:false,
	autoScale:false,
	padding:5,
	margin:5,
	width:800,
	height:'auto'
}




var MAP = {
	map:null,
	
	init:function () {
		if (MAP.map == null) {

			  var stylez = [
					  {
						featureType: "landscape",
						elementType: "all",
						stylers: [
						  { hue:'#000000' },
						  { saturation: -100 },
						  { lightness: -10 }
						]
					  },{
						featureType: "water",
						elementType: "all",
						stylers: [
						  { saturation: -100 },
						  { lightness: -30 }
						]
					  },{
						featureType: "administrative",
						elementType: "labels",
						stylers: [
						  { hue: "#ffffff" },
						  { saturation: 0 },
						  { lightness: 0 }
						]
					  },{
						featureType: "poi",
						elementType: "all",
						stylers: [
						  { lightness: 0 },
						  { visibility: "off" }
						]
					  },{
						featureType: "landscape",
						elementType: "all",
						stylers: [
						  { visibility: "off" }
						]
					  },{
						featureType: "water",
						elementType: "labels",
						stylers: [
						  { lightness: 0 },
						  { visibility: "off" }
						]
					  },{
						featureType: "road",
						elementType: "labels",
						stylers: [
						  { visibility: "on" },
						  { hue: "#6B7DC7" },
						  { saturation: -30 },
						  { lightness: 0 }						  
						]
					  },{
						featureType: "administrative",
						elementType: "geometry",
						stylers: [
						  { visibility: "simplified" }
						]
					  },{
						featureType: "road.highway",
						elementType: "geometry",
						stylers: [
						  { saturation: -100 }
						]
					  },{
						featureType: "road.arterial",
						elementType: "geometry",
						stylers: [
						  { saturation: -100 }
						]
					  },{
						featureType: "road.local",
						elementType: "geometry",
						stylers: [
						  { saturation: -100 },
						  { lightness: 0 }
						]
					  },{
						featureType: "transit",
						elementType: "all",
						stylers: [
						  { visibility: "off" }
						]
					  }
					];



			var latlng = new google.maps.LatLng(51.9638355, 6.9811615);
		
		  var mapOptions = {
			zoom: 13,
			center: latlng,
			mapTypeControlOptions: {
			   mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'RIO']
			}
		  };
		  
		MAP.map = new google.maps.Map(document.getElementById("map-embed"), mapOptions);
		
		  var styledMapOptions = {
			  name: "RIO"
		  }
		
		  var jayzMapType = new google.maps.StyledMapType(
			  stylez, styledMapOptions);
		
		  MAP.map.mapTypes.set('RIO', jayzMapType);
		  MAP.map.setMapTypeId('RIO');


		var marker = new google.maps.Marker({
			position: latlng, 
			map: MAP.map, 
			title:"RIO"
			});   
		  
		  
		}
	}	
}


function updateTrackName (name) {$('#trackname').html(name);}
var playerPlay = true;
function togglePlayer (elem) {
	if (playerPlay == true) {
		playerPlay = false;
		stopMusicplayer();
		$(elem).children('img').attr('src','images/player_stop.png');	
	}else{
		playerPlay = true;
		startMusicplayer();
		$(elem).children('img').attr('src','images/player_play.png');
	}	
}
function startMusicplayer () { 
	try {swfobject.getObjectById("eq_object").startSound()}catch (e) {}
	playerPlay = true;
	$('#playerToggle').children('img').attr('src','images/player_play.png');
}
function stopMusicplayer (){ 
	try {swfobject.getObjectById("eq_object").stopSound()}catch (e) {} 
	playerPlay = false;
	$('#playerToggle').children('img').attr('src','images/player_stop.png');
}
function nextTrack (){ try {swfobject.getObjectById("eq_object").nextTrack()}catch (e) {} }
function prevTrack (){ try {swfobject.getObjectById("eq_object").prevTrack()}catch (e) {} }
