$(document).ready(function(){
	$('A[rel="external"]').click( function() {
		window.open($(this).attr('href'));
		return false;
	});
	if ($('#past-events').length > 0) {
		$('#past-events').tabs();
	}
	if ($('#content #nav li.active').length > 0) {
		$('#content #nav li.active').pngFix( );
	}
	if ($('#content #nav li a').length > 0) {
		$('#content #nav li a').pngFix( );
	}
	if ($('#box-centre .transparent-box').length > 0) {
		$('#box-centre .transparent-box').pngFix( );
	}
	if ($('#box-right .boxes').length > 0) {
		$('#box-right .boxes').pngFix( );
	}
	if ($('#box-centre .ui-tabs-nav a, #box-centre .ui-tabs-nav a span').length > 0) {
		$('#box-centre .ui-tabs-nav a, #box-centre .ui-tabs-nav a span').pngFix( );
	}
	if ($('#box-centre .ui-tabs-nav .ui-tabs-selected a').length > 0) {
		$('#box-centre .ui-tabs-nav .ui-tabs-selected a').pngFix( );
	}
	
	if ($('#open-keynote').length > 0) {
		$('#open-keynote, .close-keynote').click(function() {
			$('#keynote').toggle('fast');
			//$('#open-keynote').toggle('fast');
			return false;
		});
	}
	if ($('#open-workshops').length > 0) {
		$('#open-workshops, .close-workshops').click(function() {
			$('#workshops').toggle('fast');
			//$('#open-workshops').toggle('fast');
			return false;
		});
	}
	if ($('#open-speakers').length > 0) {
		$('#open-speakers, .close-speakers').click(function() {
			$('#speakers').toggle('fast');
			//$('#open-speakers').toggle('fast');
			return false;
		});
	}
	if ($('#open-agenda').length > 0) {
		$('#open-agenda, .close-agenda').click(function() {
			$('#agenda').toggle('fast');
			//$('#open-agenda').toggle('fast');
			return false;
		});
	}
	if ($('#open-venue').length > 0) {
		$('#open-venue, .close-venue').click(function() {
			$('#venue').toggle('fast');
			//$('#open-venue').toggle('fast');
			return false;
		});
	}
	
	if ($('#contact-form').length > 0) {
		$('#contact-form').validate();
	}
	
	if ($("#twitter-badge").length > 0) {
		$("#twitter-badge").getTwitter({
			userName: "demandgentweet",
			numTweets: 2,
			loaderText: "Loading tweets...",
			slideIn: false,
			showHeading: false,
			//headingText: "Latest Tweets",
			showProfileLink: false
		});
	}
	if ($('#contact').length > 0) {
        $('#contact').validate({
              errorContainer: "#formErroMsg",
              errorClass: "invalid",
              errorPlacement: function(error, element) {
                    //error.appendTo( element.parent("label") );
              },
              debug:false
        });
	};
	if ($('#sorry-form').length > 0) {
        $('#sorry-form').validate({
              errorContainer: "#formErroMsg",
              errorClass: "invalid",
              errorPlacement: function(error, element) {
                    //error.appendTo( element.parent("label") );
              },
              debug:false
        });
	};
	if ($('#confirm-form').length > 0) {
		$('#submit').click(function() {
			if($("#confirm").val()=='Yes')
				$('#Known').val($('#email').val());
			
		});
		
        $('#confirm-form').validate({
              errorContainer: "#formErroMsg",
              errorClass: "invalid",
              errorPlacement: function(error, element) {
                    //error.appendTo( element.parent("label") );
              },
              debug:false
        });
	};
	if ($('#optout').length > 0) {
        $('#optout').validate({
              errorContainer: "#formErroMsg",
              errorClass: "invalid",
              errorPlacement: function(error, element) {
                    //error.appendTo( element.parent("label") );
              },
              debug:false
        });
	};
	
	if ($('#webcast').length > 0) {
		$('#webcast1').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10697/flashplayer.xml?1226414273&view_id=2226594'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast2').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10705/flashplayer.xml?1226414614&view_id=2226711'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast3').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10720/flashplayer.xml?1226414722&view_id=2226765'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast4').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10727/flashplayer.xml?1226414802&view_id=2226804'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast5').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10747/flashplayer.xml?1226431372&view_id=2230945'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast6').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/10749/flashplayer.xml?1226431268&view_id=2230932'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast7').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/13084/flashplayer.xml?1241692201'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast8').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/13086/flashplayer.xml?1241692256'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast9').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/13085/flashplayer.xml?1241692226'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast10').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/13095/flashplayer.xml?1241692284'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast11').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/17710/flashplayer.xml?1271761753'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast12').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/17700/flashplayer.xml?1271761558'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
		$('#webcast13').flash({ 
			src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
			flashvars: {
			config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/17720/flashplayer.xml?1271761666'},
			width: 620,
			height: 550,
			wmode: 'transparent'
		},{version: 9});
	}
	if ($('#highlights-video').length > 0) {
		$('#highlights-video').flash({ 
				src: 'http://mediazone.brighttalk.com/sitedata/templates/player/player-video-ondemand-tabbed-flash-embed/flashplayer.swf',
				flashvars: {
				config_url: 'http://mediazone.brighttalk.com/sitedata/b3967a0e938dc2a6340e258630febd5a/communication/13146/flashplayer.xml?1242124279&view_id=3231699'},
				width: 620,
				height: 550,
				wmode: 'transparent'
			},{version: 9});
	}

	if ($("#twitter-badge").length > 0) {
		$("#twitter-badge").getTwitter({
			userName: "demandgentweet",
			numTweets: 2,
			loaderText: "Loading tweets...",
			slideIn: false,
			showHeading: false,
			//headingText: "Latest Tweets",
			showProfileLink: false
		});
	}
});