$.cacheImage(['/G/MMAO/header/home.gif','/G/MMAO/header/home-over.gif','/G/MMAO/header/account.gif','/G/MMAO/header/account-over.gif','/G/MMAO/header/history.gif','/G/MMAO/header/history-over.gif','/G/MMAO/header/browse.gif','/G/MMAO/header/browse-over.gif','/G/MMAO/header/exitMMAO.gif','/G/MMAO/header/exitMMAO-over.gif','/G/MMAO/category/redButton.png','/G/MMAO/category/redButton-over.png','/G/MMAO/category/boxTop.png']);var selectionID;selectionID=-1;var selectionCieling=10;function changeActiveHovers(id)
{var lcv=0;selectionCieling=10;while(lcv<selectionCieling)
{if($('#sug'+lcv))
{if($('#sug'+lcv).attr('class')=='active')
{$('#sug'+lcv).removeClass('active').addClass('nonActive');}}
else
{selectionCieling=lcv;}
lcv+=1;}
if(lcv>=9)
{selectionCieling=10;}
if($('#sug'+id))
{$('#sug'+id).removeClass('nonActive').addClass('active');$('#searchText').val(rtrim($('#suggestionSearchVal'+id).html()));}
else
{$('#sug0').removeClass('nonActive').addClass('active');selectionID=0;}}
function getkeywordsuggestion(keyword,oEvent,subFlag)
{var currentTime=new Date();var temp=0;if(keyword.length>=3)
{if(oEvent.keyCode==38){if(selectionID>0){selectionID=selectionID-1;}
else{selectionID=0;}
changeActiveHovers(selectionID);}
else if(oEvent.keyCode==40){if(selectionID<selectionCieling-1){selectionID=selectionID+1;}
changeActiveHovers(selectionID);}
else
{$.ajax({url:'/make-me-an-offer-v2/includes/offerSuggestions.asp',data:{k:[''+keyword]},cache:false,beforeSend:function(){},success:function(html){if(html=='No results returned')
{$('#keywordSearchSuggestContainer').css('display','none');}
else
{$('#keywordSearchSuggestContainer').css('display','inline');$('#keywordsuggest').html(html);}
varGlobal=0;},complete:function(html){}});}}
else
{$('#keywordSearchSuggestContainer').css('display','none');if(subFlag==1)
{if(selectionID!=-1)
{$('#frmProdKeywordlower').val($('#suggestionSearchVal'+selectionID).html().replace("&","&"));}
$('#searchLeftNav').attr('action',$('#searchLeftNav').attr('action')+$('#frmProdKeywordlower').val());return true;}}}
function showLogin()
{$('#popout').modal({closeHTML:"<a href='#' title='Close' class='modal-close'><img id='theCloser' style='display: none;' src='/make-me-an-offer-v2/graphics/category/popup/close.png' width='25' height='25' border='0'></a>",overlayId:'popout-overlay',containerId:'popout-container',containerCss:'height: auto',minHeight:500,onOpen:function(dialog){$('.modal-close').css('display','none');dialog.overlay.fadeIn('fast',function(){dialog.container.slideDown('fast',function(){dialog.data.fadeIn('fast');$('.modal-close').css('display','inline');$('#theCloser').css('display','inline');});});$('#popout').css('background-image','none');$('#popoutProduct').css('display','none');if(thisBrowser=='other')
{$('#loginBox').css('display','block');$('.simplemodal-wrap').css('width','780px');$('#popout-container').css('width','780px');$('#theCloser').css('margin-left','-240px');}
else
{$('#loginBox').css('display','block');$('.simplemodal-wrap').css('width','780px');$('#popout-container').css('width','780px');}},onClose:function(dialog){dialog.data.fadeOut('slow',function(){$.modal.close();});}});}
function submitOffer(mmaoID,userID)
{if(userID==0)
{var lOfferAmount=$('#offerAmount').val();var lOfferQuant=$('#offerQty').val();var lMMAOid=mmaoID;loadingPopup();$.ajax({url:'includes/MMAOsubmitOfferCheck.asp',data:{a:[''+$('#offerAmount').val()],q:[''+$('#offerQty').val()],u:[userID],m:[mmaoID]},cache:false,beforeSend:function(){},complete:function(){},error:function(xhr,textStatus,errorThrown){customErrorPopup(xhr);},success:function(html){if(html!='')
customErrorPopup(html);else
{$(".container").css('display','none');$('#mID').val(lMMAOid);$('#offer').val(lOfferAmount);$('#oQty').val(lOfferQuant);$('#popout').css('background-image','none');$('#popoutProduct').css('display','none');if(thisBrowser=='other')
{$('#loginBox').css('display','block');$('.simplemodal-wrap').css('width','780px');$('#popout-container').css('width','780px');$('#theCloser').css('margin-left','-240px');}
else
{$('#loginBox').css('display','block');$('.simplemodal-wrap').css('width','780px');$('#popout-container').css('width','780px');}}}});}
else
{loadingPopup();$.ajax({url:'includes/MMAOsubmitOfferCheck.asp',data:{a:[''+$('#offerAmount').val()],q:[''+$('#offerQty').val()],u:[userID],m:[mmaoID]},cache:false,beforeSend:function(){},complete:function(){},error:function(xhr,textStatus,errorThrown){customErrorPopup(xhr);},success:function(html){if(html!='')
customErrorPopup(html);else
window.location='mmao-cart.asp';}});}}
var qty;var offer;var allowClose=0;function sendEmailPlus(errorText,ProductType,Strength,Wrapper,MSRP,Accessories,Special,filterID,newFilter,removeActionType,removeFilter,removeFilterID,perpage,whichPage){$('#testing').html(errorText);errorText=errorText.replace('?','');errorText=errorText.replace('<','');errorText=errorText.replace('>','');errorText=errorText.replace('\'','');errorText=errorText.replace('"','');errorText=errorText.replace('&','');$.ajax({url:'/make-me-an-offer-v2/includes/MMAOErrorEmail.asp',data:{theBody:[''+errorText],handleSection:["grid"],keyword:[''+errorText],PR:[''+ProductType],ST:[''+Strength],WR:[''+Wrapper],MS:[''+MSRP],AC:[''+Accessories],SP:[''+Special],'new':[''+filterID],newF:[''+newFilter],REM:[''+removeActionType],RMF:[''+removeFilter],RMI:[''+removeFilterID],perPage:[''+perpage],page:[''+whichPage]},cache:false,beforeSend:function(){},complete:function(){},error:function(xhr,textStatus,errorThrown){},success:function(html){}});}
function HandleFilter(keyword,ProductType,Strength,Wrapper,MSRP,Accessories,Special,filterID,newFilter,removeActionType,removeFilter,removeFilterID,perpage,whichPage)
{var topData,leftData,mainData,ajaxhandlerURL
$(".container").css('display','block');ajaxhandlerURL='/make-me-an-offer-v2/includes/MMAOAjaxHandler.asp';$.ajax({url:ajaxhandlerURL,data:{handleSection:["grid"],keyword:[''+keyword],PR:[''+ProductType],ST:[''+Strength],WR:[''+Wrapper],MS:[''+MSRP],AA:[''+Accessories],SP:[''+Special],'new':[''+filterID],newF:[''+newFilter],REM:[''+removeActionType],RMF:[''+removeFilter],RMI:[''+removeFilterID],perPage:[''+perpage],page:[''+whichPage]},cache:false,beforeSend:function(){$("#appliedFilters").animate({opacity:0.1},500);$("#notAppliedFilters").animate({opacity:0.1},500);$("#productGrid").animate({opacity:0.1},500);},complete:function(){$('#tempHolder').html('');},error:function(xhr,textStatus,errorThrown){$(".container").css('display','block');$('#loadingBox').css('display','none');$('#errorBox').css('display','block');$('#loadingTextBox').css('display','none');$('#errorTextBox').css('display','block');sendEmailPlus(xhr.responseText,ProductType,Strength,Wrapper,MSRP,Accessories,Special,filterID,newFilter,removeActionType,removeFilter,removeFilterID,'','','','','');},success:function(html){$('#loadingBox').css('display','block');$('#errorBox').css('display','none');$('#loadingTextBox').css('display','block');$('#errorTextBox').css('display','none');$('#tempHolder').html(html);mainData=$('#gridDiv','#tempHolder').html();topData=$('#topDiv','#tempHolder').html();leftData=$('#leftDiv','#tempHolder').html();if(topData.replace(/\s+/g,'')=='')
{$("#appliedFilters").css('display','none');$("#appliedFilterTable").css('font-size','5px');}
else
{$("#appliedFilters").css('display','block');$("#appliedFilterTable").css('font-size','0px');}
$("#appliedFilters").html(topData);$("#notAppliedFilters").html(leftData);$("#productGrid").html(mainData);$("#appliedFilters").animate({opacity:1},500);$("#notAppliedFilters").animate({opacity:1},500);$("#productGrid").animate({opacity:1},500,function(){$(".container").css('display','none');$('#tempHolder').html('');});}});}
function loadProduct(tileInstance)
{$('.boxTop',tileInstance).animate({marginTop:-300},200);$('.specialBanner',tileInstance).css('display','none');var prodID=$('.prodIDContainer > .prodID',tileInstance).html();var mmaoID=$('.prodIDContainer > .mmaoID',tileInstance).html();$.ajax({url:'includes/ProductPopupContent.asp',data:{p:[''+prodID],m:[''+mmaoID]},cache:false,beforeSend:function(){},complete:function(){$('#popout').modal({closeHTML:"<a href='#' title='Close' class='modal-close'><img id='theCloser' style='display: none;' src='/make-me-an-offer-v2/graphics/category/popup/close.png' width='25' height='25' border='0'></a>",overlayId:'popout-overlay',containerId:'popout-container',containerCss:'height: auto',minHeight:500,onOpen:function(dialog){$('.modal-close').css('display','none');dialog.overlay.fadeIn('fast',function(){dialog.container.slideDown('fast',function(){dialog.data.fadeIn('fast',function(){$('#prodPopupBody').css('position','relative');$('.prodPopupHeader').css('position','relative');$('.simplemodal-wrap').css('overflow','visible');$('.modal-close').css('display','inline');$('#theCloser').css('display','inline');});});})},onClose:function(dialog){$('#prodPopupBody').css('position','static');$('.prodPopupHeader').css('position','static');$('#historyImageGallery').css('display','none');dialog.data.fadeOut('slow',function(){$.modal.close();$('.boxTop').animate({marginTop:0},500,function(){$('.specialBanner',tileInstance).css('display','inline');});});}});},error:function(xhr,textStatus,errorThrown){},success:function(html){$('#popoutProduct').html(html);}});}
function mouseOverTile(tileInstance)
{if($('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src").indexOf("-over.png")<=0)
{var preSrc=$('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src");var src=preSrc.replace(".png","-over.png");$('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src",src);}}
function mouseOutTile(tileInstance)
{if($('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src").indexOf("-over.png")>0)
{var src=$('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src").replace("-over","");$('div.boxTop div.productFrame img.theRedButton',tileInstance).attr("src",src);}}
function displayImageGallery(){$('#popout-container').animate({marginLeft:'180px'},'fast');$('#historyImageGallery').css('display','inline');$('#historyImageGallery').animate({marginLeft:'-372px'},'fast');}
function hideImageGallery(){$('#popout-container').animate({marginLeft:'0px'},'fast');$('#historyImageGallery').animate({marginLeft:'0px'},'fast',function(){$('#historyImageGallery').css('display','none');});}
$(document).ready(function(){if($('#Previous1').length!=0)
{var remains=parseInt($('.numberedPageListTD').css('width').replace("px",""))-(parseInt($('.pageNavArrows').css('width').replace("px",""))*2)-parseInt($('.numberedPageContainer').css('width').replace("px",""));remains=remains/2;if(thisBrowser!='IE'){$('.numberedPageSlidingContainer').css('height','22px');$('.numberedPageContainer').css('height','22px');var pageNumberWidth=24;}else{var pageNumberWidth=22;}var limitLeft=-((totalPages*pageNumberWidth)-200);$('#Previous1').click(function(){var rightPosition=parseInt($('.numberedPageSlidingContainer').css('margin-left').replace("px",""))+200;$('.numberedPageSlidingContainer').animate({marginLeft:rightPosition},50,function(){if(parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))>=0){$('.numberedPageSlidingContainer').animate({marginLeft:10},50).animate({marginLeft:0},50);}});});$('#Previous2').click(function(){var rightPosition=parseInt($('.numberedPageSlidingContainer').css('margin-left').replace("px",""))+200;$('.numberedPageSlidingContainer').animate({marginLeft:rightPosition},50,function(){if(parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))>=0){$('.numberedPageSlidingContainer').animate({marginLeft:10},50).animate({marginLeft:0},50);}});});$('#Next1').click(function(){var leftPosition=parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))-200;$('.numberedPageSlidingContainer').animate({marginLeft:leftPosition},50,function(){if(limitLeft>=parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))){if(limitLeft>=200){$('.numberedPageSlidingContainer').animate({marginLeft:-10},50).animate({marginLeft:0},50);}else{$('.numberedPageSlidingContainer').animate({marginLeft:limitLeft-10},50).animate({marginLeft:limitLeft},50);}}});});$('#Next2').click(function(){var leftPosition=parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))-200;$('.numberedPageSlidingContainer').animate({marginLeft:leftPosition},50,function(){if(limitLeft>=parseInt($('.numberedPageSlidingContainer').css("margin-left").replace("px",""))){if(limitLeft>=200){$('.numberedPageSlidingContainer').animate({marginLeft:-10},50).animate({marginLeft:0},50);}else{$('.numberedPageSlidingContainer').animate({marginLeft:limitLeft-10},50).animate({marginLeft:limitLeft},50);}}});});}
$(".navigationOver").mouseover(function(){if($('img',this).attr("src").indexOf("-over.gif")<=0){var src=$('img',this).attr("src").replace(".gif","-over.gif");$('img',this).attr("src",src);}}).mouseout(function(){if($('img',this).attr("src").indexOf("-over.gif")>0){var src=$('img',this).attr("src").replace("-over.gif",".gif");$('img',this).attr("src",src);}});});function customErrorPopup(errorText)
{var errorMessage='<img src=\'graphics/alert.jpg\' height=\'100\' width=\'100\' style=\'float: left; padding-right: 5px;\'>'+errorText;$('#customErrorText').html(errorMessage);$('#loadingBox').css('display','none');$('#errorBox').css('display','block');$('#loadingTextBox').css('display','none');$('#errorTextBox').css('display','none');$('#customErrorTextBox').css('display','block');$('.container').css('display','block');}
function errorPopup()
{$('#loadingBox').css('display','none');$('#errorBox').css('display','block');$('#loadingTextBox').css('display','none');$('#errorTextBox').css('display','block');$('#customErrorTextBox').css('display','none');$('.container').css('display','block');}
function loadingPopup()
{$('#loadingBox').css('display','block');$('#errorBox').css('display','none');$('#loadingTextBox').css('display','block');$('#errorTextBox').css('display','none');$('#customErrorTextBox').css('display','none');$('.container').css('display','block');}
function checkNewEmail(emailval){var RegExp=/^\w+([\.&-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/;if(!RegExp.test(emailval)){return false;}else{return true;}}
function isBlank(val)
{if(val.replace(' ','')=='')
{return true;}
else
{return false;}}
function checkLogon(returningCust){if(isBlank($('#returningEmail').val())==true){alert("\nPlease enter the Email Address associated with your account.");$('#returningEmail').focus();returningCust.email.select()
return false;}
if(checkNewEmail($('#returningEmail').val())==false){alert("\nPlease enter a valid Email Address.");$('#returningEmail').focus();return false;}
if(isBlank($('#returningPass').val())==true){alert("\nPlease enter your password.");$('#returningPass').focus();return false;}
return true;}
function checkNewUser(newCust){if(isBlank($('#newemail').val())==true){alert("\nPlease enter an Email Address.");$('#newemail').focus();return false;}
if(checkNewEmail($('#newemail').val())==false){alert("\nPlease enter a valid Email Address.");$('#newemail').focus();return false;}
if(isBlank($('#newPass1').val())==true){alert("\nPlease enter a password.");$('#newPass1').focus();return false;}
if($('#newPass1').val().length<3){alert("\nYour password must be greater than 2 characters.");$('#newPass1').focus();return false;}
if($('#newPass1').val()!=$('#newPass2').val()){alert("\nYour passwords do not match. Please re-enter your passwords.");$('#newPass1').focus();return false;}
return true;}
function ltrim(s)
{return s.replace(/^\s*/,"");}
function rtrim(s)
{return s.replace(/\s*$/,"");}
function trim(s)
{return rtrim(ltrim(s));}
