var flashversion = "10";

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);
	}
}


var flashvars = {};
								
var params = {
	AllowScriptAccess:"always",
	allowfullscreen:"true",
	wmode:"opaque",
	base:"media"
};

var attributes = {};
									
swfobject.embedSWF("media/main.swf", "flashcontent", "100%", "466", flashversion, "", flashvars, params, attributes);
//swffit.fit("flashcontent");

function popWin (link){
	if (link){
		if(!window.open(link)){
			alert('Please disable your popup blocker and try again.');
		}
	}			
}

share.url = "http://karatekid-themovie.com/";
share.title = "Check Out The Official Karate Kid Movie Site and Trailer";
share.description = "In Columbia Pictures' The Karate Kid, 12-year-old Dre Parker (Jaden Smith) could've been the most popular kid in Detroit, but his mother's (Taraji P. Henson) latest career move has landed him in China.  Dre immediately falls for his classmate Mei Ying - and the feeling is mutual - but cultural differences make such a friendship impossible. Even worse, Dre's feelings make an enemy of the class bully, Cheng.  In the land of kung fu, Dre knows only a little karate, and Cheng puts 'the karate kid' on the floor with ease.  With no friends in a strange land, Dre has nowhere to turn but maintenance man Mr. Han (Jackie Chan), who is secretly a master of kung fu.  As Han teaches Dre that kung fu is not about punches and parries, but maturity and calm, Dre realizes that facing down the bullies will be the fight of his life.";
share.tweet = "Check out The Karate Kid Movie Site and Trailer at http://karatekid-themovie.com/";

// Social bookmarking function

function shareThis() {
	var links = document.getElementById('share').getElementsByTagName('a');
	
	for (i=0; i<links.length; i++) {
		var link = links[i];
		var rel = link.getAttribute('rel');
		switch(rel){
			case 'facebook':
			case 'myspace':
			case 'twitter':
			case 'delicious':
			case 'digg':
			case 'stumbleupon':
		
			extendOnClick(link, function(evt,el) {
				var flashcontent = document.getElementById('flashcontent');
				flashcontent.shareActive();
				share.send(el.getAttribute('rel'));						
				return false;
			});
		}
		if (link.getAttribute('rel') == 'facebookfan') {	
			extendOnClick(link, function() {
				var flashcontent = document.getElementById('flashcontent');
				flashcontent.shareActive();
			});
		}
	}
}

function registerPop() {
	var register = document.getElementById('register');
	if (register){	
		var a = register.getElementsByTagName('a');
		extendOnClick(a[0], function(evt,el) {
			displayWindow(this.getAttribute('href'),'_blank',446,496);
			return false;
		});
	}
}


function configureVideoPlayer() {
	//overlayPlayer config
	feedUrl = "thekaratekid_siteplayer.xml"; 
	autocloseToggle = true; 
	singlevideoToggle = false; 
	clipName = 1757;
	useQAplayer = false; 
	callbackToggle = false;
}

function playWimoVideo() {
	//overlayPlayer config
	feedUrl = "thekaratekid_wimoplayer.xml"; 
	autocloseToggle = true; 
	singlevideoToggle = false; 
	clipName = 1757;
	useQAplayer = false; 
	callbackToggle = false;

	configureVideoPlayer();
}

configureVideoPlayer();
addLoadEvent(registerPop);
addLoadEvent(shareThis);