function play() {
	document.location = "boontyshell://startgame/?" ;
}

function buy() {
	setidtran('');
	document.getElementById("PopBuy").style.visibility = "visible";
	//not needed anymore : document.location = "boontyshell://activate/?" ;
	document.location = "boontyshell://activateonline/?" ;
}
function unlock()
{
	document.location = "boontyshell://activateonline/?" ;
}

function activateCode() {
	var code = document.getElementById("input_idtran").value;
        setidtran(code);
	if (code=='') alert(txtNoCodeMsg);
	else {
          activationWait();
          document.location = "boontyshell://activateonline/?" ;
        }
}

function alreadybought() {
	document.getElementById("PopAlready").style.visibility = "visible";
}


function activateOfflineSN (serialNumber)
{
        document.location = "boontyshell://applyserialnumber/?" + serialNumber ;
        document.location = "boontyshell://manunlock/?";
}

function activateOfflineAC (activationCode)
{
        document.location = "boontyshell://applyactivationcode/?" + activationCode ;
}

function subscribe_popup() {
	window.location.href = "./activate.html" ;
}

function closeconnection (command) {
	document.location = "boontyshell://close/?" + command ;
}

function aborttransaction () {
	document.location = "boontyshell://abort/?";
}

function buy_popup() {
	window.location.href = "./activation_unlock.html" ;
}

function buy_popup_idtran(theIdTran) {
	setidtran(theIdTran);
	window.location.href = "./activation_unlock.html" ;
}


function helpPurchase() {
	document.location = "boontyshell://help/?m_szHelpPurchase" ;
}

function helpActivation() {
	document.location = "boontyshell://help/?m_szHelpActivation" ;
}

function help() {
	document.location = "boontyshell://help/?m_szHelpIndex" ;
}

function helpManUnlock()
{
         document.location = "boontyshell://help/?m_szHelpManualActivation" ;
}

function browseLink(theLink) {
	document.location = "boontyshell://browser/?" + theLink ;
}

function browseGame() {
	document.location = "boontyshell://browser/?" + gamePageAtPartner ;
}

function getmoregames() {
	document.location = "boontyshell://browser/?" + baseSiteBoonty ;
}

function closepopup (command) {
	document.location = "boontyshell://close/?" + command ;	
}

function customersupport() {
	document.location = "boontyshell://browser/?" + baseSiteBoonty + "/contact.php";
}

function customersupportrecover() {
	document.location = "boontyshell://browser/?" + baseSiteBoonty + "/contact.php";
}

function privacy() {
	document.location = "boontyshell://browser/?" + baseSiteBoonty + "/howitworks.php?intMode=5";
}

function cancel() {
	document.location = "boontyshell://cancel/?" ;	
}
function retry() {
	document.location = "boontyshell://retryunlock/?" ;
}

function setidtran(idTran) {
	document.location = "boontyshell://idtran/?" + idTran ;
}

function newsletter (email) {
	if(/^[a-zA-Z0-9]([-_\.]?[a-zA-Z0-9])*@[a-zA-Z0-9]([-\.]?[a-zA-Z0-9])*\.([a-z]{2,4})$/.test(email)) {
		document.location = "boontyshell://browser/?poll.mshell.boonty.com/redirect.php?strAction=newsletter&strEmail=" + email + "&intIdSite=" +  idSite;
	}
	else {
		alert(txtCorrectEmailMsg);
	} 
}

function openPartnerWebsite() {
	document.location = "boontyshell://browser/?" + baseSitePartner;
}

function openPartnerWebsiteFAQ() {
	document.location = "boontyshell://browser/?" + baseSiteBoonty + "/howitworks.php?intMode=2";
}

function openPartnerGame(intIdGame) {
	document.location = "boontyshell://browser/?" + baseSiteBoonty + "/fiche.php?intIdGame=" + intIdGame;
}

function openBoontyWebsite() {
	document.location = "boontyshell://browser/?" + baseCorporateBoonty;
}

function textOut(theText) {
	document.write ( theText ) ;
}


function ConversionHeure(TrialMin) {
	return (Math.floor(TrialMin/3600));
}

function conversionHM(duration) {
        return (Math.floor(duration/3600))+" heures "+(duration%3600)+" minutes";
}

function ConversionMin(TrialMin) {
	return (Math.floor(TrialMin/60));
}

