// JavaScript Document
var verif = 0;
var theme = "";
var ref = "";
/*var time = 0;
var mytime = 0;*/
function startmovie(){
	if (verif == 1){
		$("#divPlayerMiddle").removeClass("loading")
		$("#divPlayerMiddle").html('<object width="453" height="340"><param name="video" value="http://streamingquill.com/images/movie_intro.swf"></param><embed width ="453" height="340" src="http://streamingquill.com/images/movie_intro.swf"></embed></object>');
		setTimeout(function(){starttrial();},9000);
	}	
};
function starttrial(){
	if (verif == 1){
		refcode = "";
		if(ref != ""){
			refcode = "&ref=" + ref;
		}
		$("#liPlay").html("<img src='images/player_play.png' alt='Pause' border='0'/>");
		$("#divPlayerMiddle").addClass("trial");
		$("#divPlayerMiddle").html('<div id="divWarning" onclick="window.location.href=http://www.streamingquill.com/free-trial.php?movie='+movie+'&theme='+theme+refcode+'"><p>Notre collection de films est visionnable que dans certaines r&eacute;gions.</p><p>S.V.P. veuillez voir si vous &egrave;tes &eacute;ligible en cr&eacute;ant un compte</p><p>Vous devez vous inscrire <b>GRATUITEMENT</b> pour avoir acc&egrave;s aux films en <b>STREAMING</b> et aux <b>T&Eacute;L&Eacute;CHARGEMENTS.</b></p><a class="aOfferBtn" href="http://www.streamingquill.com/free-trial.php?movie='+movie+'&theme='+theme+refcode+'"></a></div>');
		$("#divPlayerMiddle").click(function () {
   	   		window.location = "http://www.streamingquill.com/free-trial.php?movie="+movie+"&theme="+theme+refcode;
   		});
	}
};
function playmovie(){
	verif = 1;
	$("#divPlayerImg").removeClass("scene");
	$("#liPlay").html("<img src='images/player_pause.png' alt='Play' border='0'/>");
	$("#divPlayerMiddle").addClass("loading");
	loading();
	clocktime();
	setTimeout(function(){startmovie();},4000);
}
function stopmovie(){
	verif = 0
	$("#divPlayerImg").addClass("scene");
	$("#liPlay").html("<img src='images/player_play.png' alt='Pause' border='0'/>");
	$("#divPlayerMiddle").removeClass("loading")
	$("#divPlayerMiddle").addClass("normal");
	$("#divPlayerMiddle").html("");
}
function loading(){
	$("#divProgKnob").animate({width: 200},30000);
}
var cur = 0;
function clocktime(){
	if(cur <13){
		mytime = cur + '';
		len0 = mytime.length;
		if (len0 == 1){
			mytime = "0" + mytime;
		}
		$("#time").html(mytime);
		cur++;
		setTimeout(function(){clocktime();},1000);	
	}else{
		cur =0;
	}
	return false;	
}

$("document").ready(function(){
	$("#divPlayerImg").addClass("scene");
	$("#divPlayerMiddle").click(function(){
		playmovie();
	});
	$("#liPlay").toggle(
      function () {
       playmovie();
      },
      function () {
		stopmovie();
      }  
    );
});


