
function fn_tabnav(tabid){var tabi=1;var tabnavtemp1="";var tabcolorArray=new Array(5);tabcolorArray[0]="4B6870";tabcolorArray[1]="1B2224";tabcolorArray[2]="660000";tabcolorArray[3]="574C43";tabcolorArray[4]="705740";if(tabid==6)
{$('autoship').className='visibleTab';}
else
{$('autoship').className='hiddenTab';}
for(tabi=1;tabi<=5;tabi++)
{tabnavtemp1=document.getElementById('tabnav'+tabi);if(tabi==tabid){document.getElementById('tabnav'+tabi).style.height=25;document.getElementById('tabnav'+tabi).style.marginTop=0;document.getElementById('tabnav'+tabi).style.border="1px solid #D3DCDF";tabnavtemp1.onmouseout=function(){}
tabnavtemp1.onmouseover=function(){}
document.getElementById('subtabnav'+tabi).style.paddingTop=5;$('tab'+tabi).className='visibleTab';}
else{document.getElementById('tabnav'+tabi).style.height=19;document.getElementById('tabnav'+tabi).style.marginTop=3;document.getElementById('tabnav'+tabi).style.borderTop=0;document.getElementById('tabnav'+tabi).style.borderBottom=0;document.getElementById('tabnav'+tabi).style.borderRight="1px solid #"+tabcolorArray[tabi-1];document.getElementById('tabnav'+tabi).style.borderLeft="1px solid #"+tabcolorArray[tabi-1];tabnavtemp1.onmouseout=function(){this.style.height=19;this.style.marginTop=3;this.firstChild.style.paddingTop=2;}
tabnavtemp1.onmouseover=function(){this.style.height=25;this.style.marginTop=0;this.firstChild.style.paddingTop=5;this.style.cursor='pointer';}
document.getElementById('subtabnav'+tabi).style.paddingTop=2;$('tab'+tabi).className='hiddenTab';}}}
function getHoverBox(prodID)
{if($(prodID+'hoverBasedone'))
{}
else
{$(prodID+'infoBox').style.display='inline';var pars='prodID='+prodID;var url='/sflib/searchHover.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){if($(prodID+'infoBox'))
{$(prodID+'infoBox').innerHTML=txt;$(prodID+'infoBox').style.height='auto';$(prodID+'hoverBase').id=prodID+'hoverBasedone';}}}).request();}}
function IsNumeric(sText)
{var ValidChars="0123456789.";var IsNumber=true;var Char;for(i=0;i<sText.length&&IsNumber==true;i++)
{Char=sText.charAt(i);if(ValidChars.indexOf(Char)==-1)
{IsNumber=false;}}
return IsNumber;}
function throwPopup(product,loggedIn)
{var answer=confirm("Welcome to CI's Auto-Ship Program, a convenient tool that allows you to setup automatic shipments at regular intervals. \n\nClick OK to login into your Auto-Ship account.");if(answer)
{if(loggedIn==0)
{window.location=sVar+"/ssl/accountLogin.asp?autoShip=1&product="+product;}
else
{window.location=sVar+"/ssl/accountAutoship.asp?product="+product;}}
else
{}}
function addFav(prodID)
{var pars='cmd=add&prodID='+prodID;var url='/sflib/addFav.asp?'+pars;var myAJAX=new Ajax(url,{method:'get',onComplete:function(txt,xml){}}).request();$(prodID+"fav").innerHTML="<a href=\""+sVar+"/ssl/accountFavorites.asp\"><img src=\"./graphics/checkmark2.gif\" border=\"0\"></a>";}
function fillTab(productPageType,requestedItem,tCheck,baseSku,orderProd)
{var pars='productPageType='+productPageType+'&requestedItem='+requestedItem+'&tCheck='+tCheck+'&baseSku='+baseSku+'&orderProd='+orderProd;var url='/sflib/fillTab.asp';new Ajax(url,{method:'get',data:pars,update:$("tab1")}).request();}
function fillTab2(tabNumber,productPageType,requestedItem,tCheck,prodQuerySku,intPage)
{var pars='productPageType='+productPageType+'&Item='+requestedItem+'&tCheck='+tCheck+'&NAV='+intPage+'&prodQuerySku='+prodQuerySku+'&intpage='+intPage;var url='/sflib/incProdTestimonial.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$("tab4").innerHTML=txt;if(txt.indexOf(" ")==-1)
{$("tabnav4").style.display='none';}
else
{$("tabnav4").style.visibility='visible';}}}).request();}
function fillTabmp3(baseSku,productPageType,requestedItem,tCheck,prodQuerySku,intPage)
{var pars='baseSku='+baseSku+'&productPageType='+productPageType+'&Item='+requestedItem+'&requestedItem='+requestedItem+'&tCheck='+tCheck+'&NAV='+intPage+'&prodQuerySku='+prodQuerySku+'&intpage='+intPage;var url='/sflib/mp3tab.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$("tab5").innerHTML=txt;if(txt.indexOf("mp3")==-1)
{$("tabnav5").style.display='none';}
else
{$("tabnav5").style.visibility='visible';}}}).request();}
function fillTabautoship(baseSku,productPageType,requestedItem,tCheck,prodQuerySku,intPage)
{var pars='baseSku='+baseSku+'&productPageType='+productPageType+'&Item='+requestedItem+'&requestedItem='+requestedItem+'&tCheck='+tCheck+'&NAV='+intPage+'&prodQuerySku='+prodQuerySku+'&intpage='+intPage;var url='/sflib/autoshiptab.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$("autoship").innerHTML=txt;}}).request();}
function fillTab4(tabNumber,baseSku,productPageType,requestedItem,tCheck,prodQuerySku,intPage)
{var pars='baseSku='+baseSku+'&productPageType='+productPageType+'&Item='+requestedItem+'&requestedItem='+requestedItem+'&tCheck='+tCheck+'&NAV='+intPage+'&prodQuerySku='+prodQuerySku+'&intpage='+intPage;var url='/sflib/staffReviewTab.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$("tab2").innerHTML=txt;if(txt.indexOf("PICK")==-1)
{$("tabnav2").style.display='none';}
else
{$("tabnav2").style.visibility='visible';}}}).request();}
function fillTab5(tabNumber,baseSku,productPageType,requestedItem,tCheck,prodQuerySku,intPage)
{var pars='baseSku='+baseSku+'&productPageType='+productPageType+'&item='+requestedItem+'&tCheck='+tCheck+'&NAV='+intPage+'&prodQuerySku='+prodQuerySku+'&intpage='+intPage;var url='/sflib/freebieTab.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$("tab3").innerHTML=txt;if(txt.indexOf("freebie Image")==-1)
{$("tabnav3").style.display='none';}
else
{$("tabnav3").style.visibility='visible';}}}).request();}
function getAutoShip(prodID)
{var qtyElement=$('qty'+prodID.replace(new RegExp("-","g"),"")).value;if(qtyElement=="")
{qtyElement=1;$('qty'+prodID.replace(new RegExp("-","g"),"")).value=1;}
else if(!IsNumeric(qtyElement))
{alert("Please enter a quantity that is numeric.");return false;}
var pars='cmd=get&prodID='+prodID+'&autoID='+aSID+'&quantity='+qtyElement;var url='/sflib/getAutoShip.asp?'+pars;new Ajax(url,{method:'get',onComplete:function(txt,xml){$(prodID.replace(new RegExp("-","g"),"")+"auto").innerHTML="<a href=\"javascript:;\" onclick=\"getAutoShip('"+prodID+"');\"  class=\"acNavLink\"><img src=\"./graphics/icon_auto_added.gif\" alt=\"autoship\" border=\"0\"></a>";}}).request();}
function isBlank(val){if(val==null){return true;}
for(var i=0;i<val.length;i++){if((val.charAt(i)!=' ')&&(val.charAt(i)!="\t")&&(val.charAt(i)!="\n")&&(val.charAt(i)!="\r")){return false;}}
return true;}
function checkNewEmail(emailval){var RegExp=/^\w+([\.&-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;if(!RegExp.test(emailval)){return false;}
else{return true;}}
function checkLogon(returningCust){if(isBlank(returningCust.email.value)==true)
{alert("\nPlease enter the Email Address associated with your account.")
returningCust.email.focus()
returningCust.email.select()
return false;}
if(checkNewEmail(returningCust.email.value)==false)
{alert("\nPlease enter a valid Email Address.")
returningCust.email.focus()
returningCust.email.select()
return false;}
if(isBlank(returningCust.pass.value)==true)
{alert("\nPlease enter your password.")
returningCust.pass.focus()
returningCust.pass.select()
return false;}
return true;}
function checkNewUser(newCust){if(isBlank(newCust.newemail.value)==true)
{alert("\nPlease enter an Email Address.")
newCust.newemail.focus()
newCust.newemail.select()
return false;}
if(checkNewEmail(newCust.newemail.value)==false)
{alert("\nPlease enter a valid Email Address.")
newCust.newemail.focus()
newCust.newemail.select()
return false;}
if(isBlank(newCust.pass1.value)==true)
{alert("\nPlease enter a password.")
newCust.pass1.focus()
newCust.pass1.select()
return false;}
if(newCust.pass1.value.length<3)
{alert("\nYour password must be greater than 2 characters.")
newCust.pass1.focus()
newCust.pass1.select()
return false;}
if(newCust.pass1.value!=newCust.pass2.value)
{alert("\nYour passwords do not match. Please re-enter your passwords.")
newCust.pass1.focus()
newCust.pass1.select()
return false;}
return true;}
function addToCart(prodID,qty,pigid)
{if(typeof pigid=='undefined')pigid='';if(qty=='')
{qty=1;$('qty'+prodID.replace(new RegExp("-","g"),"")).value='1';}
if(!IsNumeric(qty))
{alert('Quantity entered must be a number.');return false;}
var pars='cmd=add&prodID='+prodID+'&qty='+qty+'&pigID='+pigid;var url='/sflib/addToCart.asp?'+pars;$("loadingDiv").style.display="inline";new Ajax(url,{method:'get',onComplete:function(txt,xml){var cartValues=txt.split('|');var pars='';var url='/sflib/populateCart.asp';$("cartTotalCost").innerHTML="Item Total: "+cartValues[0];$("basketCount").innerHTML=cartValues[1]+" ";new Ajax(url,{method:'get',onComplete:function(txt,xml){$("slideOutCart").innerHTML=txt;stretch.hide();stretch.toggle();}}).request();setTimeout("stretch.slideOut();",5000);$("loadingDiv").style.display="none";$('qty'+prodID.replace(new RegExp("-","g"),"")).value='';$(prodID.replace(new RegExp("-","g"),"")+"cart").innerHTML="<img src=\"/graphics/bta-addagain.gif\" border=\"0\" height =\"15\" width=\"56\" style='cursor:pointer;' onclick=\"this.attributes['onclick'].value = ''; this.src='"+nsVar+"/graphics/bta-adding.gif'; stretch.slideOut();  addToCart('"+prodID+"', document.getElementById('qty"+prodID.replace(new RegExp("-","g"),"")+"').value);\">";}}).request();}
function addToCartBLK(prodID,qty,pigid)
{if(typeof pigid=='undefined')pigid='';if(qty=='')
{qty=1;$('qty'+prodID.replace(new RegExp("-","g"),"")).value='1';}
if(!IsNumeric(qty))
{alert('Quantity entered must be a number.');return false;}
var pars='cmd=add&prodID='+prodID+'&qty='+qty+'&pigID='+pigid;var url='/sflib/addToCart-blk.asp?'+pars;$("loadingDiv").style.display="inline";new Ajax(url,{method:'get',onComplete:function(txt,xml){var cartValues=txt.split('|');var pars='';var url='/sflib/populateCart.asp';$("cartTotalCost").innerHTML="Item Total: "+cartValues[0];$("basketCount").innerHTML=cartValues[1]+" ";new Ajax(url,{method:'get',onComplete:function(txt,xml){$("slideOutCart").innerHTML=txt;stretch.hide();stretch.toggle();}}).request();setTimeout("stretch.slideOut();",5000);$("loadingDiv").style.display="none";$('qty'+prodID.replace(new RegExp("-","g"),"")).value='';$(prodID.replace(new RegExp("-","g"),"")+"cart").innerHTML="<img src=\"/graphics/bta-addagain.gif\" border=\"0\" height =\"15\" width=\"56\" style='cursor:pointer;' onclick=\"this.attributes['onclick'].value = ''; this.src='"+nsVar+"/graphics/bta-adding.gif'; stretch.slideOut();  addToCart('"+prodID+"', document.getElementById('qty"+prodID.replace(new RegExp("-","g"),"")+"').value);\">";}}).request();}
function yptAddToCartSpec(yptProdList,yptPickCount,yptOfferID,buttonID,yptMinVal,sampCount)
{var pars;if(sampCount==yptMinVal&&yptMinVal<yptPickCount)
{pars='cmd=add&yptProdList='+yptProdList+'&ypt='+yptMinVal+'&yptID='+yptOfferID+'&qty=1';}
else
{pars='cmd=add&yptProdList='+yptProdList+'&ypt='+yptPickCount+'&yptID='+yptOfferID+'&qty=1';}
var url='/sflib/addToCart.asp?'+pars;$("loadingDiv").style.display="inline";new Ajax(url,{method:'get',onComplete:function(txt,xml){var cartValues=txt.split('|');var pars='';var url='/sflib/populateCart.asp';$("cartTotalCost").innerHTML="Item Total: "+cartValues[0];$("basketCount").innerHTML=cartValues[1]+" ";new Ajax(url,{method:'get',onComplete:function(txt,xml){$("slideOutCart").innerHTML=txt;stretch.hide();stretch.toggle();}}).request();setTimeout("stretch.slideOut();",5000);$("loadingDiv").style.display="none";if(buttonID=='checkout')
{window.location='/order.asp';}
$('yptCart').innerHTML="<img src=\"/graphics/bta-addtocartLarge.gif\" border=\"0\" height =\"25\" width=\"130\" style='cursor:pointer;' onclick=\"this.attributes['onclick'].value = ''; this.src='"+nsVar+"/graphics/bta-addingLarge.gif'; stretch.slideOut();  yptCheckCart("+yptOfferID+",'cart', "+yptMinVal+");\">";}}).request();}

function yptCheckCart(yptOfferID,bID,yptMinVal)
{var yptPickCount=document.getElementById('yptPickCount').value;var rProdCount=document.getElementById('yptProdCount').value;var yptProductList='';var noAdd=0;var sampCount=0;var currentElement='';for(x=1;x<=rProdCount;x++)
{xtemp=x;if(x<10)
{xtemp='0'+x;}
currentElement='prodSku'+xtemp;if(document.getElementById(currentElement))
{if(document.getElementById(currentElement).checked==true)
{if(yptProductList.length>0)
{yptProductList=yptProductList+','+document.getElementById(currentElement).value;}
else
{yptProductList=document.getElementById(currentElement).value;}
sampCount++;}}}
if((sampCount==yptPickCount)||(sampCount==yptMinVal))
{yptAddToCartSpec(yptProductList,yptPickCount,yptOfferID,bID,yptMinVal,sampCount);}
else
{if(bID=='checkout')
{window.location='/order.asp';}
else
{if(yptMinVal!=yptPickCount)
{alert('This offer is limited to '+yptMinVal+' OR '+yptPickCount+' picks. If you wish to change your selection please un-check the product you no longer want and select a new one.');}
else
{alert('This offer is limited to '+yptPickCount+' picks. If you wish to change your selection please un-check the product you no longer want and select a new one.')}
if(bID=='cart')
{$('yptCart').innerHTML="<img src=\"/graphics/bta-addtocartLarge.gif\" border=\"0\" height =\"25\" width=\"130\" style='cursor:pointer;' onclick=\"this.attributes['onclick'].value = ''; this.src='/graphics/bta-addinglarge.gif'; stretch.slideOut(); yptCheckCart("+yptOfferID+",'cart', "+yptMinVal+");\">";}
return false;}}
clearChecks();return true;}

function clearChecks()
{var rProdCount=document.getElementById('yptProdCount').value;var currentElement='';for(x=1;x<=rProdCount;x++)
{xtemp=x;if(x<10)
{xtemp='0'+x;}
currentElement='prodSku'+xtemp;document.getElementById(currentElement).checked=false;}
if(document.getElementById('prodSku01').value=='M-CIMISC5'||document.getElementById('prodSku01').value=='SP-4KB7257-M-2'||document.getElementById('prodSku01').value=='SP-ZTA6060-XX-1'||document.getElementById('prodSku01').value=='SP-4KASST12'||document.getElementById('prodSku01').value=='SP-GGC6552-1'||document.getElementById('prodSku01').value=='SP-G2PASST1'||document.getElementById('prodSku01').value=='SP-CIDD125'||document.getElementById('prodSku01').value=='SP-G2PASST2'||document.getElementById('prodSku01').value=='SP-CIDD138'||document.getElementById('prodSku01').value=='SP-CIDD147'||document.getElementById('prodSku01').value=='SP-CIDD152')
{document.getElementById('prodSku01').checked=true;}
return true;}

function updateCount(objID)
{var rProdCount=document.getElementById('yptProdCount').value;var rPickCount=document.getElementById('yptPickCount').value;var sampCount=0;var currItem='prodSku'+objID;var currentElement='';for(x=1;x<=rProdCount;x++)
{xtemp=x;if(x<10)
{xtemp='0'+x;}
currentElement='prodSku'+xtemp;if(document.getElementById(currentElement))
{if(document.getElementById(currentElement).checked==true)
{sampCount=sampCount+1;}}}
if(sampCount>rPickCount)
{alert('This offer is limited to '+rPickCount+' picks. If you wish to change your selection please un-check the product you no longer want and select a new one.');document.getElementById(currItem).checked=false;return false;}
else
{return true;}}

function popUpProdInfo(baseImage)
{var popoptions;var url;url='prodDetailPopup.asp?imgPic='+baseImage+'&details=1';popoptions='toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=yes,width=650,height=625,left=50,top=50';imageWin=window.open(url,'imageEnlarge',popoptions);}
function showAndHide(curObjNumber,cieling,curobj,subobjstr,opt_position)
{var loopControl=0;var disableObj;curobj.style.borderBottom='#FFFFFF';curobj.style.color='#FFFFFF';counter2=curObjNumber;while(loopControl<cieling)
{if(loopControl!=curObjNumber)
{if(document.getElementById("thumbnail"+loopControl))
{disableObj=document.getElementById("thumbnail"+loopControl);disableObj.style.borderBottom='#e5e5e5';disableObj.style.display="none";}}
loopControl=loopControl+1;}
var subobj=document.getElementById(subobjstr);subobj.style.display="block";}
function showAndHide2(curObjNumber,cieling,curobj,subobjstr,opt_position)
{var loopControl=0;var disableObj;curobj.style.borderBottom='#FFFFFF';curobj.style.color='#FFFFFF';counter2=curObjNumber;while(loopControl<=cieling)
{if(loopControl!=curObjNumber)
{if(document.getElementById("thumbnail"+loopControl))
{disableObj=document.getElementById("thumbnail"+loopControl);disableObj.style.borderBottom='#e5e5e5';disableObj.style.display="none";}}
loopControl=loopControl+1;}
var subobj=document.getElementById(subobjstr);subobj.style.display="block";}

function yptCheckCartHoliday(yptOfferID,bID,yptMinVal)
{var yptPickCount=document.getElementById('yptPickCount').value;var rProdCount=document.getElementById('yptProdCount').value;var yptProductList='';var noAdd=0;var sampCount=0;var currentElement='';for(x=1;x<=rProdCount;x++){xtemp=x;
if(x<10){xtemp='0'+x;}currentElement='prodSku'+xtemp;
if(document.getElementById(currentElement))
{if(document.getElementById(currentElement).checked==true)
{if(yptProductList.length>0){yptProductList=yptProductList+','+document.getElementById(currentElement).value;}
else{yptProductList=document.getElementById(currentElement).value;}sampCount++;}}}
if((sampCount==yptPickCount)||(sampCount==yptMinVal)){yptAddToCartSpec(yptProductList,yptPickCount,yptOfferID,bID,yptMinVal,sampCount);
if(bID=='checkout')
{window.location='/order.asp';}}
else
{if(bID=='checkout'){window.location='/order.asp';}
else
{alert('Please pick one (1) item from each category to proceed.');
if(bID=='cart'){$('yptCart').innerHTML="<img src=\"/graphics/bta-addtocartLarge.gif\" border=\"0\" height =\"25\" width=\"130\" style='cursor:pointer;' onclick=\"this.attributes['onclick'].value = ''; this.src='/graphics/bta-addinglarge.gif'; stretch.slideOut(); yptCheckCartHoliday("+yptOfferID+",'cart', "+yptMinVal+");\">";}return false;}}clearChecks();return true;}

function updateYPTCount(objID,prodSample)
{var rProdCount = document.getElementById('yptProdCount').value;var rPickCount = document.getElementById('yptPickCount').value;	var sampCount = 0;var currItem = 'prodSku' + objID;var currentElement = '';var SampSelected = 0;var HumiSelected = 0;var CutterSelected = 0;var LighterSelected = 0;for(x=1; x<=12; x++){xtemp = x;
if(x < 10){xtemp = '0'+x;}currentElement = 'prodSku' + xtemp;
if (document.getElementById(currentElement)) 
{if (document.getElementById(currentElement).checked == true)
{if(SampSelected == 1){SampSelected = 2;}
else{SampSelected = 1;}sampCount = sampCount + 1;}}}for(x=13; x<=22; x++){xtemp = x;
if(x < 10){xtemp = '0'+x;}currentElement = 'prodSku' + xtemp;
if (document.getElementById(currentElement))
{if (document.getElementById(currentElement).checked == true)
{if(HumiSelected == 1){HumiSelected = 2;}
else{HumiSelected = 1;}sampCount = sampCount + 1;}}}for(x=23; x<=25; x++){xtemp = x;
if(x < 10){xtemp = '0'+x;}currentElement = 'prodSku' + xtemp;
if (document.getElementById(currentElement))
{if (document.getElementById(currentElement).checked == true)
{if(CutterSelected == 1){CutterSelected = 2;}
else{CutterSelected = 1;}sampCount = sampCount + 1;}}}for(x=26; x<=29; x++){xtemp = x;
if(x < 10){xtemp = '0'+x;}currentElement = 'prodSku' + xtemp;
if (document.getElementById(currentElement)){
if (document.getElementById(currentElement).checked == true)
{if(LighterSelected == 1){LighterSelected = 2;}
else{LighterSelected = 1;}sampCount = sampCount + 1;}}}
if(SampSelected > 1){alert('You may only pick one sampler from the list. If you wish to change your selection please un-check the product you no longer want and select a new one.');document.getElementById(currItem).checked = false;return false;}
else if(HumiSelected > 1){alert('You may only pick one humidor from the list. If you wish to change your selection please un-check the product you no longer want and select a new one.');document.getElementById(currItem).checked = false;return false;}	
else if(CutterSelected > 1){alert('You may only pick one cigar cutter from the list. If you wish to change your selection please un-check the product you no longer want and select a new one.');document.getElementById(currItem).checked = false;return false;}		
else if(LighterSelected > 1){alert('You may only pick one lighter from the list. If you wish to change your selection please un-check the product you no longer want and select a new one.');document.getElementById(currItem).checked = false;return false;}		
else{return true;}}
