function showfile(file,prodid,inv)
{
var left = (screen.width-430)/2;
var top = 140;
var winShow = window.open("large_photo.asp?file="+ file + "&prodid=" + prodid + "&ssl_invoice_number=" + inv, "LargePhotos","height=100,width=100,left=0,top=0,toolbar=0,status=0");
winShow.focus();
}

function setbilling()
{
document.user.BillingAddress.value=document.user.Address.value;
document.user.BillingCity.value=document.user.City.value;
document.user.BillingState.value=document.user.State.value;
document.user.BillingZipCode.value = document.user.ZipCode.value;
document.user.BillingPhone.value=document.user.Phone.value;
document.user.Phone.focus();
}

//view cart

function removeitem(frm,Cnt,invNum,query)
{
if(confirm('You are about to remove [ ' + document[frm].Product.value + ' ] from the cart\nTo continue click "OK"\nTo stop now click "Cancel"'))
    {
    document[frm].action='removeitem.asp?cnt=' + Cnt + '&ssl_invoice_number=' + invNum + '&invitemid=' + document[frm].id.value + '&query=' + query;
    document[frm].submit();
    }
}

function valItem(frm)
{
if(document[frm].action=='default.asp?query=email_notification' || document[frm].action=='email_notification.asp')
    {
        if(document[frm].email.value=='enter email address')
            {
            alert('invalid email address');
            return false;
            }
        if(document[frm].email.value=='')
            {
            alert('invalid email address');
            return false;
            }
    }

var ValidChars = "0123456789.";
var IsNumber=true;
var Char;
sText = document[frm].Quantity.value;

if(document[frm].Quantity.value=='')
    {
    alert('Invalid quantity');
    return false;
    }

for (i = 0; i < sText.length && IsNumber == true; i++)
{
    Char = sText.charAt(i);
    if (ValidChars.indexOf(Char) == -1)
        {
        IsNumber = false;
        }
}

if(IsNumber == false)
    {
    alert('Invalid quantity');
    return false;
    }
if(parseInt(document[frm].Quantity.value) < parseInt(document[frm].Minimum_Purchase.value))
{
alert('The minimum purchase for this item is ' + document[frm].Minimum_Purchase.value);
return false;
}
return true;
}

//checkout

function setbilling()
{
document.cart.ssl_company.value=document.cart.ssl_ship_to_company.value;
document.cart.ssl_first_name.value=document.cart.ssl_ship_to_first_name.value;
document.cart.ssl_last_name.value=document.cart.ssl_ship_to_last_name.value;
document.cart.ssl_avs_address.value=document.cart.ssl_ship_to_avs_address.value;
document.cart.ssl_city.value=document.cart.ssl_ship_to_city.value;
document.cart.ssl_state.value=document.cart.ssl_ship_to_state.value;
document.cart.ssl_avs_zip.value=document.cart.ssl_ship_to_avs_zip.value;
document.cart.ssl_phone.value=document.cart.ssl_ship_to_phone.value;
}

//Search form

function valSearchFrm()
{
if(document.searchfrm.searchtxt.value=='')
    {
    alert('Invalid search entry');
    return false;
    }
if(document.searchfrm.searchtxt.value=='search by keyword or item #')
    {
    alert('Invalid search entry');
    return false;
    }
return true;    
}

//E-Blast Submission
function Eblastfrm()
{

var str  = trim(document.eblast.EmailAddress.value);
var strSubscriber = trim(document.eblast.Subscriber.value);
var at ="@"
var dot ="."
var lat = str.indexOf(at)
var lstr = str.length
var ldot = str.indexOf(dot)

if(strSubscriber =='')
    {
    alert('Please enter your name');
    return false;
    }
if(strSubscriber =='enter name')
    {
    alert('Please enter your name');
    return false;
    }
if(document.eblast.EmailAddress.value=='')
    {
    alert('Invalid Email Address');
    return false;
    }
if(document.eblast.EmailAddress.value=='enter email')
    {
    alert('Invalid Email Address');
    return false;
    }
    

if (str.indexOf(at)==-1)
    {
    alert("Invalid Email Address")
    return false
    }

if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
    {
    alert("Invalid Email Address")
    return false
    }

if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr)
    {
    alert("Invalid Email Address")
    return false
    }

if (str.indexOf(at,(lat+1))!=-1)
    {
    alert("Invalid Email Address")
    return false
    }

if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
    {
    alert("Invalid Email Address")
    return false
    }

if (str.indexOf(dot,(lat+2))==-1)
    {
    alert("Invalid Email Address")
    return false
    }
        
if (str.indexOf(" ")!=-1)
    {
    alert("Invalid Email Address")
    return false
    }

return true;    
}

