function popWindow(url, width, height, win) //standard popup window script
{
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	if (win == undefined) win = "_blank";
	newwindow = window.open(url, win, 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}

function exitPopup(url) //popup window for links that leave the sonypictures.com website
{
	var width = 350;
	var height = 350;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open('http://www.sonypictures.com/movies/surfsup/popup/exit/index.php?url='+url, 'exitWindow','toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left='+left+',top='+top);
	if (window.focus) newwindow.focus();
}

function wallpaperWindow(filename) //popup window for the wallpaper downloads
{
	var width = 700;
	var height = 640;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open('http://www.sonypictures.com/movies/surfsup/site/downloads/wallpaper.php?wallpaper='+filename, 'wallpaper', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left='+left+',top='+top);
	if (window.focus) newwindow.focus();
}

function iconWindow(filename) //popup window for the icon downloads
{
	var width = 400;
	var height = 300;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open('http://www.sonypictures.com/movies/surfsup/site/downloads/icon.php?icon='+filename, 'icon', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}

function screensaverWindow(filename) //popup window for the icon downloads
{
	var width = 400;
	var height = 300;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open('http://www.sonypictures.com/movies/surfsup/site/downloads/screensaver.php?screensaver='+filename, 'screensaver', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}

function reviewWindowTest(url) //standard popup window script
{
	var width = screen.width;
	var height = screen.height;
	var left = 0;
	var top = 0;
	var win = "reviewWindow";
	newwindow = window.open(url, win, 'toolbar=1,location=1,status=1,menubar=1,scrollbars=1,resizable=1,width=' + width + ',height=' + height + ',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}

function getQueryVariable() //allows for deep links
{
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  var pair = vars[0].split("=");
  return query;
}
  var urlString = getQueryVariable();

function launchTalentSearch() //full screen popup window for the talent search / teaser page
{
var w = screen.width; //fixed width
var h = screen.height; //fixed height

leftPosition = 0;		// centering horizontal position to middle of screen
topPosition = 0;	// centering vertical position to middle of screen
if (h<768)
{
	var windowprops = 'width=' + w + ',height=' + h + ',top='+ topPosition +',left='+ leftPosition +',toolbar=no,location=no,directories=no,status=no,scrollbars=yes,menubar=no'; //set popup window properties
	var url = "http://www.sonypictures.com/movies/surfsup/teaser/surfsUpLoaderScroll.html";
} else
{
	var windowprops = 'width=' + w + ',height=' + h + ',top='+ topPosition +',left='+ leftPosition +',toolbar=no,location=no,directories=no,status=no,scrollbars=no,menubar=no'; //set popup window properties
	var url = "http://www.sonypictures.com/movies/surfsup/teaser/surfsUpLoader.html";
}

var popup = window.open(url,'history',windowprops); // open popup window with properties
//popup.moveTo(0,0)
//popup.resizeTo(w,h);
//popup.focus(); // focus on window
}

function popFlashSniffer() //links to the noflash page if a user does not have flash installed
{	
	var width = 600;
	var height = 600;
	var left = (screen.width - width) / 2;
	var top = (screen.height - height) / 2;
	newwindow = window.open('http://www.sonypictures.com/movies/surfsup/site/noflash.html', 'window', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=0,width='+width+',height='+height+',left=' + left + ',top=' + top);
	if (window.focus) newwindow.focus();
}

function openHighlightReel()
{
	var w = screen.width; //fixed width
	var h = screen.height; //fixed height
	var url = 'http://www.sonypictures.com/movies/surfsup/site/highlightReel/index.html';
	
	leftPosition = 0;		// centering horizontal position to middle of screen
	topPosition = 0;	// centering vertical position to middle of screen
	if (h>1280 && h>990)
	{
		var scrollbars='no';
		h=1280;
		w=990;
	} else
	{
		var scrollbars='yes';
		if (w>990)
		{
			w=1006;
		}
		if (h>1280)
		{
			h=1280;
		} else
		{
			h-=16;
		}
	}
	
	var windowprops = 'width=' + w + ',height=' + h + ',top='+ topPosition +',left='+ leftPosition +',toolbar=no,location=no,directories=no,status=no,scrollbars='+ scrollbars +',menubar=no'; 
	
	var popup = window.open(url,'highlights',windowprops); // open popup window with properties
	popup.focus(); // focus on window
}