﻿//---------Get url params for download  button (inside html and not the header)-----------

//used to add WO/WB to q.string
var ShowHomePageBanner ;
var currentPageName ;

if (IsPageBannerEnabled=="true")
{
    ShowHomePageBanner = true ;
}
else
{
    ShowHomePageBanner = false ;
}


if (IsHomeVideoTestEnabled=="true")
{
    ShowHomeVideoSlide = true ;
}
else
{
    ShowHomeVideoSlide = false ;
}

function GetQueyStringParams() {

    var btnDownload = document.getElementById('btnDownload');
    var btnDownload2 = document.getElementById('btnDownload2');
    var btnBuyDownload = document.getElementById('btnBuyDownload');

    if (btnDownload != null) {

        btnDownload.href = "Download.aspx";
    }

    if (btnDownload2 != null) {

        btnDownload2.href = "Download.aspx";
    }

    if ($("#btnBuyDownload").length > 0) {
        $("#btnBuyDownload").attr("href", "Download.aspx"); 
        $("#btnBuyDownload").css("text-decoration", "none");
    }

}


function queryString(parameter) {
    
    hu = window.location.search.substring(1);    
    gy = hu.split("&");
    
    var j = 0;
    for (j = 0; j < gy.length; j++)
    {
        ft = gy[j].split("=");
		
        if (ft[0] == parameter )        
        {
           return ft[j] ; 
        }
     }      
}


function Set30Trial()
{
  if(IsTrial30Enabled=='1')
  {
      $("#divHome30Trial").show();
      $("#divBannerHeader").show();
      $("#divBusiness30_Trial").show();            
      $("#panel_addons").show();        
      $("#divPlans30Trial").show();        
      $("#divCredit30Trial").show();
      $("#divBannerContent").show();
  }
  else
  {
      $("#divBannerHeader").text("Download ooVoo");
      $("#divBannerHeader").show(); 
   }  
}

function Set1stPlanTest()
{
   if(Is1PlanEnabled=='0')    
   {
     $("#divUpgradePlan").show();
   }
}


function DownloadBtnClick() {
    SendDataToGA("Buy.Plan." + pageLanguage.toUpperCase() + "-Click-Download");   
}

function BuyCreidtsBtnClick() {
    SendDataToGA("Buy.Plan." + pageLanguage.toUpperCase() + "-Click-Buy");
}

function SendDataToGA(param) {
    if (gaJsHost == "" || gaJsHost == 'undefined') {
        var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
        document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    }

    try {

        var pageTracker = _gat._getTracker("UA-1091806-4");
        pageTracker._trackPageview(param);
    }
    catch (ex) { alert(ex); }

}

function PlansBuyDownloadOnClickGa() {
    $("a[id^='btnDownload']").click(function() {
        DownloadBtnClick();
    });

    $("a[id^='btnBuyCreduts']").click(function() {
        BuyCreidtsBtnClick();
    });
}

onload = function() {

    //the onload not really works , the call for the function is onClick
    GetQueyStringParams();
    Set30Trial();
    Set1stPlanTest();
        
    //only if we on Buy-Plans page and the language is en,zh,pt then add current GA.
    if ( queryString("pname") == "Plans" && (pageLanguage == "en" || pageLanguage == "zh" || pageLanguage == "pt")) 
    {
        PlansBuyDownloadOnClickGa();
    }
}

//---------Get url params for download  button -----------


