var ids = new Array('WhatsCorrsReallyLike','WhoWillIWorkWith','WhatSortofLaw','WhatClients','WhatWillIEarn','WhatHours','ProfessionalDevelopment','WhereCanITakeMyCareer','WhatAboutProBono','WhereIsCorrsHeaded','HowDoYouSupport', 'SarahSchnabel', 'NaomiLawry');

var titlesArray=new Array();
titlesArray['WhatsCorrsReallyLike']="Haley Aprile (Lawyer), Antoine Smiley (Lawyer), Tim Dobney (Lawyer)";
titlesArray['WhoWillIWorkWith']="<a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/JolleyBraddon'>Braddon Jolley</a> (Partner), <a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/MakSandy'>Sandy Mak</a> (Partner), James Shirbin (Lawyer), <br/>Nicole Graham (Lawyer)"; 
titlesArray['WhatSortofLaw']="";
titlesArray['WhatClients']=""; 
titlesArray['WhatWillIEarn']="Alexis Navie (National Human Resources Manager)";
titlesArray['WhatHours']=""; 
titlesArray['ProfessionalDevelopment']="Katy Andersen (Senior Associate), Karen Bennett (National People Development Manager), Mark Cessario (Senior Associate)";
titlesArray['WhereCanITakeMyCareer']="Chris Leong (Lawyer), <a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/SchnabelSarah'>Sarah Schnabel</a> (Senior Associate)"; 
titlesArray['WhatAboutProBono']="<a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/GostencnikVal'>Val Gostencnik</a> (National Pro Bono Partner)";
titlesArray['WhereIsCorrsHeaded']="John Denton (Partner and CEO)"; 
titlesArray['HowDoYouSupport']="<a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/HusbandBrad'>Brad Husband</a> (Partner), <a href='http://www.corrs.com.au/corrs/website/web.nsf/Content/LawrieNaomi'>Naomi Lawrie</a> (Partner) "; 


var selected = 'blank';
var section = 'main';
var readmorestate = "closed";
var clips = new Array();

var browser = ($.browser.msie && $.browser.version=="6.0")? 'ie6' : '';

for(x = 0; x < ids.length; x++)
{	
	clips[ids[x]] = $.flash.create(
	{
	  swf: 'swf/mediaplayer.swf',
	  width: 512,
	  height: 308,
	  params:
	  {
		allowfullscreen: true,
		loop: true,
		flashvars:
		{
		  width: 512,
		  height: 308,
		  file: '../flv/'+ids[x]+'.flv',
		  image: 'flv/'+ids[x]+'.jpg',
		  bufferlength: 10
		}
	  }
	});
};

var applyFlv = $.flash.create(
	{
	  swf: 'swf/mediaplayer.swf',
	  width: 626,
	  height: 414,
	  params:
	  {
		allowfullscreen: true,
		loop: true,
		flashvars:
		{
		  autostart:true,
		  shownavigation:false,
		  width: 626,
		  height: 414,
		  file: '../flv/HowDoIApply.flv',
		  image: 'flv/HowDoIApply.jpg',
		  bufferlength: 10,
		  screencolor:"0xffffff"
		}
	  }
	});

