﻿
/* Voting */
function yesVote(customerid, couponId, btnNoVoteId, btnVote ) 
{
    var  btnNoVote =  document.getElementById( btnNoVoteId );
    incrementCount(btnVote);
    updateClicks(customerid, couponId, "yesvote");
    
    if (btnVote != null && btnNoVote != null)
    {
        btnVote.disabled = "true";
        btnNoVote.disabled = "true";
    }
}

function noVote(customerid, couponId, btnYesVote, btnVote) {
    var  btnYesVote =  document.getElementById( btnYesVote );

    incrementCount(btnVote);
    updateClicks(customerid, couponId, "novote");

    if (btnVote != null && btnYesVote != null)
    {
        btnVote.disabled = "true";
        btnYesVote.disabled = "true";
    }
}

function updateClicks(customerid, objectId, typeClick)
{
    var request = clicksHandler + "?customerid=" + customerid + "&objectId=" + objectId + "&typeClick=" + typeClick;
    sendData( request );
}



function sendData( requestString ) 
{
    var xmlHTTP, e;

    try {

        xmlHTTP = zXmlHttp.createRequest();
    
        //Send request
        if (xmlHTTP != null) {
            xmlHTTP.open("GET", requestString, false );
            xmlHTTP.send(null);
            //xmlHTTP.abort();
            //xmlHTTP = null;
        }
    }
    catch (e) {
    alert(e)
    }
}


function incrementCount( btnVote )
{

    var count = 0;
    try {
        count = parseInt(btnVote.value);
        count++;
        btnVote.value = count;
    }
    catch (ex) {
    }

}


// Add comment
function addComment( customerId, couponId ) {

    var hfCustomer = document.getElementById( hfCustomerId );
    var hfCoupon = document.getElementById( hfCouponId );
   
    hfCustomer.value = customerId;
    hfCoupon.value = couponId;
}


/*
function subscribe(txtSubscriberId) {

    var subscriber = document.getElementById(txtSubscriberId);
    var request = "";
    
    if (subscriber != null) {
        request = subscribeHandler + "?subscriber=" + subscriber.value;
        sendData(request);
        subscriber.value = "";
    }

}
*/



function setCouponCode( clickObject, text, navigateUrl ) {
     _zeroClip.setText(text);

        // reposition the movie over our element
        // or create it if this is the first time
     if (_zeroClip.div) {
         _zeroClip.receiveEvent('mouseout', null);
         _zeroClip.reposition(clickObject);
        }
        else { _zeroClip.glue(clickObject); }

        _navigateUrl = navigateUrl;
       // window.status = navigateUrl;
        
        _zeroClip.addEventListener('onComplete', navigateToCustomer);        // gotta force these events due to the Flash movie
        // moving all around.  This insures the CSS effects
        // are properly updated.
        _zeroClip.receiveEvent('mouseover', null);
 }

 function navigateToCustomer(client, text) 
 {
     window.open(_navigateUrl, "_navigateUrl" );
 }


 function setUrl( customerId ) {

     if (customerId != null) {
         window.status = links[customerId];
     }
    
     return true;
 }

 //Block content
 //Update progress
 function UpdateProgress() {
     var divProgress = document.getElementById("divBackProgress");
     SetPageSize();
     if (divProgress != null) {
         divProgress.style.display = "block";
     }

 }

 // Set page size.
 function SetPageSize() {
     var divProgress = document.getElementById("divBackProgress");
     
     if (divProgress != null) {
         divProgress.style.height = document.body.scrollHeight + + 50 + "px";

     }
 }


 var _zeroClip = new ZeroClipboard.Client();
 _zeroClip.setHandCursor(true);
 var _navigateUrl = "";
 window.onresize = "SetPageSize();"

//Scroller script
 $(function() { var viewer = $('#viewer'); if (viewer != null) { viewer.imageScroller({ next: 'btnScrollNext', prev: 'btnScrollPrev', frame: 'screenShotsFrame', width: 190, child: 'li', auto: true }); } });

