/* Initialize Examples Slider */


$(document).ready(function(){
	$('.sliderExamples').advancedSlider({width:368, height:207, effectType:'simpleSlide', pauseSlideshowOnHover:true, timerAnimation:false, hideCaption:true, effectType:'random', captionHideEffect:'slide', shadow:false, shuffle:true, navigationButtons:false, captionSize:35, slideshowDelay:15000, navigationArrows:false});
});




/* Initialize Sentences Slider */


$(document).ready(function(){
	$('.sliderSentences').advancedSlider({width:450, height:225, effectType:'fade', slideshowControls:false, navigationArrows:false, shadow:false, shuffle:false, timerAnimation:false, navigationButtons:false, slideshowDelay:9000, verticalSlices:1});
});




/* Initialize Page Navigation Slider


var sliderNav

$(document).ready(function(){
sliderNav = $('.sliderNav').advancedSlider({width:900, height:330, effectType:'simpleSlide', shadow:false, slideshow:false, slideshowControls:false, timerAnimation:false, navigationButtons:false, transitionComplete:onTransitionComplete});
});

function gotoPage(page) {
sliderNav.gotoSlide(page);
}

function onTransitionComplete (obj) {
$("a").removeClass("currentPage");
var pageNumber = "page" + obj.index;
$("#page"+obj.index).addClass("currentPage");
}
*/










//SOUND & SPLASH SCREEN
$(document).ready( function() {
	/*
	soundHandle = document.getElementById('soundHandle');
	soundHandle.src = "sounds/splash.wav";
	$('.splash').delay(200);
	soundHandle.play();
	*/
	$('.splash').animate({backgroundColor: "white"}, 100, 'easeInExpo').delay(150).animate({backgroundColor: "black"}, 800, 'easeOutCirc');	
	$('.splash').delay(150).fadeOut(1400, function() {
		$(this).remove();
		} );
});


//PAGES NAVIGATOR

//Display controls on hover over navigator
$("#boxNav").mouseenter(
	function() {
		$(".control").css("opacity","0.6");
	}
);
$("#boxNav").mouseleave(
	function() {
		$(".control").animate({opacity: "0"}, 100)
	}
);


//Opacify controls on hover over them
$(".control").hover(
	function() {
		$(this).css("opacity", "1")
	},
	function() {
		$(this).css("opacity", "0.6")
	}
);


//Check Flash Player : Restart when entering page/Stop when going out
var flashElement = document.getElementById('flashContainer');

function checkFlashPlayer(fromPage, toPage) {
	if (fromPage == 0) {
		jwplayer().stop();
	}
	else if (toPage == 0) {
		jwplayer().play(true);
	}
}


//Page Changing
curPage = 0;
maxPage = $('.page').length-1;

function goToPage(nb) {
	if (nb < 0) {
		goToPage(maxPage);
	}
	else if (nb > maxPage) {
		goToPage(0);
	}
	else {
		checkFlashPlayer(curPage,nb);
		curPage = nb;
		$('#pagesWrapper').animate({left: nb*(-900)+"px"}, 300, "easeInOutCirc");
		menuUpdate(nb);
	}
}

//Navigate Back
$(".control").click(
	function() {
		switch ($(this).attr("id")) {
			case "arrowLeft":
			goToPage(curPage-1);
			break;
			case "arrowRight":
			goToPage(curPage+1);
		}
	}
);

//Change Menu on Page Change
function menuUpdate(nextPage) {
	$('li[class*="currentPage"]').removeClass('currentPage');
	$('.p'+nextPage).addClass('currentPage');
}
//END PAGES NAVIGATOR


//WHAT WE DO
//Hover On Arena -> Display Hidden Text
$(".withHover").hover(
	function () {
		$(this).find('ul').css("visibility", "visible")
	},
	function () {
		$(this).find('ul').css("visibility", "hidden")
	}
);
//END WHAT WE DO



//NETWORK
$(".act").hover(
	function () {
		$(this).css("background-color", "#C33").css("color", "white")
	},
	function () {
		$(this).css("background-color", "rgba(204,51,51,0.7)").css("color", "#d5d5d5")
	}
);

$(".soon").hover(
	function () {
		$(this).css("background-color", "#999").css("color", "white")
	},
	function () {
		$(this).css("background-color", "rgba(153,153,153,0.7)").css("color", "#d5d5d5")
	}
);

$(".linked").hover(
	function() {
		$(this).css("z-index", "3").animate({fontSize: "15px"}, 100)
	},
	function() {
		$(this).animate({fontSize: "12px"}, 100, function() {$(this).css("z-index", "2")})
	})

	$(".linked").click(
		function () {
			var city = $(this).attr('id');
			Shadowbox.open({
				content: '<iframe src='+"offices/"+city+".html"+' width="522" height="234"/>',
				player: "html",
				title: "Office Contact",
				height: 240,
				width: 530
			});	
		});
		//END NETWORK

		



/* LOGO SWITCH 

function logoSwitch() {	
$('.boxLogo').delay(3080).animate({backgroundPosition: "76px"}, 400, 'swing').delay(3080).animate({backgroundPosition: "0px"}, 400, 'swing');
setTimeout("logoSwitch()",0);
}
logoSwitch();

*/