var trialLeft = "";
var trialTotal = "";
function prepareTrialPeriod() {
        if ( typeof(Status) == "string")
	{
		switch ( Status )
		{ 
			case "TRIAL": // Trial period is valid
				if ($TrialInitMin != -1)
				{
					if ( $TrialMin > 24*60*60) 
						trialLeft = Math.round($TrialMin/60/60/24) + ' jours' ;
					else if ( $TrialMin > 60*60) 
						trialLeft = Math.round($TrialMin/60/60) + ' heures' ;
					else if ( $TrialMin > 60) 
						trialLeft = Math.round($TrialMin/60) + ' mins' ;
					else 
						trialLeft = ($TrialMin) + ' secs' ;

					if ( $TrialInitMin > 24*60*60) 
						trialTotal = Math.round($TrialInitMin/60/60/24) + ' jours' ;
					else if ( $TrialInitMin > 60*60) 
						trialTotal = Math.round($TrialInitMin/60/60) + ' heures' ;
					else if ( $TrialInitMin > 60) 
						trialTotal = Math.round($TrialInitMin/60) + ' mins' ;
					else 
						trialTotal = ($TrialInitMin) + ' secs' ;
				} 
				else if ($TrialInit != -1)
				{
					if ( $Trial > 24*60*60) 
						trialLeft = Math.round($Trial/60/60/24) + ' jours' ;
					else if ( $Trial > 60*60) 
						trialLeft = Math.round($Trial/60/60) + ' heures' ;
					else if ( $Trial > 60) 
						trialLeft = Math.round($Trial/60) + ' mins' ;
					else 
						trialLeft = ($Trial) + ' secs' ;

					if ( $TrialInit > 24*60*60) 
						trialTotal = Math.round($TrialInit/60/60/24) + ' jours' ;
					else if ( $TrialInit > 60*60) 
						trialTotal = Math.round($TrialInit/60/60) + ' heures' ;
					else if ( $TrialInit > 60) 
						trialTotal = Math.round($TrialInit/60) + ' mins' ;
					else 
						trialTotal = ($TrialInit) + ' secs' ;
				} 
				else if ($TrialInitLau != -1)
				{
					trialLeft = $TrialLau + ' parties' ;
					trialTotal = $TrialInitLau ;
				} 
				break ;
			case 'EXPIRED': // Game is expired
				break ;
			case "BUYONLY": // Game is buy only
				break ;
			case "NORMAL": // Game is unlocked
				break ;
			case "BROKEN": // License is broken
				break ;
			case "ERROR": // Error encoutered
				break ;
		}
	}
}

/****************************** SUPPORT ************************************************/
var suppEmailSubjSN = "[Req. SN] " + gameName;
var suppEmailSubjActCode = "[Req. ActCode] " + gameName;


function suppRequestSn(orderId) {
	var emailBody = "OrderId: " + orderId;
	emailBody += "%0d%0a%0d%0aSite: " + partnerName + " ("+idSite+")";
	emailBody += "%0d%0a%0d%0aGame: " + gameName + " ("+IdGame+")";
	emailBody += "%0d%0a%0d%0aCPA: " + CPA;
	if(orderId == "")
	{
		alert('Please enter a valid Order ID!');
		return false;
	} else {
		window.location = "mailto:"+suppEmailTo+"?subject="+suppEmailSubjSN+"&body="+emailBody ;
		}
}

function suppRequestActCode()
{
        var emailBody = "Serial Number: " + SerialNumber;
	emailBody += "%0d%0a%0d%0aSite: " + partnerName + " ("+idSite+")";
	emailBody += "%0d%0a%0d%0aGame: " + gameName + " ("+IdGame+")";
	emailBody += "%0d%0a%0d%0aCPA: " + CPA;
	emailBody += "%0d%0a%0d%0aReq. code: " + RequestCode;
	window.location = "mailto:"+suppEmailTo+"?subject="+suppEmailSubjActCode+"&body="+emailBody ;
	window.location = "man-unlock-01.html" ;
}

/*************************************** RUN ***************************************************************/

// Disable text selection and righ-click
document.onselectstart=new Function ("return false;");
var myOcm = document.oncontextmenu;
document.oncontextmenu=new Function ("return false;");
// Initialise Trial Period
prepareTrialPeriod();