$(document).ready(function(){	

	var curid = '';
	var loadState = false;
	
		if(browser!='ie6')	$(".thumb-vid a").bind("mouseenter",function(){
	
		$('.orange', this).animate({ "top": '123px', "height": '5px' }, 50 );  
  
	}).bind("mouseleave",function(){

		$('.orange', this).animate({ "top": '128px', "height": '0px' }, 200 );  
  

	});



	/*///////	onClicks	///////*/

	
	$(".thumb-vid a").click(function(){
		
		curid = $(this).attr('id');
		if(!loadState&&curid!="HowDoIApply") loadMovie(curid);
	});

	
	$("#navLeft li a").click(function()
	{	
		if(section=="how") closePopup();	
		if(section=="apply"){
			if($(this).attr("id")=='apply') return false;		
			closeApply();
		};	
		if(section=="contact"){
			if($(this).attr("id")=='contact') return false;
			closeContact();	
		};

	});
	
	$("a#HowDoIApply").click(function()
	{
		openPopup();
		section = 'how';
	});



	$("a#readMore").click(function(event)
	{
		event.preventDefault();
		if(readmorestate=="closed"){
			readMoreOpen();
		};
	});

		function readMoreOpen(){

			$("a#watchVideo").removeClass("current");
			$("a#readMore").addClass("current");
			readmorestate = "open"; 
			$("#copy-"+curid).fadeIn();
		};

	$(".printBtn").click(function(event)
	{
	
		window.open("print.html?v="+curid);
		return false;

	});
	
	
	$("a#watchVideo").click(function(event)
	{
		event.preventDefault();
		if(readmorestate=="open"){ 
			readMoreClose();
		}
	});


		function readMoreClose(){
		
			$("a#readMore").removeClass("current");
			$("a#watchVideo").addClass("current");
			$("#copy-"+curid).fadeOut();
			readmorestate="closed";
		
		};

	$("a#btnClose").click(function(event){
		event.preventDefault();
		closeMovie();
	});

	$("a#btnClosePopup").click(function(event){
		event.preventDefault();
		closePopup();
	});

	$("#TB_overlay").click(function(){
		closeMovie();
	});
	
	$("a#WhereCanITakeMyCareer-next").click(function(event){
		event.preventDefault();
		$(".nextBtn").removeClass("current");
		$(this).addClass("current");
		$("#sarahnote").hide();
		$("#chrisnote").show();
		if(curid!='WhereCanITakeMyCareer'){curid = 'WhereCanITakeMyCareer'; switchMovie(curid); };
	});

	$("a#SarahSchnabel-next").click(function(event){
		event.preventDefault();
		$(".nextBtn").removeClass("current");
		$(this).addClass("current");
		$("#sarahnote").show();
		$("#chrisnote").hide();
		if(curid!='SarahSchnabel'){ curid = 'SarahSchnabel'; switchMovie(curid); };
	});

	$("a#HowDoYouSupport-next").click(function(event){
		event.preventDefault();
		$(".nextBtn").removeClass("current");
		$(this).addClass("current");
		$("#naominote").hide();
		$("#bradnote").show();
		if(curid!='HowDoYouSupport'){curid = 'HowDoYouSupport'; switchMovie(curid); };
	});

	$("a#NaomiLawrie-next").click(function(event){
		event.preventDefault();
		$(".nextBtn").removeClass("current");
		$(this).addClass("current");
		$("#naominote").show();
		$("#bradnote").hide();
		if(curid!='NaomiLawry'){ curid = 'NaomiLawry'; switchMovie(curid); };
	});

	$("#apply").click(function(){
		if(section!="apply")openApply();
		
	});

	$("#contact").click(function(){
		if(section!="contact")openContact();
	});

	$("a#btnCloseApply").click(function(event){
		event.preventDefault();
		closeApply();
	});

	$("a#btnCloseContact").click(function(event){
		event.preventDefault();
		closeContact();
	});



	$("#type").change(function(){
			var oldselect = selected;		
			selected = $(this).attr('value');
	
			$("#"+oldselect).slideUp( function(){
				$("#"+selected).slideDown();
			});

	});

	/*///////	functions	///////*/

/*	function applyFlash(){
		alert('flash');		
	};*/

	function loadMovie(curid){
	
		if(curid=="WhereIsCorrsHeaded"){$("#readMore").parent().hide()} else {$("#readMore").parent().show()};
		
		if(curid=="WhereCanITakeMyCareer"||curid=="SarahSchnabel"){
			$(".nextBtn").removeClass("current");
			
			if(curid=="SarahSchnabel"||curid=="WhereCanITakeMyCareer") var newid="WhereCanITakeMyCareer";
			if(curid=="NaomiLawrie"||curid=="HowDoYouSupport") var newid="HowDoYouSupport";
			$("#"+curid+"-next").addClass("current");
			$(".altTitle").hide();
			$("#corrsVidTitle").hide();
			$("#"+newid+"-title").show();
		} else { 
			$("#corrsVidTitle").show();
			$(".altTitle").hide();
		};
		
		curidpng="img/titles/title-"+curid+".png";
		
		$("#movieTitle").attr({src: curidpng});
		
		$("#shareLink").attr({href: "http://www.facebook.com/share.php?u=http://makingcareersense.com/?v="+curid});

		$("#shareEmail").attr({href: "mailto:?subject=Have a look at this video from Corrs Chambers Westgarth&body=Hi,%0D%0A%0D%0ACheck out this video on Corrs' graduate recruitment site.%0D%0A%0D%0Ahttp://makingcareersense.com/#"+curid});
		
		$("#corrsVid").html(clips[curid]);

		$("#corrsVidTitle").html(titlesArray[curid]);

		loadState = true;

        tb_show("", "#TB_inline?height=430&width=700&inlineId=movieLoader&modal=true", "");
	};


	function switchMovie(curid){
					
		$("#shareLink").attr({href: "http://www.facebook.com/share.php?u=http://makingcareersense.com/?v="+curid});

		$("#shareEmail").attr({href: "mailto:?subject=Have a look at this video from Corrs Chambers Westgarth&body=Hi,%0D%0A%0D%0ACheck out this video on Corrs' graduate recruitment site.%0D%0A%0D%0Ahttp://makingcareersense.com/#"+curid});
		
		$("#corrsVid").html(clips[curid]);

		$("#corrsVidTitle").html(titlesArray(curid));
	};

	function openPopup()
	{
		if(loadState!=true)
		{
		
		loadState = true;
		
		$("#applyflash").delay(20300).fadeIn(400).delay(2000).fadeOut(1000);
	
		$("#popupLoader").animate({ height:'430px', top:'203px' }, 500, function(){ $("#popupLoaderContent").fadeIn(); }); 

		$("#applyVid").html(applyFlv);

		};
	
	};

	function openApply(){
		section = 'apply';

		if(loadState!=true){
	
		loadState = true;
		$("#applyLoader").delay(200).animate({ height:'430px', top:'193px' }, 500, function(){ $("#applyContent").fadeIn(); }); 
		$("#applyVid").html(applyFlv);
		};
	
	};

	function openContact(){
		section = 'contact';

		if(loadState!=true){
	
		loadState = true;
		$("#contactLoader").delay(200).animate({ height:'430px', top:'193px' }, 500, function(){ $("#contactContent").fadeIn(); }); 
		};
	
	};

	function closeMovie(){
		loadState = false;
		if(readmorestate=="open") readMoreClose();
		curid="";
		tb_remove();
	};





	function closePopup(){
		loadState = false;
		readmorestate="closed";
		//curid="";
		$("#popupLoaderContent").fadeOut( function(){ 
			$("#popupLoader").animate({ height:'0px', top:'388px' }, 500, function(){ loadState = false; }); 
		});

	};

	function closeApply(){
		loadState = false;
		section="";
		$("#applyContent").fadeOut( function(){ 
			$("#applyLoader").animate({ height:'0px', top:'388px' }, 500, function(){ loadState = false; }); 
		});
	
	};

	function closeContact(){
		loadState = false;
		section="";
			$("#contactContent").fadeOut( function(){ 
				$("#contactLoader").animate({ height:'0px', top:'388px' }, 500, function(){ loadState = false; }); 
			});
	};

	function autoLoad(){
	
		var video = '';
	
		if(window.location.hash) video = window.location.hash.substring(1);
		
		if($.url.param("v")) video = $.url.param("v");
		
		if(video!=''){

		if(video=="HowDoIApply"){openPopup();
			} else if (video=="ApplyNow"){
				openApply();
			} else if  (video=="contact"){
				openContact();
			} ;
				
		for (i=0;i<ids.length;i++){
				if(ids[i] == video){
					curid = video;
					loadMovie(video);
				};
			};
			
		};
	
	};
	
	autoLoad();
	
});

