﻿
/* Cookies */
function get_cookie(Name) {
    var search = Name + "=";
    var returnvalue = "";
    if (document.cookie.length > 0) {
        offset = document.cookie.indexOf(search);
        if (offset != -1) {
            offset += search.length;
            end = document.cookie.indexOf(";", offset);
            if (end == -1) end = document.cookie.length;
            returnvalue = unescape(document.cookie.substring(offset, end));
        }
    }
    return returnvalue;
}

function set_cookie(name, value, days, path, domain, secure) {
    var cookie_string = name + "=" + encodeURIComponent(value);

    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        cookie_string += "; expires=" + date.toGMTString();
    }
    if (path)
        cookie_string += "; path=" + escape(path);

    if (domain)
        cookie_string += "; domain=" + escape(domain);

    if (secure)
        cookie_string += "; secure";
    // alert('in set cookie name='+name +' *** cookie_string='+cookie_string);
    document.cookie = cookie_string;
}
function delete_cookie(cookie_name) {
    var cookie_date = new Date();  // current date / time
    cookie_date.setTime(cookie_date.getTime() - 1);
    document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
}
/* End Cookies */



//In order for this to work Google AdWords must be linked to Google Analytics and Auto-Tagging on
var ContactPhoneNumber = "(718) 921-6601"; //normal office number
var PPC_Traffic = get_cookie("PPC_Traffic");
if (PPC_Traffic != "Yes") {//if ppc traffic skip all this code
        if (document.URL.indexOf("gclid") != -1) { //check the current document querystring
        
            //alert("this is a PPC");
            set_cookie("PPC_Traffic", "Yes", 30, "/");
            //google voice number show
            ContactPhoneNumber = "(347)-850-4529"; //347-850-4LAW (4529)
        }
}
else {
    //google voice number show
    ContactPhoneNumber = "(347)-850-4529"; //347-850-4LAW (4529)
}
//wherever contact number appears on website paste this code:
//<script type="text/javascript">document.write(ContactPhoneNumber);</script><noscript>(718) 921-6601</noscript>

//test
//alert(document.URL);
