

var _g_eceDefCookieName = "_eceCartv2_" + "6888";
var _g_eceDefCookieMax = 5; 
var _g_eceDefCookieSizeMax = 4000; 
var _g_eceDefExpDate = new Date();
_g_eceDefExpDate.setTime(new Date().getTime() + (2 * 24 * 60 * 60 * 1000));

function _eceGetSubDomain()
{
    if (document.getElementById && location && location.hostname)
    {
        var _eceUseDomain = location.hostname.toLowerCase();
        var _eceUseDomainArray = _eceUseDomain.split(".");

        if (_eceUseDomainArray.length >= 2)
        {
            if (_eceUseDomainArray[_eceUseDomainArray.length - 1].length >= 2)
            {
                if (isNaN(_eceUseDomainArray[_eceUseDomainArray.length - 1]))
                {
			var _eceTmpDomainStr = _eceUseDomainArray[_eceUseDomainArray.length - 2] + "." + _eceUseDomainArray[_eceUseDomainArray.length - 1];
					
			if ((_eceUseDomainArray[_eceUseDomainArray.length - 2].length <= 2 || _eceUseDomainArray[_eceUseDomainArray.length - 2] == "com") && _eceUseDomainArray.length > 2)
				_eceTmpDomainStr = _eceUseDomainArray[_eceUseDomainArray.length - 3] + "." + _eceTmpDomainStr;
						
			return ("; domain=." + _eceTmpDomainStr);

                    	//return ("; domain=." + _eceUseDomainArray[_eceUseDomainArray.length - 2] + "." + _eceUseDomainArray[_eceUseDomainArray.length - 1]);
                }
            }
        }
    }
    
    return "";
}

function _eceGetCookie (cookieName)
{
    var retStr = "";
    if (document.cookie)
    {
        if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
        var cookieArray = document.cookie.split(";")
        var nCount = 0;

        for (var n = 0; n < cookieArray.length; n++)
        {
            while(cookieArray[n].charAt(0) == ' '){cookieArray[n] = cookieArray[n].substring(1)}
            if (cookieArray[n].indexOf(cookieName) == 0)
            {
                retStr += cookieArray[n].substring(cookieName.length+1 + (nCount > 0 ? 1 : 0));
                nCount++;
            }
        }
    }

    return retStr;
}


function _eceWriteCookie (cookieValue, cookieName)
{

    if (cookieValue.length > (_g_eceDefCookieMax * _g_eceDefCookieSizeMax))
    {
        alert("Maximum cart size exceeded.");
        return "";
    }

    if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
    _eceResetCart(cookieName);
            
    for (var n = 0; n < _g_eceDefCookieMax; n++)
    {
         if ( cookieValue.length > _g_eceDefCookieSizeMax)
         {
            var setCookie = cookieName + (n > 0 ? n : "") + "=" + cookieValue.substring(0, _g_eceDefCookieSizeMax);
            document.cookie = setCookie + "; expires=" + _g_eceDefExpDate.toGMTString() + "; path=/" + _eceGetSubDomain();
            cookieValue = cookieValue.substring(_g_eceDefCookieSizeMax);
         }
         else
         {
            var setCookie = cookieName + (n > 0 ? n : "") + "=" + cookieValue;
            document.cookie = setCookie + "; expires=" + _g_eceDefExpDate.toGMTString() + "; path=/" + _eceGetSubDomain();
            break;
         }
    }

    return "";
}

function _eceResetCart(cookieName)
{
    if (!cookieName)
            cookieName = _g_eceDefCookieName;
            
    var cookieArray = document.cookie.split(";")
    
    for (var n = 0; n < cookieArray.length; n++)
    {
        while(cookieArray[n].charAt(0) == ' '){cookieArray[n] = cookieArray[n].substring(1)}
        
        for (var x = 0; x < _g_eceDefCookieMax; x++)
        {
            var useCookiename = cookieName + (x > 0 ? x : "") + "=";
            if (cookieArray[n].indexOf(useCookiename) == 0)
                document.cookie = useCookiename + "" + "; expires=-1; path=/" + _eceGetSubDomain();
        }
    }
}


var _g_eceDefCartButton = "http://allbackgroundchecks.safestorefront.com/images/sample_add.jpg";
var _g_eceMerchantID = "6888";
var _g_eceCartButton = "";
var _g_ecePostAddLink = "ViewCart.aspx?m=6888";
var _g_eceDefQtyText = "Quantity:";
var _g_eceImgAltText = 'alt="' + "Add To Cart" + '"';
var _g_eceQtyText = "Quantity:";

