﻿var videoURL = 'http://flash.sonypictures.com/video/intl/global/movies/thesocialnetwork/thesocialnetwork_trailer.mp4',
    videoTracking = 'thesocialnetwork_trailer';

// Social bookmarking function
function sharethis() {
	if(document.getElementById('share')) {
		var links = document.getElementById('share').getElementsByTagName('a');
		for (var i=0; i<links.length; i++) {
			var link = links[i];
			link.onclick= function() {
				share.send(this.getAttribute('rel'));	
				return false;
			}
		}
	} else {
		return false;
	}
}

addLoadEvent(sharethis);

// share props
share.tracking = true;
share.facebook.url = 'http://TheSocialNetwork-Movie.net/share.html';
share.digg.url = 'http://TheSocialNetwork-Movie.net/share.html';
share.url = 'http://TheSocialNetwork-Movie.net/';
share.title = 'Watch The Social Network Official International Trailer';
share.tweet = 'Check out The Social Network International Movie Site  http://TheSocialNetwork-Movie.net/';
share.description = 'A story about the founders of the social-networking website, Facebook. At cinemas from October 7.';

function dimensionPopup() {
	var screenWidth  = window.screen.width,
		screenHeight = window.screen.height,
		width = 1280,
		height = 950;		
	if(screenHeight <= 1050) {
		height = screenHeight;
	}
	if(screenWidth < 1070) {
		width = 860;
	} else if(screenWidth >= 1070 && screenWidth < 1280) {
		width = 1070;
	} 
	
	$('#keyart, #enter-the-site').bind('click', function() {
		var tracking = $(this).attr('rel');
		sCode.trackFeaturedContentClick(this.href, tracking);
		window.open(this.href, '', 'width=' + width + ', height=' + height + ', resizable=no, location=no, scrollbar=no, status=no, titlebar=no, toolbar=no, directories=no, fullscreen=no');
		return false;
	});			
}

function quoteRotation() {
	var curPos,
		nextPos;
	for(var i = 0, count = $('#quote div').length; i < count; i++) {
		if($('#quote div').eq(i).is(':visible')) {
			curPos = i;
		}
	}
	if( (curPos + 1) == $('#quote div').length ) {
		nextPos = 0; 
	} else {
		nextPos = curPos + 1;
	}
	$('#quote div').eq(curPos).hide();
	$('#quote div').eq(nextPos).fadeIn('slow');
}


	
$(function() {
	/* var autoplay = setTimeout(openOverlay, 5000);
	$('a').bind('click', function() {
		clearTimeout(autoplay);		
	}); */
	setInterval('quoteRotation()', 5000);
	
	$('li#quote div').hide();
	$('li#quote div').eq(0).show();
	
	$('#itrailer').bind('click', function() {
		window.open(this.href, '', 'width=640, height=395, resizable=no, location=no, scrollbar=no, status=no, titlebar=no, toolbar=no, directories=no, fullscreen=no');
		return false;
	});
	
	dimensionPopup();
});

