﻿// JScript File

if(document.forms["frmMain"].elements["viewName"].value == "PurchaseReceiptView")
{
//pull parameters from cookie
var tr = GetCookie("siteID"); 
var land = GetCookie("LS_time_entered");

//pull parameters from order.xsl
  var InvoiceNum = XSLInvoiceNumber; //orderID
  var ClientId= XSLClientOrderId;//client orderID
  var CustId = XSLCustomerId;//customer Id
  //create ord variable
  var ord = CustId+"_"+InvoiceNum+"_"+ClientId;
  
  
  var amt = getPriceDigit(XSLOrderAmount); //round total price to 2 decimal places *100
  amt = 100 * amt;
  amt=Math.round(amt*100)/100;
  
  
    //create string
    var cur = "USD";
    //date
    var gmtdate = new Date();
    var gmtyear = gmtdate.getUTCFullYear();
    var gmtmonth = gmtdate.getUTCMonth()+1;
    var gmtday = gmtdate.getUTCDate();
    var gmthours = gmtdate.getUTCHours();
    var gmtmins = gmtdate.getUTCMinutes();
    if (gmtmonth<10){
            gmtmonth = "0"+gmtmonth;
                    }
    if  (gmtday<10){
            gmtday = "0"+gmtday;
                    }
    if (gmthours<10){
            gmthours = "0"+gmthours;
                    }               
    if (gmtmins<10){
            gmtmins = "0"+gmtmins;
                    }    
    var date = gmtyear+gmtmonth+gmtday+"_"+gmthours+gmtmins;
    //end date
  
    //actual string
    var origmsg = ("ord="+ord+"&tr="+tr+"&land="+land+"&date="+date+"&amt="+amt+"&cur="+cur);

    //send
    var xmlhttp = null;
    origmsg = escape(origmsg);
    //verify cookies
    if (tr!=null){  
    //(duplicate handling)check ORDERID(tmpOrd) cookie: if null or != ord then continue 
    var tmpOrd = GetCookie("tmpOrd"); 
    if (tmpOrd == null || tmpOrd != ord)
        {
        //send to MZlinkShare
        loadXMLDoc("http://secure.mediazone.com/MZlinkshare/Default.aspx?origmsg="+origmsg+"&xml=1");
        //create cookie
        var date = new Date();
        date.setTime(date.getTime()+(3 * 1000 * 60 * 60 * 24));
        var expires = "; expires="+date.toGMTString();
        document.cookie = "tmpOrd="+ord+expires+ "; path=/";
        }//end ORDERID check
    }//end Verify cookies
} 