
jQuery.fn.shake=function(intShakes,intDistance,intDuration){this.each(function(){$(this).css({position:'relative'});for(var x=1;x<=intShakes;x++){$(this).animate({left:(intDistance*-1)},(((intDuration/intShakes)/4))).animate({left:intDistance},((intDuration/intShakes)/2)).animate({left:0},(((intDuration/intShakes)/4)));}});return this;};var noAJAX=false;var disableSB=false;var sbAnmSpd="fast";var cookieExp=365;var cookiePrefix="sd_";var cookiePath="/";var hideStk=false;var DefGridView=true;var timeOutVal=6000;function insertStyleSheet(path){var cssNode=document.createElement('link');cssNode.type='text/css';cssNode.rel='stylesheet';cssNode.href=path;cssNode.media='screen';cssNode.title='dynamicLoadedSheet';document.getElementsByTagName("head")[0].appendChild(cssNode);}
function setPageHeight(){var getWindowHeight=$(window).height()+'px';var getFooterHeight=$(".footer").height()+'px';$("#pageSurround").css("min-height",getWindowHeight);$(".spacer").css("height",getFooterHeight);}
function hideDropDownBox(){$(".optField").css("visibility","hidden");}
function showDropDownBox(fade){$(".optField").css("visibility","visible");}
function slideBox(q){if(q.attr("class")!="noCollapse"){if(q.attr("class")=="collapsed"){q.parents(".sidebox").children(".boxContentLeft").slideDown(sbAnmSpd);q.removeClass("collapsed");q.parents(".boxTitleLeft").children(".expand").fadeOut(sbAnmSpd);var boxID=q.parents(".sidebox").attr("id");$.cookie(cookiePrefix+boxID,1,{expires:cookieExp,path:cookiePath});}else{q.parents(".sidebox").children(".boxContentLeft").slideUp(sbAnmSpd);q.addClass("collapsed");q.parents(".boxTitleLeft").children(".expand").fadeIn(sbAnmSpd);var boxID=q.parents(".sidebox").attr("id");$.cookie(cookiePrefix+boxID,0,{expires:cookieExp,path:cookiePath});}}}
$(function(){if(disableSB!=true){$("div.boxTitleLeft img").each(function(){if($(this).attr("class")!="noCollapse"){$(this).css("cursor","pointer");}});$("div.sidebox").each(function(i){if($(this).children(".boxTitleLeft").children("img").attr("class")=="collapsed"){$(this).children(".boxContentLeft").css("display","none");$(this).children(".boxTitleLeft").children(".expand").css("display","block");}
if(typeof(isCart)=="undefined"){$(this).attr("id","box-"+i);}else{$(this).attr("id","cartbox-"+i);}
var cookieName=cookiePrefix+$(this).attr("id");if($.cookie(cookieName)==0){$(this).children(".boxContentLeft").css("display","none");$(this).children("div.boxTitleLeft").children("img").addClass("collapsed");$(this).children("div.boxTitleLeft").children("div.expand").fadeIn(sbAnmSpd);}else if($.cookie(cookieName)==1){$(this).children(".boxContentLeft").css("display","block");$(this).children("div.boxTitleLeft").children("img").removeClass("collapsed");$(this).children("div.boxTitleLeft").children("div.expand").fadeOut(sbAnmSpd);}});$(".boxTitleLeft").click(function(){slideBox($(this).children("img"));});}
if($("div.stockLevel").length>0){if(($("div.stockLevel").html().toLowerCase()!='<span class="txtoutofstock"></span>')&&(hideStk!=true)&&($("div.stockLevel").html().toLowerCase()!='<span class=txtoutofstock></span>')){$("div.stockLevel").show();}}
$(".addToCart").css("cursor","pointer");$(".addToCartWhiteBG").css("cursor","pointer");$("#ajaxCart").load(rootRel+'ajaxCart.php'+'?nocache='+Math.random());var tabContainers=$('div.tabs > div');$('div.tabs ul.tabMenu a').click(function(){tabContainers.hide().filter(this.hash).show();$('div.tabs ul.tabMenu a').removeClass('selected');$(this).addClass('selected');return false;}).filter(':first').click();$("a.snap_noshots").hover(function(){hideDropDownBox();},function(){showDropDownBox();});$("#addthis_dropdown").hover(function(){hideDropDownBox();},function(){showDropDownBox();});$('.changeView').click(function(){var getView=this.getAttribute("rel");$.cookie(cookiePrefix+"viewType",getView,{expires:cookieExp,path:cookiePath});location.reload(true);});if(typeof(isCart)=="undefined"){if($.cookie(cookiePrefix+"viewType")=='gridView'){insertStyleSheet(gridViewPath);}else{insertStyleSheet(rowViewPath);}
if(!$.cookie(cookiePrefix+"viewType")){if(DefGridView==true){insertStyleSheet(gridViewPath);}}}
setPageHeight(Math.random());});var options={beforeSubmit:showRequest,success:showResponse,timeout:timeOutVal,error:timeoutError};function doAddToCart(productID,manual){if(manual==true){$('#myForm'+productID).submit();}
if(noAJAX==true){$('#myForm'+productID).submit();}else{errorProdID=productID;$('#myForm'+productID).ajaxSubmit(options);return false;}};function showRequest(formData,jqForm,options){var queryString=$.param(formData);var formElement1=jqForm[0];var prodID1=formElement1[0].value;var vShift=formElement1[3].value;$('#AJAX-confirm-'+prodID1).hide()
$('#AJAX-process-'+prodID1).show()
$('#buy-'+prodID1).css("background-position","0% "+("-"+(vShift*2+"px")));return true;}
function showResponse(formData,jqForm,$form,options){var formElement2=$form[0];var prodID2=formElement2[0].value;var opt=formElement2[2].value;var vShift=formElement2[3].value;$.ajax({url:rootRel+'chkOpt.php',data:'prodID='+prodID2,success:function(checkedOpt){if(checkedOpt==1&&opt==1){$("#AJAX-process-"+prodID2).remove();$("#AJAX-opt-"+prodID2).show();$("#buy-"+prodID2).css("background-position","0% 0px");$("#AJAX-options-"+prodID2).show();var path=rootRel+"ajaxCart.php"+"?nocache="+Math.random();$("#ajaxCart").load(path);}
else{$("#AJAX-process-"+prodID2).hide();$("#AJAX-confirm-"+prodID2).show();$("#buy-"+prodID2).css("background-position","0% "+("-"+(vShift*3+"px")));var path=rootRel+"ajaxCart.php"+"?nocache="+Math.random();$("#ajaxCart").load(path);$("#cartIcon").shake(3,5,600);}}});}
function timeoutError(options){doAddToCart(errorProdID,false);}
function starsHover(rating,pathImg){for(var i=0;i<=rating;i++){if(i>0)findObj("star"+i).src=pathImg+'1.gif';}
for(var i=rating+1;i<=5;i++){findObj("star"+i).src=pathImg+'0.gif';}}
function starsOut(pathImg){var val=$("#rating_val").val();if(val==""){val=0;}
for(var i=0;i<=val;i++){if(i>0){$("#star"+i).attr({src:pathImg+"1.gif"});}}
for(var i=0;(i<=5);i++){if(i>val){$("#star"+i).attr({src:pathImg+"0.gif"});}}}
