$(document).ready(function() {
    $(".box a").hover(function () {
      $(this).parent().find('.desc').animate({width: 'toggle'});
    });
	
	
	$(".map-link-cpt").click(function(){
		$gmap = $("#map-cpt").html();									  
		Shadowbox.open({
			content:    $gmap,
			player:     "html",
			title:      "Map",
			height:     430,
			width:      620
		});
	 });
	
	$(".map-link-jhb").click(function(){
		$gmap = $("#map-jhb").html();									  
		Shadowbox.open({
			content:    $gmap,
			player:     "html",
			title:      "Map",
			height:     430,
			width:      620
		});
	 });	
	
	
	$('#accordion .head').click(function() {
		$(this).next().toggle();
		return false;
	}).next().hide(); 
	
	$('.thumb-desc').click(function(){
		var spot = $(this).next();	
		var director_link = spot.next();
        var parent = $('object#spot').parent();
		$('object#spot').remove();
		var newElement = '<object id="spot" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab">' +
                	'<param name="src" value="' + spot.text() + '"/>' +
                    '<param name="scale" value="aspect" />' +
                    '<param name="controller" value="true" />' +
                    '<param name="autoplay" value="true" />' +
                    '<param name="width" value="606" />' +
                    '<param name="height" value="375" />' +
                    '<param name="bgcolor" value="#000000" />' +
                    '<embed src="' + spot.text() + '"  width="606" height="375" type="video/quicktime" autoplay="true" controller="true" scale="aspect" pluginspage="http://www.apple.com/quicktime/download/" bgcolor="#000000"></embed>' +
                '</object>';
				
		parent.prepend(newElement);
		
        //Update the main video description text
        var director = $(this).find('p.director').text();
		var brand = $(this).find('span.brand').text();
		var title = $(this).find('span.title').text();

		$('#spot-meta .director').text(director);
        $('#spot-meta .brand').text(brand);
        $('#spot-meta .title').text(title);

        //Update the social media buttons
        var main_social_media = $('#social-media');
        main_social_media.html('');

        main_social_media.append($(this).parent().find('.social-hidden').children());

        try{
            FB.XFBML.parse();
        }catch(ex){}

	});
});
