﻿var videoURL = 'http://bd-dvd.sonypictures.jp/thesocialnetwork/video/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.tracking = true;
//share.facebook.url = 'http://socialnetwork-movie.jp/share.html';
//share.digg.url = 'http://socialnetwork-movie.jp/share.html';
//share.url = 'http://socialnetwork-movie.jp/';
//share.title = 'ソーシャル・ネットワーク - 2011年1月15日（土）より全国ロードショー';
//share.tweet = 'ソーシャル・ネットワーク - 2011年1月15日（土）より全国ロードショー  http://www.socialnetwork-movie.jp/';
//share.description = '世界最大のSNS「Facebook」誕生の物語。 2011年1月15日（土）より全国ロードショー';

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');
		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();
});


//Configure pop up window. Must include global common.js
function windowPop(){
	var links = document.getElementsByTagName('a');	
	for(i=0;i<links.length;i++){
		if (links[i].getAttribute('rel')=="popup"){
			links[i].onclick = function(){
				displayWindow(this.href,"forgot_password",800,600,"directories=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,titlebar=0,toolbar=0");
				return false;
			}
		}
	}
}

addLoadEvent(function(){
	windowPop();
});