if (!_g_eceQtyText)
    _g_eceQtyText = _g_eceDefQtyText;
    
if (_g_eceCartButton)
    _g_eceImgAltText = "";
else
    _g_eceCartButton = _g_eceDefCartButton;
    
function _eceAttributeOptionsStructure(ID, name, priceUnit, price, displayOrder, selected)
{
    this.ID = ID;
    this.name = name;
    this.priceUnit = priceUnit;
    this.price = price;
    this.displayOrder = displayOrder;
    this.selected = selected;
}

function _eceAttributeStructure(name, type, displayOrder, options)
{
    this.name = name;
    this.type = type;
    this.displayOrder = displayOrder;
    this.options = options
}

function _eceProductStructure(ID, name, description, price, shipping, attributesString, attributes)
{
    this.ID = ID;
    this.name = name;
    this.description = description;
    this.price = price;
    this.shipping = shipping;
    this.attributesString = attributesString;
    this.attributes = attributes;
}

function _eceAttributeInputStructure(ID, input)
{
    this.ID = ID;
    this.input = input;
}

var _g_eceProductArray = new Array();

_g_eceProductArray[0] = new _eceProductStructure("131472", "National Instant Criminal &amp; Sex Offender + Social Security Number Validation Trace - $10.00", "1. All States Instant Criminal + Violent Sex Offender Search ($10.00 purchase as a single Search)  2. Social Security Number Validation Trace + Past Address History:  $3.75 (purchased as a single Search)  <br>    <br>Nothing provides better instant coverage of the United States than the All States Instant Criminal Violent Sex Offender Search. With one search, you can comb more than 300 million criminal records from counties, Department of Corrections (DOC), Administration of the Court (AOC) and State Sex Offender registries covering 49 states and Washington DC, Guam and Puerto Rico.<br><br>Also included are national and international terrorism sources, more than 3.1 million photos and our proprietary database of previously completed reports. This Search provides the data you want, the quality you demand, and the updates that ensure you get the best possible information<br><br>2. Ths SSN Validation Trace + Address History is an important first step when conducting a background check.  The Social Security Number Trace verifies the applicants social security number (SSN) against third party databases for use, validity in format, past and present address information as well as reporting any alias names used; married, maiden, etc.  The Social Security Number Trace will in most cases also report dates addresses and names were used.  <br><br>The Social Security Number Trace is excellent for uncovering information that may not have been disclosed by the applicant.  It will help determine where research may be needed based on the address history of the applicant.  It's the number one tool to help determine where to search for criminal records. <br><br>*Applicant Release Form:  Required by the Fair Credit Reporting Act(FCRA) and enforced by the Federal Trade Commission(FTC) to Protect Consumers Privacy Rights.  To conduct a Pre-employment or Tenant Screening Reports this Form is mandatory to be in compliance with the FCRA and Federal and State Law.<br><br>You can download the form by copying and pasting the following link into your browser to download and print on 1 Page.<br><br>http://people-checks.com/ApplicantReleaseForm.aspx <br><br>The Form takes an average of 5 - 7 minutes for an Applicant to complete. After completion Fax the Form toll free to 1-877-777-5121 or e-mail to info@people-checks.com. After receipt of the form we will Process and send the Results to your preference of Fax or E-mail in 45 minutes.<br><br>*We do not Search Social Security Numbers. Social Security Number are voluntarily given on a signed Applicant Release Form by the Applicant/Subject of the Search. ", "$10.00", "$0.00", '', new Array ());



