﻿function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

    function movieOut()
    {
    var Dashboard = document.tracking.DashboardTracking.value
    if (Dashboard == "True")
    {
    return
    }
    var fNameParam = "sFirstName=" + document.tracking.firstName.value
    var lNameParam = "&sLastName=" + document.tracking.lastName.value
    var emailParam = "&sEmail=" + document.tracking.email.value
    var startTimeParam = "&sStartDate=" + document.tracking.movieStart.value
    var acctMgrIDParam = "&sAcctMgrID=" + document.tracking.acctMgrID.value
    var WebServiceUrl = "../common/includes/WebServices/Tracking.asmx/MovieWatched?"
    var url = WebServiceUrl + fNameParam + acctMgrIDParam + lNameParam + emailParam + startTimeParam
    var wsRequest = GetXmlHttpObject();
    
    if(wsRequest == null)
    {   alert("request = null")
    }

    wsRequest.open("GET", url, false);
   
  wsRequest.send(null)
  //  alert(wsRequest.responseText);
   }
   
   
   /*To use this function a Page must have a form called info
   with rightsID, custID,ContactID,statID,PageID
   */
       function pageLoaded()
    {
    isPageView = document.info.IsPageView.value;

    doTracking = document.info.DoTracking.value;
   //alert(doTracking + " " + isPageView)
    if(doTracking == "True"&& isPageView == "True")
    {
    //alert(doTracking)
       
        isVisit = false;
        rightID = document.info.RightsID.value;
        custID = document.info.CustID.value;
        contactID = document.info.ContactID.value;
        statID = document.info.StatsID.value;
        PageID = document.info.PageID.value;
        if(contactID<0||custID<0)
        {
        return false;
        }
       // alert(" custID " + custID + " contactID " + contactID + " StatsID " + statID, + " PageID " + PageID);
        
        GoP1D.TrackingWS.AddPageView(custID,contactID,statID,PageID,rightID,onAddPageViewComplete,onAddPageViewError,onAddPageViewError);
        }
    }
    function onAddPageViewComplete(args)
    {
  //  alert("Complete")
    }
        function onAddPageViewError(args)
    {
  //  alert("Error" + args)
    }
    
    
function publicEyeLoad()
{
    {
    isPageView = document.info.IsPageView.value;

    doTracking = document.info.DoTracking.value;
   //alert(doTracking + " " + isPageView)
    if(doTracking == "True"&& isPageView == "True")
    {
    //alert(doTracking)
       
        isVisit = false;
        rightID = document.info.RightsID.value;
        custID = document.info.CustID.value;
        contactID = document.info.ContactID.value;
        statID = document.info.StatsID.value;
        PageID = document.info.PageID.value;
        if(contactID<0||custID<0)
        {
        return false;
        }
       // alert(" custID " + custID + " contactID " + contactID + " StatsID " + statID, + " PageID " + PageID);
        
       GoP1D.TrackingWS.addPulicEyeView(custID,contactID,statID,PageID,rightID,onAddPageViewComplete,onAddPageViewError,onAddPageViewError);
        }
    }
}
