var flashversion = "9.0.115";


if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPod') != -1)){
            window.location = 'iphone/';
}else if(navigator.userAgent.indexOf('iPad') != -1) {
            window.location = 'ipad/';
}

if(typeof(swfobject)=='object' && swfobject.hasFlashPlayerVersion(flashversion)){
	var head = document.getElementsByTagName('head');
	var flashstyle = document.createElement('style');
	var css = '#flashcontent h1, #flashcontent p {display: none}';
	flashstyle.setAttribute('type','text/css');
	if(head[0]){
		if(flashstyle.styleSheet){
			flashstyle.styleSheet.cssText = css;
		}else{
			flashstyle.appendChild(document.createTextNode(css));
		}
		head[0].appendChild(flashstyle);
	}
}

function grownUpsSwf() {
	var flashvars = {
	};
									
	var params = {
		allowscriptaccess:"always",
		allowfullscreen:"true",
		base:"media/",
		wmode:"transparent"
	};
				
	var attributes = {
	};
	
	var version = 'loaderA.swf'; 
	var ran = Math.round(Math.random());
	if(ran){
		version = 'loaderB.swf';
	}
	
	if(typeof(console) == 'object') {
		console.log(ran + version);
	}
	
	swfobject.embedSWF("media/" +version,  "flashcontent", "100%", "635", "9.0.115", "", flashvars, params, attributes);
}


share.url = "http://www.GrownUps-Movie.com";
share.title = "Grown Ups | Official Movie Site and Trailer";
share.description = "GROWN UPS, a comedy with Adam Sandler, Kevin James, Chris Rock, Rob Schneider, and David Spade, tells the story of five childhood friends who pick up where they left off.";
share.tweet = "Grown Ups | Official Movie Site and Trailer http://www.GrownUps-Movie.com";
share.delicious.description = "GROWN UPS, a comedy with Adam Sandler, Kevin James, Chris Rock, Rob Schneider, and David Spade, tells the story of five childhood friends who pick up where they left off.";

// Social bookmarking function

function shareThis() {
	var links = document.getElementById('share').getElementsByTagName('a');
	for (i=0; i<links.length; i++) {
		var link = links[i];
		if( (link.getAttribute('rel') == 'facebook') || (link.getAttribute('rel') == 'myspace') || (link.getAttribute('rel') == 'twitter') || (link.getAttribute('rel') == 'delicious') || (link.getAttribute('rel') == 'digg') || (link.getAttribute('rel') == 'stumbleupon'))
		{
			link.onclick= function() {
				document.getElementById('flashcontent').shareActive();
				share.send(this.getAttribute('rel'));						
				return false;
			}
		} else if (link.getAttribute('rel') == 'facebookfan') {	
			link.onclick= function() {
				document.getElementById('flashcontent').shareActive();
			}
		}
	}
}

function registerPop() {
	if (document.getElementById('register'))
	{	
		var register = document.getElementById('register');
		register.onclick = function() {
			displayWindow(this.href,'registration',446,470);
			return false;
		}
	}
}


function openFull(url) {
	newwindow=window.open(url,'name','fullscreen,scrollbars');
	if (window.focus) {newwindow.focus()}
	return false;
}


//overlayPlayer config
feedUrl = "http://www.sonypictures.com/previews/movies/grownups.xml"; 
autocloseToggle = true; 
singlevideoToggle = false; 
clipName = 1472;
useQAplayer = true; 



addLoadEvent(grownUpsSwf);
addLoadEvent(registerPop);