/* LOGO ROTATION */

var startWidth = $('#logo').css('width');
function logoRotation() {
	$('#logo').delay(7000).animate({width: "0px"}, 400, function() {
		$(this).attr("src", "images/logoFullRed.png");
	});
	$('#logo').animate({width: startWidth}, 400);
	$('#logo').delay(7000).animate({width: "0px"}, 400, function() {
		$(this).attr("src", "images/logoShapeWhite.png");
	});
	$('#logo').animate({width: startWidth}, 400);
	setTimeout("logoRotation()",0);
}
logoRotation();




/* SHADOWBOX VIDEOS FUNCTIONS */


var vpath = 'vids/';

var titleShowcases = "Snapshot of long term global entertainment marketing strategy&#8230;";
var titleClips = "";

	function openYouTube(videoID) {
		Shadowbox.open({
			content:    '<iframe height="100%" width="100%" src="http://www.youtube.com/v/'+videoID+'"/>',
			player:     "html"
		})
	}
	
	
	function openVideo(videoURL,wdth,hght,boxTitle) {
		Shadowbox.open({
			content:    videoURL,
			player:     "flv",
			title:      boxTitle, 
			height:     hght,
			width:      wdth,
			overlayOpacity: 1,
			"logo.file": ""
			/*"logo.file": "images/watermark_player.png",
			"logo.hide": false,
			"logo.position": "top-left",
			"logo.margin": 10*/
		})
	}

/*END SHADOWBOX VIDEOS FUNCTIONS*/


/* CLIPS FUNCTIONS */
	
	function switchClip(clip) {
		switch(clip) {
			case "cobraS":
				openVideo(vpath+'Cobra_Starship-YouMakeMeFeel.f4v',640,360,titleClips);
				break;
			case "colbieC":
				openVideo(vpath+'Colbie_Caillat-Brighter.f4v',640,360,titleClips);
				break;
			case "darkKnight":
				openVideo(vpath+'darkKnight.f4v',640,360,titleClips);
				break;
			case "eminem":
				openVideo(vpath+'Eminem-We.f4v',640,360,titleClips);
				break;
			case "house":
				openVideo(vpath+'house-casio.f4v',640,360,titleClips);
				break;
			case "jessicaA":
				openVideo(vpath+'jAlba-piaget.f4v',640,512,titleClips);
				break;
			case "ladyG":
				openVideo(vpath+'ladyGaga-BadRomance.f4v',640,360,titleClips);
				break;
			case "dieHard":
				openVideo(vpath+'diehard4-rimowa.f4v',640,360,titleClips);
				break;
			case "mi4":
				openVideo(vpath+'mi_gp_bmw.f4v',640,512,titleClips);
				break;
			case "nicoleS":
				openVideo(vpath+'NicoleScherzinger-Poison.f4v',640,360,titleClips);
				break;
			case "nipTuck":
				openVideo(vpath+'niptuck-bo.f4v',640,360,titleClips);
				break;
			case "topSpin":
				openVideo(vpath+'topspin3.f4v',640,360,titleClips);
				break;
			case "travie":
				openVideo(vpath+'travie-billionaire.f4v',640,512,titleClips);
				break;
			case "tron":
				openVideo(vpath+'tron.f4v',640,512,titleClips);
				break;
			case "wallStreet":
				openVideo(vpath+'wallStreet2.f4v',640,360,titleClips);
				break;
			case "wif":
				openVideo(vpath+'wif-pandora.f4v',640,512,titleClips);
				break;
			}
	}	
	
	
	
	$('#clips td').click(function() {
		var clip = $(this).attr("class");
		switchClip(clip);
	});
	
	$('#clips th').click(function() {
		var clip = $(this).attr("class");
		switchClip(clip);		
	});
	
/* END CLIPS FUNCTIONS */
	
	
/* SHOWCASES FUNCTIONS */

function switchShowcase(showcase) {
	switch(showcase) {
		case "showcase0":
			openVideo(vpath+'showcases/carrera_640x426.f4v',640,426,titleShowcases);
			break;
		case "showcase1":
			openVideo(vpath+'showcases/tron_640x448.f4v',640,448,titleShowcases);
			break;
		case "showcase2":
			openVideo(vpath+'showcases/spirit_600x480.f4v',600,480,titleShowcases);
			break;
		case "showcase3":
			openVideo(vpath+'showcases/connectedDrive_640x384.f4v',640,384,titleShowcases);
			break;
		}
	}
	
	
	
	$('#showcases table').hover(
		function() {
			$(this).find('img').css("visibility", "hidden");
		},
		function() {
			$(this).find('img').css("visibility", "visible");
		}
	);
	
	$('#showcases table').click(function() {
		var showcase = $(this).attr("id");
		switchShowcase(showcase);
	});
	
	$('#showcases table').click(function() {
		var showcase = $(this).attr("id");
		switchShowcase(showcase);		
	});
	
	/*
	$('#showcases table').hover(
		function() {
			$(this).find('.nohover').removeClass('nohover').addClass('hover');
		},
		function() {
			$(this).find('.hover').removeClass('hover').addClass('nohover');
		}
	);
	*/
	
/* END SHOWCASES FUNCTIONS */
	
	


