/**
 * 
 */
var flashObject = null;
var app_id = null;
var api = null;
var uid = null;
var justconnecting = true;

function getMovie(){
	if(flashObject == null){
		flashObject = document.getElementById('flashfile');
	}
	return flashObject;
}

function setFB(){
	FB.init({
      appId   : '326089454085399',
      channelUrl  : 'http:/www.tosh.com.co/channel.html',
      status  : true, // check login status
      cookie  : true, // enable cookies to allow the server to access the session
      oauth   : true,
      xfbml   : true // parse XFBML
    });
	FB.getLoginStatus(function(response) {
	  if (response.status === 'connected') {
		  obtenerDatos(true, "completo");
	  } else if (response.status === 'not_authorized') {
		  getLogin();
	  } else {
	      getLogin();
	  }
	});
	console.log('entro en setFB');
}

function obtenerDatos(valor, accion){
	getMovie().getFB(valor, accion);
}

function popup(page, height, width)
{
  var url = page;
  var h = height;
  var w = width;
  var left=(screen.width)?(screen.width - width)/2:100;
  var top=(screen.height)?(screen.height - height)/2:100;

 var popup = window.open(url,'popUp','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=' + w + ',height=' + h + ',left='+left+',top='+top);
 popup.focus();
}

function shareFB(url){
    var surl = "http://www.facebook.com/sharer.php?u="+encodeURIComponent(url);
    popup(surl, 300, 600);
}

function shareTwitter(url){
	var texto = url;
    var surl = "http://twitter.com/share?url="+url+"&text=Visita http://www.doritos.com.co, cumple el desafío APRETADITOS y podrás ganar un viaje para 6 personas";
    popup(surl, 300, 600);
}

function isReady(){
	return true;
}

function launchIframe(UID){
	var user = (UID);
	document.getElementById('frame-container').style.display = 'block';
	document.getElementById('frame-container').innerHTML = "<iframe id='frame-oculto' src='http://cbtosh.ats.com.co/?uid="+user+"'  scrolling='no' frameborder='0' style='border:none; overflow:hidden; width:100%; height:100%;' allowTransparency='true'></iframe>";
}