function ValidateForm(){
    var emailID=document.frmSample.txtEmail
    
    if ((emailID.value==null)||(emailID.value=="")){
        alert("Please Enter your Email ID")
        emailID.focus()
        return false
    }
    if (echeck(emailID.value)==false){
        emailID.value=""
        emailID.focus()
        return false
    }
    return true
 }

function valReminder()
{
if(document.reminder.ProductID.value=='')
    {
    alert('No Products selected');
    return false;
    }
if(confirm('You are about to add the selected products to your Reminder List.\nTo continue click OK, To stop now click Cancel.'))
    {
    return true;
    }
else
    {
    return false;
    }
}

function paypalbtn2()
{
if(confirm('You have selected Paypal as your payment source.\nTo continue click OK, To stop now click Cancel.'))
    {
    document.paypalscart.submit()
    }
}
function paypalbtn()
{
document.paypalscart.submit();
}

function getSupport()
{
if (document.all)
    {//IS IE 4 or 5 (or 6 beta)
    document.getElementById("support").style.height='400';
    document.getElementById("support-div").style.display ='none';
    top.support.Content.document.Chat.user.value=document.mysupport.user.value
    top.support.Content.document.Chat.ChatEntry.value='request support';
    }

if (document.getElementById &&!document.all)
    {
    sup = document.getElementById("support");
    supdiv =  document.getElementById("support-div");
    sup.style.height = '400px'
    supdiv.style.display ='none';
    //document.getElementById("support").style.height='400';
    //document.getElementById("support-div").style.display ='none';
    top.support.Content.document.Chat.user.value=document.mysupport.user.value
    top.support.Content.document.Chat.ChatEntry.value='request support';
    }
if (document.layers)
    { //IS NETSCAPE 4 or below
    //alert('doc layers');
    }
//document.getElementById("support").style.height='400';
//document.getElementById("support-div").style.display ='none';
top.support.Content.document.Chat.user.value=document.mysupport.user.value
top.support.Content.document.Chat.ChatEntry.value='request support';
top.support.Content.document.Chat.submit();
}

function valProcess()
{

if(document.processfrm.Shipping_Code.value=='')
    {
    alert('Shipping Code is required');
    return false;
    }

if(document.processfrm.Shipping_Date.value=='')
    {
    alert('Shipping Date is required');
    return false;
    }
if(document.processfrm.Email.value=='')
    {
    alert('Email is required');
    return false;
    }
}

function trim(stringToTrim) {
    return stringToTrim.replace(/^\s+|\s+$/g,"");
}
function ltrim(stringToTrim) {
    return stringToTrim.replace(/^\s+/,"");
}
function rtrim(stringToTrim) {
    return stringToTrim.replace(/\s+$/,"");
}

function ShowDiv(divObj)
{
     
var CurDiv = document.getElementById(divObj)
if(CurDiv.style.display == "block")
    {
    CurDiv.style.display = "none"
    }
else
    {
    var divs = document.getElementsByTagName('div') 
    for (var i=0;i<divs.length;i++)
    { 
    if (divs[i].style.display =='block')
        {
        divs[i].style.display ='none'
        }
    }
    
    hza = document.getElementById(divObj);
    hza.style.display = "block" ;
    }
}

function valreview()
{
if(document.reviewsubmit.Rating.value=='0')
    {
    alert('Please enter a rating to continue');
    return false;
    }

if(document.reviewsubmit.CustomerName.value=='')
    {
    alert('Please enter your name to continue');
    return false;
    }
    
if(document.reviewsubmit.ReviewTitle.value=='')
    {
    alert('Please enter a title for your review to continue');
    return false;
    }
    
if(document.reviewsubmit.Comments.value=='')
    {
    alert('Please enter comments to continue');
    return false;
    }
    
if(confirm('You are about to add your review of our services.\nTo continue click OK, To stop now click Cancel.'))
    {
    return true;
    }
else
    {
    return false;
    }
}

function ValPurchaseReview()
{
if(document.customerreview.Rating.value=='0')
    {
    alert('Please enter a rating to continue');
    return false;
    }

if(document.customerreview.CustomerName.value=='')
    {
    alert('Please enter your name to continue');
    return false;
    }

if(document.customerreview.Q1.value=='')
    {
    alert('Please answer question 1 to continue');
    return false;
    }
    
if(document.customerreview.Q2.value=='')
    {
    alert('Please answer question 2 to continue');
    return false;
    }

if(document.customerreview.Q3.value=='')
    {
    alert('Please answer question 1 to continue');
    return false;
    }
        
if(confirm('You are about to submit your review of our services.\nTo continue click OK, To stop now click Cancel.'))
    {
    return true;
    }
else
    {
    return false;
    }
}

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-19081991-2']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();