function _eceAddToCart(itemID, itemQty, linkThrough, _ecePostAddLink, formObj, attCounter)
{
    _ecePostAddLink = unescape(_ecePostAddLink);
 
    if (itemQty.length == 0)
    {
        alert("Quantity cannot be empty.");
        return false;
    }
    else if (isNaN(itemQty))
    {
        alert("Quantity must be numeric.");
        return false;
    }
    else if (parseInt(itemQty) < 1)
    {
        alert("Quantity must be greater than 0.");
        return false;
    }
        
    var currentName = _eceGetCookie();
    var newProdArray = new Array()
    var bFound = false;
    var attribArray = new Array();
    
    if (formObj && attCounter)
    {
        for (n = 0; n < formObj.elements.length; n++)
        {
            var baseName = "a" + attCounter + "-";
            if (formObj.elements[n].name.indexOf(baseName) == 0)
            {

                switch(formObj.elements[n].type)
                {
                case "select-one":
                case "select-multiple":
                    for (var x = 0; x < formObj.elements[n].options.length; x++)
                    {
                        if (formObj.elements[n].options[x].selected)
                            attribArray[attribArray.length] = formObj.elements[n].options[x].value;
                    }
                    
                    break;
                case "radio":
                case "checkbox":
                    if (formObj.elements[n].checked)
                        attribArray[attribArray.length] = formObj.elements[n].value;
                    break;
                    
                case "text":
                case "textarea":
                    if (formObj.elements[n].value.replace(/\s/g, "").length > 0)
                    {
                        var name = formObj.elements[n].name.split("-");
                        if (name.length == 3)
                            attribArray[attribArray.length] = name[2] + "=" + escape(formObj.elements[n].value);
                    }
                    break;
                }
            }
        }
        
    }
    
    if(currentName.length > 0)
    {
        var prodArray = currentName.split(",")
        for (var n = 0; n < prodArray.length; n++)
        {
            var inputsMatch = true;
            var localFound = false;
            var item = prodArray[n].split(":")
            if (item.length == 2)
                item[2] = "";
            if (item.length == 3)
            {
                if (item[0] == itemID && item[2] == attribArray.join("&"))
                {
                    var newQty = parseInt(item[1]) + parseInt(itemQty)
                    newProdArray[newProdArray.length] = item[0] + ":" + newQty + ":" + item[2];
                    bFound = true;
                }
                else if (item[0] != 'm')
                    newProdArray[newProdArray.length] = item[0] + ":" + item[1] + ":" + item[2];
            }
        }
    }
    
    if (!bFound)
    {
        newProdArray[newProdArray.length] = itemID + ":" + itemQty + ":" + attribArray.join("&");
    }
    
    var cookie = newProdArray.join(",");
    _eceWriteCookie (cookie);
    
    //    if (document.getElementById && !_ecePostAddLink)
    //        linkThrough = false;
            
    var postAddLink = (_ecePostAddLink ? _ecePostAddLink : location.href);
        
    if (linkThrough)
        location.href = postAddLink;
    else
    {
        if (typeof(this._eceDisplayMiniCart) != 'undefined')
        {
            if (typeof(this._eceDisplayMiniCart) == 'function')
                _eceDisplayMiniCart(true);
        }
    }
}


function _eceWriteProduct(useQty, useProductInfo)
{
    var _ecePostAddLink = escape(_g_ecePostAddLink);
    
    for (var n = 0; n < _g_eceProductArray.length; n++)
    {
        document.writeln('<form method="post" name="_eceAddToCartForm' + _g_eceProductArray[n].ID + '" action="'+location.href+'" onsubmit="_eceAddToCart('+_g_eceProductArray[n].ID+', this.quantity.value, true, \''+_ecePostAddLink+'\', this, ' + (n+1) + ');return(false)">');
        document.writeln('<table cellpadding="3" cellspacing="3">');
        
        if (useProductInfo)
        {
 
            document.writeln('<tr><td align="right">' + 
                            _g_eceProductArray[n].name +
                            '</td></tr><tr><td align="right">' +
                            _g_eceProductArray[n].price +
                            '</td></tr>');
                         
 


        }
        
        document.writeln('<tr><td align="right">' +
                            _g_eceProductArray[n].attributesString +
                            '</td></tr>');
        
        if (useQty)
        {
            document.write('<tr><td align="right">');

            document.write('<b>'+_g_eceQtyText+' </b><input type="text" name="quantity" value="1" maxlength="4" size="4" />' +
                                '</td></tr><tr><td align="right"><input type="image" src="'+_g_eceCartButton+'" border="0"  '+_g_eceImgAltText+'/>');
 
   
            document.write('</td></tr>');         
        }
        else              
        {
            document.write('<tr><td align="right"><input type="image" src="'+_g_eceCartButton+'" border="0"  '+_g_eceImgAltText+'/>' + 
                            '<input type="hidden" name="quantity" value="1" /></td></tr>');
                          
        }
    
        document.writeln('</table>');
        
        document.writeln('</form>');
    }
}


