/* QuickView - v2.7.6 - 2008.10.27 */
(function($) { 

/* CENTER OBJECT ON SCREEN */ 
    $.fn.centerOnScreen = function(){ 
        $this = this[0];
        windowHeight = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight;
        windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
        vertScroll = window.pageYOffset || document.body.scrollTop || document.documentElement.scrollTop;
        $this.style.top = ((windowHeight/2) - ($this.offsetHeight/2) + vertScroll) + "px";
        $this.style.left = ((windowWidth/2) - ($this.offsetWidth/2)) + "px";
    } 
  
/* GET COORDINATE OF OBJECT */  
    $.fn.getCoordinates = function() {
        obj = this[0];
        x = y = 0;
        if (obj.offsetParent) {
            x = obj.offsetLeft; y = obj.offsetTop;
            while (obj == obj.offsetParent){ x += obj.offsetLeft; y += obj.offsetTop; }
        }
        return {x:x,y:y};
    }
})($);
/*---- HOMEMADE JQUERY PLUGINS /END ----*/

var jspStoreImgDir='http://beta.sears.com/0514/';

//Set default thumbnail size for quick view images
var qvImgDim = 198;
var qvThmbDim = 40;
var qvThmbDim2 = 100;

// Put all sears specific functions into its own namespace
SEARS = {
    /* STORE PRODUCT INFO */
    Item: {
        "info":function(data){
            var data = data[0];
            // Product Object
            this.product        = data.P;
            this.strId          = this.product.strId;
            this.catId          = this.product.catId;
            this.catEntId       = this.product.cid;
            this.parCatEntId    = this.product.pid;
            this.pId            = this.product.pn;
			this.revURL			= this.product.rpn;
            this.mId            = this.product.mfrNum;
            this.pTitle         = this.product.t;
            this.type           = this.product.type;
            this.oDescription   = this.product.des;
            this.rating         = this.product.ra;
            this.numReviews     = this.product.nr;
            this.reviews        = this.product.reviews;
            this.hasSpecs       = this.product.specs;
			this.Img			= this.product.Img;
            this.mainImage      = this.product.Img[0];
            this.mImageElig     = this.mainImage.s7;
            this.mImageWidth    = this.mainImage.w;
            this.mImageHeight   = this.mainImage.h;
            this.mFimgURL1      = this.mainImage.iId;
            this.mImageAltTxt   = this.product.t;
            this.click2call     = this.product.c2t;
			this.regional		= this.product.regpr;
            // Save Story Object
            this.saveStory      = data.DD;
            this.offline        = this.saveStory.off;
            this.ssText         = this.saveStory.SStory;
            this.inStock        = this.saveStory.stock;
            this.spo            = this.saveStory.so;
            this.storepu        = this.saveStory.sp;
            this.addToCart      = this.saveStory.dispAdd;
			this.holiday		= this.saveStory.hMsg;
			this.preOrder		= this.saveStory.rdate;
			this.doNotEmail		= this.saveStory.DEME;
			this.spuFlag		= this.saveStory.spFlag;
			this.sp_ssText		= this.saveStory.spSS;
			this.sp_storeName	= this.saveStory.storeName;
			//Softlines
			if(data.Softline){
				this.softData	= data.Softline;
				this.variants	= this.softData.prodVarList;
			
			this.current		= {skuList:'',attList:''};
			this.ssArray		= data.Softline.ssArray;
			this.fakeDDshow 	= function(elm){
									var t;
									var global = this;
									$('#fakeDDcontent').remove();
									var dd = $('<div id="fakeDDcontent"></div>').appendTo('.quickView');
									$(elm).children('div').each(function(){
										if($(this).is('.disabled')){
											$('<div class="notAvail">'+$(this).html()+'</div>').appendTo(dd);	
										}else{
											$('<div>'+$(this).html()+'</div>').appendTo(dd);
										}
									});
									if($(dd).children().length > 10){
										$(dd).css({
											height: 175,
											overflow:'auto'
										});	
									};
									$('#fakeDDcontent div').hover(function(){
										$(this).addClass('hover');								   
									},function(){
										$(this).removeClass('hover');
									});
									$(dd).css({
										top: 	$(elm).offset().top - $(elm).parents('.quickView').offset().top,
										left:	$(elm).offset().left - $(elm).parents('.quickView').offset().left
									}).show().mouseout(function(){
										t = setTimeout(function(){
											//$(dd).remove();						
										},400);	
									}).mouseover(function(){
										clearTimeout(t)	;
									});
									$(dd).find('div').click(function(){
										var val = $(this).text();
										$(elm).children('div').each(function(){
											if($(this).text() == val){
												$(this).addClass('opt_sel').removeClass('opt_not_sel');
											}else{
												$(this).removeClass('opt_sel').addClass('opt_not_sel');
											};
											
										});
										$(dd).remove();
										global.attrChange(elm,true);
										
										if($(elm).is('#qvp_var')){
											$(SEARS.Item.softData.prodList.prodVarList).each(function(){
												if(this.varName == val){
													SEARS.Item.current.attList = this.attList;
													SEARS.Item.current.skuList = this.skuList; 
												};														   
											});
											global.changeVariant();
											};
									});
			};
			}
			var tempVal;
			this.changeVariant = function(){
			    $('.softAddtoCart').hide();	
			    $('.selectionsTab .qvp_att_dd').add('.selectionsTab div.oos').remove();
			    $(this.current.attList).each(function(a){
				    var dd = $('<div class="fakeDD qvp_att_dd" id="qvp_att'+a+'"></div>').appendTo('.selectionsTab').click(function(){
					tempVal = $(this).find('.opt_sel').removeClass('opt_sel').addClass('opt_not_sel');
					$(this).find('.default').addClass('opt_sel').removeClass('opt_not_sel');
					SEARS.Item.attrChange(dd);
					SEARS.Item.fakeDDshow(this);																							   
				    });
				    $(dd).append('<div class="opt_sel default">'+this.name+'</div>')
				    if(this.name == 'Color' || this.name == 'Overall Color'){
				    $(dd).addClass('qvcolor');
					$(this.values).each(function(b){
						var swURL = 'http://s.sears.com/is/image/Sears/'+this.swId+'?hei=20&wid=20&op_sharpen=1';
						$('<div class="opt_not_sel"><img src="'+swURL+'" alt="'+this.cName+'" align="absmiddle" height="20" width="20">'+this.cName+'</div>').appendTo(dd);	
					});
				    }else{
					$(this.values).each(function(c){
						$('<div class="opt_not_sel">'+this+'</div>').appendTo(dd);					 
					});	
				    };
			    });
			    $('<div class="oos">This item is not available in the combination you have selected. Please change your selections.</div>').hide().appendTo('.selectionsTab');
			};
			this.attrChange = function(changed,msg){
				var condition = '';
				var closedAttrs = [];
				var matches = [];
				var skuList = SEARS.Item.current.skuList;
				var saveStory = SEARS.Item.ssArray;
				var allAttrs = $('.qvp_att_dd');
				$(allAttrs).find('div').removeClass('enabled').removeClass('disabled');
				$('.qvp_att_dd').each(function(){
					if(!$(this).find('div:first').is('.opt_sel')){
						closedAttrs.push(this);
					}
				});
				
				if(closedAttrs.length > 0){
					$(closedAttrs).each(function(a){
						var spot = this.id.split('qvp_att')[1];
						if(a==0){
							condition+= 'this.aVals['+spot+'] == "'+$(this).find('.opt_sel').text()+'"';
						}else{
							condition+= ' && this.aVals['+spot+'] == "'+$(this).find('.opt_sel').text()+'"';
						}
					});
					condition+=' && this.stk > 0';
					$(skuList).each(function(){  
						if(eval(condition)){
							matches.push(this);
							$(this.aVals).each(function(b){
								var m = this;
								$('#qvp_att'+b).find('div').each(function(){
									if($(this).text() == m){$(this).addClass('enabled')}										  
								});
							});
						}
					});
					$(allAttrs).children('div').not('.default').not('.enabled').addClass('disabled');
					if(closedAttrs.length == 1){
						$(closedAttrs).children('div').removeClass('disabled').removeClass('enabled');
					}
				}else{
					$(allAttrs).children('div').removeClass('disabled').removeClass('enabled');
				};
				
				if($('.qvp_att_dd').find('.opt_sel').hasClass('disabled')){
					$('.selectionsTab .oos').show();
				}else{
					$('.selectionsTab .oos').hide();
				}
				if(msg){
					var tot = allAttrs.length
					var check = [];
					$(allAttrs).each(function(){
						if ($(this).children('div.default').hasClass('opt_sel')){
							check.push(this);
						};
					});
					if(matches.length == 0 && check.length != tot){
						$('.selectionsTab .oos').show();
					};
				};
				if(closedAttrs.length == allAttrs.length && $('.selectionsTab .oos').is(':hidden')){
					var QVparent = $('#qv'+SEARS.Item.pId);
					var _QV = $('.quickView');
					var pid = matches[0].pid;
					$('form[name="addToCart"] input[name="catEntryId_1"]').val(pid);
					var ssIndex = matches[0].ssIdx;
					$('.quickView .saveStory').html(saveStory[ssIndex]);
					var _SSqty = $(QVparent).find('.saveStory').eq(0);
					var _defaultST ="";  
					if($(_SSqty).find('.regPrice').length){
						 _defaultST = $(_SSqty).find('.regPrice').html().split("$")[1];
					}else if($(_SSqty).find('.salePrice').length){
						 _defaultST = $(_SSqty).find('.salePrice').html().split("$")[1];
					}
					//$('.softAddtoCart').find('.QVsubT').html(_defaultST);
					var _a2c = $('.softAddtoCart')
					var _qty = $(_a2c).find('.QVqty').val();
					var _sub = $(_a2c).find('.QVsubT');
					$(_sub).html((_qty*_defaultST).toFixed(2));
					$('.softAddtoCart').fadeIn(400,function(){$('.QVborder').height($(_QV).height()+25)});
				}else{
					$('.softAddtoCart').hide();
				};
				if($(changed).hasClass('qvcolor')){
					if(!$(changed).find('.opt_sel').hasClass('default')){
						var selcolor = $(changed).find('.opt_sel').text();
						var matchcolor;
						$(SEARS.Item.current.attList).each(function(){
							if(this.name == 'Color' ||  this.name == 'Overall Color'){
								$(this.values).each(function(){
									if(this.cName == selcolor){
										matchcolor = this;
									};
								});
							};
						});  
						if(matchcolor.mImgId != ''){
							$('.itemWidgets .imgnotavail').remove();
							$('.quickView .slider .zzz_imgzoom:first').add('.quickView .slider .zzz_zoomed:first').fadeOut(800).remove();
							$('<img/>').attr({
								alt:SEARS.Item.pTitle,
								src:'http://s.sears.com/is/image/Sears/'+matchcolor.mImgId+'?hei='+qvImgDim+'&wid='+qvImgDim+'&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0',
								width:qvImgDim,
								height:qvImgDim
							}).hide().prependTo('.quickView .slider').fadeIn(800).imgZoom({container:'.content', src:"http://s.sears.com/is/image/Sears/"+matchcolor.mImgId+"?&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0"});;
							$('.quickView .slider2 img').removeClass('selected');
							$('.quickView .slider2 img:first').addClass('selected').animate({opacity:1}).attr('src','http://s.sears.com/is/image/Sears/'+matchcolor.mImgId+'?hei=40&wid=40&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0')
							clickIndx = clickIndx2 = 0;
							$('.quickView .slider').animate({left:"-"+(clickIndx*qvImgDim)},250);
							$('.quickView .slider2').animate({left:"-"+(clickIndx2*qvThmbDim)},250);
						}else{
							$('.quickView .slider .zzz_zoomed:first').remove();
							var tempimg = $('.quickView .slider .zzz_imgzoom:first').children('img').wrap('<div class="zzz_imgzoom"></div>').parents('.zzz_imgzoom');
							$('.quickView .slider .zzz_imgzoom:first').replaceWith(tempimg);
							$('<div class="imgnotavail">Image not available</div>').hide().appendTo('.itemWidgets');
							$(tempimg).animate({opacity:0.1})
							$('.itemWidgets .imgnotavail').fadeIn(800);
							$('.quickView .slider2 img').removeClass('selected');
							$('.quickView .slider2 img:first').animate({opacity:0.1})
							clickIndx = clickIndx2 = 0;
							$('.quickView .slider').animate({left:"-"+(clickIndx*qvImgDim)},250);
							$('.quickView .slider2').animate({left:"-"+(clickIndx2*qvThmbDim)},250);
						}
					};
			};
			}
        }   
    },
    /* QUICK VIEW */
    QuickView: {
        "launch":function(){
            $('.quickViewWrap').remove();
            $('.mapWrap').remove();
            $('#offerDetails').remove();
			var strName="";  
		    var _vert = omVrt.split("'").join("");
            var _cat = omCat.split("'").join("");
            var _sbcat = omSubCat.split("'").join(""); 
            
			if((SEARS.Item.strId=="10153") || (SEARS.Item.strId=="10154")){strName="Sears"}else if(SEARS.Item.strId=="10151"){strName="Kmart"}else if((SEARS.Item.strId=="10152") || (SEARS.Item.strId=="10701") || (SEARS.Item.strId=="11701") || (SEARS.Item.strId=="11702") || (SEARS.Item.strId=="11703")){strName="My Gofer"}else if(SEARS.Item.strId=="10154"){strName="Kenmore"};
			var revPath;
			if(strName=="Sears"){revPath='sears.com/2328/'}else if(strName=="Kmart"){revPath='kmart.com/2348/'};
            $('body').append('<div id="qv'+SEARS.Item.pId+'" class="quickViewWrap"></div>');
			var QVparent = $('#qv'+SEARS.Item.pId);
            var QVWrap = $('.quickViewWrap');
             $(QVWrap).append('<div class="QVborder"/>');
            $(QVWrap).append('<div class="quickView"/>');
            var _QV = $('.quickView');
            $(_QV).append('<div class="drag"><a href="#close" title="Close this window" class="closeWindow">close</a></div>');
			var _drag = $('.drag');
			//Error message for Temporary Offline Status
            if(SEARS.Item.offline){
                $(_QV).append('<p>We\'re sorry. The product you selected is no longer available, or is temporarily out of stock due to high demand. Please try again later.</p>');
            }else if(!SEARS.Item.offline){
				$(_drag).append('<ul><li><a href="#overview" onclick="s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > '+'Quick View > Overview\';s.events=\'event27\';s.product=\''+SEARS.Item.pId+'\';s.tl();">Overview</a></li></ul>');
				if(SEARS.Item.type!="C"&&SEARS.Item.type!="GC"){
					if(SEARS.Item.hasSpecs){
						$(_drag).find('ul').append('<li><a href="#specs" onclick="s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > '+'Quick View > Specs\';s.events=\'event27\';s.product=\''+SEARS.Item.pId+'\';s.tl();">Specs</a></li>')
					}
					if(strName!="My Gofer"&&SEARS.Item.reviews){
						$(_drag).find('ul').append('<li><a href="#reviews" onclick="s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > '+'Quick View > Reviews\';s.events=\'event27\';s.product=\''+SEARS.Item.pId+'\';s.tl();">Reviews</a></li></ul>')
					}
				}
				$(_QV).append('<div class="QVinnerWrap"/>');
				var _QVi = $('.QVinnerWrap');
				$(_QVi).append('<div class="itemWidgets" style="width:'+parseInt(qvImgDim+2)+'px;"/>').append('<div class="scrollWsmall" style="width:'+parseInt(qvThmbDim2+2)+'px;height:'+parseInt(qvThmbDim+2)+'"/>').append('<div class="content narrow"/><div class="clear"/>');
				$(_QV).append('<div class="goToButtons"/>');
                var itmWgts = $('.itemWidgets');
				var nonZoom = $('.scrollWsmall');
				var content = $('.content');
                var goTo = $('.goToButtons'); 
				 
				//Columns for images
                //$(itmWgts).append('<div class="scrollWidget" style="width:'+qvDim+'px;"><img alt="'+SEARS.Item.pTitle+'" src="http://s.sears.com/is/image/Sears/'+SEARS.Item.mFimgURL1+'?hei='+qvImgDim+'&wid='+qvImgDim+'&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0" width="'+qvImgDim+'" height="'+qvImgDim+'"</div>');
				var np_top = parseInt((qvImgDim/2)-7);
				$(itmWgts).append('<div class="scrollWidget" style="width:'+qvImgDim+'px;height:'+qvImgDim+'px;"><div class="slider" style="width:'+SEARS.Item.Img.length*qvImgDim+'px;"></div></div>');
				var slider = $(QVparent).find('.slider');
				if(SEARS.Item.Img.length>1){
					var np_top = parseInt((qvImgDim/2)-7);
					$(itmWgts).append('<img alt="previous image" src="'+jspStoreImgDir+'img/pImg.gif" class="pImg" style="top:'+np_top+'px;"/><img alt="next image" src="'+jspStoreImgDir+'img/nImg.gif" class="nImg" style="top:'+np_top+'px;"/>');
					$(itmWgts).append('<div class="thumbWidget"><div class="thmbMask"><div class="slider2" style="width:'+SEARS.Item.Img.length*(qvThmbDim+10)+'px;"></div></div></div>');
					var thmbWdgt = $('.thumbWidget')
					var cnp_top = parseInt(qvImgDim+($(thmbWdgt).height()/2)+5)
					if(SEARS.Item.Img.length>3){
						$(itmWgts).append('<img alt="Previous images" src="'+jspStoreImgDir+'img/pImg.gif" class="c_pImg" style="top:'+cnp_top+'px;"/><img alt="More images" src="'+jspStoreImgDir+'img/nImg.gif" class="c_nImg" style="top:'+cnp_top+'px;"/>');
					};
					var slider2 = $(QVparent).find('.slider2');
				};
				$.each(SEARS.Item.Img, function(i,Img){
					$('<img/>').attr({
						alt:SEARS.Item.pTitle,
						src:'http://s.sears.com/is/image/Sears/'+Img.iId+'?hei='+qvImgDim+'&wid='+qvImgDim+'&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0',
						width:qvImgDim,
						height:qvImgDim
					}).appendTo(slider);
					$('<img/>').attr({
						alt:SEARS.Item.pTitle,
						src:'http://s.sears.com/is/image/Sears/'+Img.iId+'?hei='+qvImgDim+'&wid='+qvImgDim+'&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0',
						width:qvThmbDim,
						height:qvThmbDim
					}).appendTo(slider2);
				});
				$(slider2).find('img').eq(0).addClass('selected');
				
				$(nonZoom).append('<img alt="'+SEARS.Item.pTitle+'" src="http://s.sears.com/is/image/Sears/'+SEARS.Item.mFimgURL1+'?hei='+qvThmbDim2+'&wid='+qvThmbDim2+'&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0" width="'+qvThmbDim2+'" height="'+qvThmbDim2+'"/>').hide();
				
				//Storing re-used elements in variables
                var mNum = SEARS.Item.mId && SEARS.Item.type=="H" ? ', Mfr. model #'+SEARS.Item.mId : '';
                var banner = '<h3><a href="/shc/s/p_'+SEARS.Item.strId+'_'+SEARS.Item.catId+'_'+SEARS.Item.pId+'">'+SEARS.Item.pTitle+'</a></h3><small class="itmNum">'+strName+' item# '+SEARS.Item.pId.split("P")[0]+mNum+'</small>';
				if(SEARS.Item.preOrder){
					banner += '<div class="qvPreOrder"><img border="0" alt="Item Coming Soon" src="img/icons/comingSoon.gif"/></div>';
				}
				if(SEARS.Item.type!="C"&&strName!="My Gofer"&&SEARS.Item.type!="GC"&&SEARS.Item.reviews){
					var reviewInfo = '<span class="reviews"><img alt="'+SEARS.Item.rating.replace('_','.')+' stars out of 5" src="http://reviews.'+revPath+SEARS.Item.rating+'/5/rating.gif"/>'+SEARS.Item.numReviews+' reviews</span>';
				}
				
				// Save story will not displayed if the product has regional price
				var ssBase;
				if(SEARS.Item.regional){
					ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>';
				}else{
					ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>';
				}
				
				//Messaging under the main thumbnail area
				if(SEARS.Item.preOrder){
					$(itmWgts).append('<span class="releaseDate"><strong>Release Date:</strong> '+SEARS.Item.preOrder+'</span><span class="preOrderSelect"><a href="#">Available for Pre-Order</a></span>')
				}
				switch(SEARS.Item.inStock){
					case 0:
						$(itmWgts).append('<span class="deliv_oos">Temporarily out of stock for delivery</span>');
						switch(SEARS.Item.storepu){
							case 0:
								$(itmWgts).append('<span class="spu_oos">Item is not Store Pick Up Eligible</span>');
							break;
							case 1:
								$(itmWgts).append('<span class="spu_elig">Item is Store Pick Up Eligible</span>');
							break;
							case 2:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_in">In Stock today at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 3:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Temporarily out of stock at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 4:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Item not carried '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
						}
					break;
					case 1:
						//$(itmWgts).append('<span class="deliv_in">In stock for delivery <a class="checkAvail" href="javascript:;">Check Availability</a></span>')
						$(itmWgts).append('<span class="deliv_in">In stock for delivery</span>')
						switch(SEARS.Item.storepu){
							case 0:
								$(itmWgts).append('<span class="spu_oos">Item is not Store Pick Up Eligible</span>');
							break;
							case 1:
								$(itmWgts).append('<span class="spu_elig">Item is Store Pick Up Eligible</span>');
							break;
							case 2:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_in">In Stock today at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 3:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Temporarily out of stock at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 4:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Item not carried '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
						}
					break;
					case 2:
						switch(SEARS.Item.storepu){
							case 0:
								$(itmWgts).append('<span class="spu_oos">Item is not Store Pick Up Eligible</span>');
							break;
							case 1:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_elig">Item is Store Pick Up Eligible</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 2:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_in">In Stock today at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 3:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Temporarily out of stock at '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
							case 4:
								if(SEARS.Item.spuFlag==1){
									$(itmWgts).append('<span class="spu_oos">Item not carried '+SEARS.Item.sp_storeName+'</span>');
									//Display DD.spSS if not null
									if(SEARS.Item.type=="S"){
										ssBase = '<div class="saveStory"><strong style="color:#f00;">Please see more product information to see your price for this item.</strong></div>'
									}else if(SEARS.Item.sp_ssText!=null || SEARS.Item.sp_ssText!='' || SEARS.Item.sp_ssText!=' '){
										ssBase = '<div class="saveStory">'+SEARS.Item.sp_ssText+'</div>'
									}else{
										ssBase = '<div class="saveStory">'+SEARS.Item.ssText+'</div>'
									}
								}
							break;
						}
					break;
				}
				//alert(ssBase);
				if(SEARS.Item.spo&&!SEARS.Item.preOrder){
                    //$(itmWgts).append('<span class="spo"><a href="#" onclick="specialOffers(this,'+SEARS.Item.strId+','+SEARS.Item.parCatEntId+');return false;">Special Offers</a></span>')
                }
				
				//Build out div.content
				$(content).append('<div class="overviewTab"/>');
				if(SEARS.Item.reviews){$(content).append('<div class="specsTab"/>')};
				var _ovr = $('.overviewTab'); 
				var _specs = $('.specsTab');
				if(strName!="My Gofer"){$(content).append('<div class="reviewsTab"/>');
				var _reviews = $('.reviewsTab')};
				
				//Softline Data (Selections, etc.)
				if(SEARS.Item.softData && SEARS.Item.type=="S"){
					$('.drag > ul').prepend('<li><a href="#selections" onclick="s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > '+'Quick View > Selections\';s.events=\'event27\';s.product=\''+SEARS.Item.pId+'\';s.tl();">Selections</a></li>');
					$(content).prepend('<div class="selectionsTab"/>');
					var _selects = $('.selectionsTab');
					$(_selects).append(banner);
					if(reviewInfo){$(_selects).append(reviewInfo)};
					$(_selects).append(ssBase);
					// SOFTLINES CODE //
					var attData = SEARS.Item.softData
					var fitment = attData.prodList.prodVarList;
					var currentFit;
					var skuList;
					var attList;
					if(fitment.length > 1){
						var title = $('<h3>Select:</h3>').appendTo(_selects);
						var varselect = $('<div class="fakeDD" id="qvp_var"></div>').appendTo(_selects).click(function(){
							SEARS.Item.fakeDDshow(this);
						});
						$(fitment).each(function(a){
							if(a==0){
								$('<div class="opt_sel">'+this.varName+'</div>').appendTo(varselect);
								SEARS.Item.current.attList = this.attList;
								SEARS.Item.current.skuList = this.skuList;
							}else{
								$('<div class="opt_not_sel">'+this.varName+'</div>').appendTo(varselect);
							}
						});
					}else{
						var varselect = $('<h4 id="qvp_var">'+fitment[0].varName+'</h4>').appendTo(_selects);
						SEARS.Item.current.attList = fitment[0].attList;
						SEARS.Item.current.skuList = fitment[0].skuList;
					};
					SEARS.Item.changeVariant();
					// END SOFTLINES //
				};
				
				//Populate div.content
				$(_ovr).append(banner);
				if(reviewInfo){$(_ovr).append(reviewInfo)};
				$(_ovr).append(ssBase).append('<div class="description">'+SEARS.Item.oDescription+'</div>');
				$(_specs).prepend(banner).append(ssBase).append('<div class="specsBucket"/>');
				if(SEARS.Item.reviews){
					$(_reviews).prepend(banner).append(ssBase);
					if(SEARS.Item.numReviews>=1){
						$(_reviews).append('<iframe class="reviewsBucket" frameborder="0" src=""/>');
					}else{
						$(_reviews).append('<br clear="both"/><a href="/shc/s/p_'+SEARS.Item.strId+'_'+SEARS.Item.catId+'_'+SEARS.Item.pId+'" title="Write a Review for This Product">Click here to write a review for this product</a>');
					}
				};
				
				
				//Bottom band, with Add to Cart, etc.
                //$(goTo).append('<a class="QVship">Shipping Calculator</a><span class="QVqtyWrap"><label for="QVqty'+SEARS.Item.pId+'">Quantity:</label><input type="text" class="QVqty" id="QVqty'+SEARS.Item.pId+'"/> <strong>Subtotal: $<span class="QVsubT"></span></strong></span><a href="#" class="gotoBtn"/>');
                if(SEARS.Item.type=="S"){
					$(goTo).append('<div class="softAddtoCart"><span class="QVqtyWrap"><label for="QVqty'+SEARS.Item.pId+'">Quantity:</label><input type="text" value="1" class="QVqty" id="QVqty'+SEARS.Item.pId+'"/> <strong>Subtotal: $<span class="QVsubT"></span></strong></span></div>');
					var _QVqtyBox = $('#QVqty'+SEARS.Item.pId);
					$(goTo).find('.softAddtoCart').append('<a href="#" class="gotoBtn"/>');
					$(_QVqtyBox).blur(function(){
						var global = $(this)
						if(global.val()>99){alert('Quantity cannot be greater than 99.\nYour quantity will be set to 99.');global.val(99)};
						if(global.val().match(/\D/)){alert('Quantity field can contain only positive numbers.\n\nYour quantity will be set to 1.');global.val(1)};
						if(global.val()<1||global.val()==''){global.val(1)};
						var _SSqty = $(QVparent).find('.saveStory').eq(0);
						if($(_SSqty).find('.regPrice').length){
							var _QtyAmt = $(_SSqty).find('.regPrice').html().split("$")[1]
						}else if($(_SSqty).find('.salePrice').length){
							var _QtyAmt = $(_SSqty).find('.salePrice').html().split("$")[1]
						}else if($(_SSqty).find('.youPay').length){
							var _QtyAmt = $(_SSqty).find('.youPay').eq(0).find('.pricing').eq(0).html().split("$")[1]
						}
						$('form[name="addToCart"] input[name="quantity_1"]').val(global.val());
						$(QVparent).find('.QVsubT').html(parseFloat(_QtyAmt*global.val()).toFixed(2));
					}).blur();
				}else{
					$(goTo).append('<a href="#" class="gotoBtn"/>');
				}
                var goToBtn = $('.gotoBtn');
                var _QVqty = $('.QVqty');
                var _QVsubT = $('.QVsubT');
                if(SEARS.Item.preOrder&&SEARS.Item.inStock){
					$(goToBtn).append('<img alt="Pre-Order Item" src="'+jspStoreImgDir+'img/buttons/preOrder.gif" onclick="submitAddToCart('+SEARS.Item.mFimgURL1+');s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > Quick View > Add to Cart\';s.tl();" height="34"/>');
				}else if(!SEARS.Item.addToCart&&SEARS.Item.type!="S"){
                    $(goToBtn).append('<img alt="More Product Details" src="'+jspStoreImgDir+'img/btn_moreDetails.gif" height="20"/>');
                    $(goToBtn).attr('href','/shc/s/p_'+SEARS.Item.strId+'_'+SEARS.Item.catId+'_'+SEARS.Item.pId);
                }else{
					$(goToBtn).append('<img alt="Add to Cart" src="'+jspStoreImgDir+'img/btn_addToCart.gif" onclick="submitAddToCart(SEARS.Item.mFimgURL1);s.prop26=\''+_vert+' > '+_cat+' > '+_sbcat+' > Quick View > Add to Cart\';s.tl();" height="34" />');
                }
                $(goTo).append('<br clear="all"/>');
				if(SEARS.Item.preOrder&&!SEARS.Item.inStock&&!SEARS.Item.doNotEmail){
					$(goTo).prepend('<a href="javascript:;" class="emailMe" rel="emailMe" info="'+SEARS.Item.pTitle+'^ '+SEARS.Item.pId+'^ '+SEARS.Item.mId+'^ '+SEARS.Item.catEntId+'^ ^ '+jspStoreImgDir+'^ img/buttons/^ '+SEARS.Item.strId+'^ '+SEARS.Item.catId+'^">E-mail me when available</a>');
				}
				else if(SEARS.Item.click2call){
					$(goTo).prepend('<script type="text/javascript" src="http://as00.estara.com/as/InitiateCall2.php?accountid=200106282552&Template=58359"></script><a class="clickCall" href="javascript:webVoicePop (\'Template=58359\');">Call for Product Questions</a>');
				}
                if(!SEARS.Item.inStock && SEARS.Item.storepu){
                    var IndA = "pickup"
                }else{
                    var IndA = "ship"
                }
                
                var adjHgt,adjWid;
                $(goTo).append('<form name="addToCart" action="ProductOptionsOrderItemAddCmd" method="post"><input type="hidden" name="storeId" value="'+SEARS.Item.strId+'"/><input type="hidden" name="langId" value="-1"/><input type="hidden" name="catalogId" value="'+SEARS.Item.catId+'"/><input type="hidden" name="URL" value="OrderItemDisplay"/><input type="hidden" name="IndicatorA" value="'+IndA+'"/><input type="hidden" name="vName" value=""/><input type="hidden" name="cName" value=""/><input type="hidden" name="sName" value=""/><input type="hidden" name="grIdentifier" value="false"/><input type="hidden" name="addToCartBtn" value="false"/><input type="hidden" name="catEntryId_1" value="'+SEARS.Item.catEntId+'"/><input type="hidden" name="quantity_1" value="1"/><input type="hidden" name="partNumber" value="'+SEARS.Item.pId+'"/><input type="hidden" name="atc" value="quickview"/><input type="hidden" name="grUserType" value="javascript:getCookie(\'GiftRegApp'+SEARS.Item.strId+'\');"/></form>');
				if(SEARS.Item.preOrder){
					$(goTo).children('form').append('<input type="hidden" name="releasedate" value="'+SEARS.Item.preOrder+'"/>');
				}
                var scrlWgt = $('.scrollWidget');
				var clickIndx=0, clickIndx2=0;
				var curImg = SEARS.Item.Img[clickIndx];
				$(slider).children('img').each(function(i){
				     var zImgTemp = SEARS.Item.Img[i];  
					 if(zImgTemp.w>2000){zImgTemp.w=2000};
					 if(zImgTemp.h>2000){zImgTemp.h=2000};
					//$(this).imgZoom({container:'.content', src:"http://s.sears.com/is/image/Sears/"+zImgTemp.iId+"?hei="+zImgTemp.h+"&wid="+zImgTemp.w+"&op_sharpen=1&qlt=90,0&resMode=sharp&op_usm=0.9,0.5,0,0"});								
				});
				if(!$.browser.msie){$(QVWrap).draggable({handle:$(".drag")})};
				var sliderThumbs = $(slider2).children('img');
				
				highlightThumb = function(){
					$(sliderThumbs).each(function(){
						$(this).removeClass('selected');
					});
					$(sliderThumbs[clickIndx]).addClass('selected');
				};
				$(".pImg").click(function(){
					clickIndx--;
					if(clickIndx < 0){clickIndx = 0; return false};
					$(slider).animate({left:"-"+(clickIndx*qvImgDim)},250);
					highlightThumb();
					return false;
				});
				$(".nImg").click(function(){
					clickIndx++;
					if(clickIndx >= SEARS.Item.Img.length){clickIndx--; return false};
					$(slider).animate({left:"-"+(clickIndx*qvImgDim)},250);
					highlightThumb();
					return false;
				});
				$(".c_pImg").click(function(){
					clickIndx2--;
					if(clickIndx2 < 0){clickIndx2 = 0; return false};
					$(slider2).animate({left:"-"+(clickIndx2*qvThmbDim)},250);
					return false;
				});
				$(".c_nImg").click(function(){
					clickIndx2++;
					if(clickIndx2 >= (SEARS.Item.Img.length-2)){clickIndx2--; return false};
					$(slider2).animate({left:"-"+(clickIndx2*qvThmbDim)},250);
					return false;
				});
				$(sliderThumbs).each(function(i){
					$(this).click(function(){
						clickIndx = i;
						$(this).siblings().removeClass('selected');
						$(this).addClass('selected');
						$(slider).animate({left:"-"+(clickIndx*qvImgDim)},250);
						return false;
					})
				});
				$('.preOrderSelect').click(function(){
					var offsetValue = $(this).offset();
					$('div.seeDetailPop').show().css({top:offsetValue.top+15,left:offsetValue.left-8});
					$('a.seeDetailPopClose').click(function(){
						$('div.seeDetailPop').hide(0);
					});
				});
				$('a.emailMe').click(function(){
					mePop(this.info, 'emailMe');
					$('grayDiv').css('z-index','501');
					$('emailMe').css('z-index','502');
				});
			
				$('.quickView div[class$="Tab"]').hide();
				$('.quickView div[class$="Tab"]:first').show(function(){
					$('.drag > ul > li:first').addClass('on');$('.QVborder').height($('.quickView').height()+20);
					$(QVWrap).centerOnScreen();
				});
				$(QVWrap).hide();
				$(QVWrap).fadeIn(500,function(){$('.QVborder').height($(_QV).height()+25);}).bgiframe();
				if(strName=="Sears"||strName=="Kenmore"){
					$(QVWrap).find('.reviewsBucket').attr('src','http://reviews2.sears.com/2328qv/'+SEARS.Item.revURL+'/reviews.htm?format=noscript&user=__USERID__');
				}else if(strName=="Kmart"){
					$(QVWrap).find('.reviewsBucket').attr('src','http://reviews2.sears.com/2348qv/'+SEARS.Item.revURL+'/reviews.htm?format=noscript&user=__USERID__')
				};
				$("a.mapLink").click(function(){
	                mapClick(this)
	            });
	            $('.closeWindow').click(function(){
	                $(QVWrap).fadeOut(200,function(){$(this).remove();});
	                return false;
	            });
				$('.drag > ul > li > a').each(function(){
				    $(this).click(function(){
					$('#fakeDDcontent').remove();
					var theTab = $(this).attr('href').split('#')[1];
					var swap = function(){
						$('.content > div').hide();
						$('.'+theTab+'Tab').show();
					};
					if(theTab=='specs'){
					    if(SEARS.Item.type!="C"&&SEARS.Item.type!="GC"){
							$(QVWrap).find('.specsBucket').load('/shc/s/DisplayTabCmd?langId=&storeId='+SEARS.Item.strId+'&catalogId='+SEARS.Item.catId+'&catentryId='+SEARS.Item.parCatEntId+'&tabName=Specs',function(){
							//$(QVWrap).find('.specsBucket').load('DisplayTabCmd.html',function(){
								$('.itemWidgets').hide();
								$('.scrollWsmall').show();
								$('.content').removeClass('narrow').addClass('wide');
								swap();
								$('.QVborder').height($(_QV).height()+25);
							});
					    };
					}else if(theTab=='reviews'){
					    $('.itemWidgets').hide();
					    $('.scrollWsmall').show();
					    $('.content').removeClass('narrow').addClass('wide');
					    swap()
					}
					if(theTab=='selections' || theTab=='overview'){
					    $('.itemWidgets').show();
					    $('.scrollWsmall').hide();
					    $('.content').removeClass('wide').addClass('narrow');
					    swap()
					}
					$('.QVborder').height($(_QV).height()+25);
					$(this).parent().addClass('on').siblings().removeClass('on');
					if($.browser.msie){$(this).blur()};
					return false;
				    });
				});
				if($('.saveStory').find('.callout').length){
				    //alert($('.saveStory .callout').html());
				    var ss2clone = $('.quickView').find('.saveStory').find('.callout').eq(0);
				    $(ss2clone).clone().appendTo('.itemWidgets');
				    $(ss2clone).clone().appendTo('.scrollWsmall');
				    $('.quickView').find('.saveStory').find('.callout').each(function(){
					$(this).remove()
				    });
				}
			}
	    }
    }
}

/*---- HOMEMADE JQUERY PLUGINS /END ----*/

/* function unencode(text){
  
  jQuery.fn.unencode = function(){
	if($(this).attr('href').toString().indexOf('%2f')!=-1){
		var _result = $(this).attr('href').toString();
	if($(this).attr('href').toString().toLowerCase().indexOf('%2f')!=-1){
		var _result = $(this).attr('href').toString().toLowerCase();

} */
jQuery.fn.unencode = function(){
	if($(this).attr('href').toString().toLowerCase().indexOf('%2f')!=-1){
		var _result = $(this).attr('href').toString().toLowerCase();
		_result=_result.replace(/%20/g,' ');
		_result=_result.replace(/%22/g,'"');
		_result=_result.replace(/%23/g,'#');
		_result=_result.replace(/%24/g,'$');
		_result=_result.replace(/%25/g,'%');
		_result=_result.replace(/%26/g,'&');
		_result=_result.replace(/%26/g,'&');
		_result=_result.replace(/%2b/g,'+');
		_result=_result.replace(/%2c/g,',');
		_result=_result.replace(/%2f/g,'/');
		_result=_result.replace(/%3a/g,':');
		_result=_result.replace(/%3b/g,';');
		_result=_result.replace(/%3c/g,'<');
		_result=_result.replace(/%3d/g,'=');
		_result=_result.replace(/%3e/g,'>');
		_result=_result.replace(/%3f/g,'?');
		_result=_result.replace(/%40/g,'@');
		//alert(_result);
		return _result;
	}else{
		return $(this).attr('href').toString();
	}
};

function qvBtn(){
    var screen = '<div class="screen"/>';
    var QVbtn = '<a href="#quickView" title="View QuickView information for this item" class="QVbtn"><img alt="quick view button" src="'+jspStoreImgDir+'img/buttons/btn_quickView.gif" width="92" height="23" style="background:transparent;"></a>';
	var photoDiv = $('div.photo');
    $(photoDiv).hover(function(){
        var _this = $(this);
        var qvString = _this.find('a').unencode().split("/s/p_")[1].split("?")[0];
       
        //Check if the product is SHC product - Vendor Product enhancement
		if(qvString != null && (qvString.indexOf("_") > 0)) {
			var qvStrng = qvString.split("_");
			var qvSID = qvStrng[0];
			var qvCID = qvStrng[1];
			var qvPID = qvStrng[2].toUpperCase();

			// Omniture variables
        	var vert = omVrt.split("'").join("");
        	var cat = omCat.split("'").join("");
        	var sbcat = omSubCat.split("'").join("");

	        //Check whether its a SHC's store - Vendor Product enhancement
			if(qvSID=="10153"||qvSID=="11201"||qvSID=="10151"||qvSID=="10152"||qvSID=="10701"||qvSID=="11701"||qvSID=="11702"||qvSID=="11703"||qvSID=="10154"){ 
		        _this.addClass("over");
		        _this.append(screen);
		        $(QVbtn).appendTo(_this).css({left:function(){
		            return ($(this).parent().width()/2)-($(this).width()/2)
		        }}).attr('onclick','s.prop26=\''+vert+' > '+cat+' > '+sbcat+' > '+'Quick View\';s.events=\'event27\';s.product=\''+qvPID+'\';s.tl();').hide();
				if($('div#results').length){
		        _this.find(".screen").animate({height:70},200,function(){
		            $(this).parent().find(".QVbtn").fadeIn(300);
			        })
				}else if($('div.recoTabs').length){
					_this.find(".screen").animate({height:50},200,function(){
			            $(this).parent().find(".QVbtn").fadeIn(300);
			        })
				}
		       $('a[@href*=#quickView]').click(function(){
		            /*$.getJSON("js/product.json",function(data){
		                SEARS.Item.info(data);
		                SEARS.QuickView.launch();
		            })*/
		            showQuickView(qvSID,qvCID,qvPID);	            	            
		            return false;
				});
			}
	    }
    },function(){
        var _this = $(this);
        _this.removeClass("over");
        _this.find(".QVbtn").remove();
        _this.find(".screen").remove();
    });
} 

function showQuickView(storeId, catalogId, partNumber){
	var options = { 
		success: displayResponse,
		url:'QuickViewCmd?storeId='+storeId+'&catalogId='+catalogId+'&partNumber='+partNumber,
		type:'GET'
	};                        
	request=$.ajax(options)
	
	// SPECIAL CASE FOR RUNNING IN LOCAL SERVER
	/*$.getJSON("product.json",function(data){
	  SEARS.Item.info(data);
	  SEARS.QuickView.launch();
	});*/

}
function displayResponse(responseText){
    var data = eval('(' + responseText + ')');  
    SEARS.Item.info(data);
    SEARS.QuickView.launch();
} 
/* submitaddtocart function signature changed for smartcart*/
function submitAddToCart(image) {
	if(document.addToCart.addToCartBtn.value == 'false') {
        //Add to cart button has been clicked once
        
        /* Added for Smart Cart AddToCartAJAX --Start
        if((jsonProperties.enableATC == "true")&&(jsonProperties.enableSC == "true")){
            var qsMode = "OtherMode";
            var isSmartCartFlag = "smartCartSingle";
        var quantity = 1;
        var img = "http://s.sears.com/is/image/Sears/"
        img += image;
            var displayValue=isSmartCartFlag+"^"+img+"^"+qsMode;
        var sid = document.addToCart.storeId.value;
        var lid = document.addToCart.langId.value;
        var cid = document.addToCart.catalogId.value;
        var indicatorA = document.addToCart.IndicatorA.value;
        var vName = document.addToCart.vName.value;
        var cName = document.addToCart.cName.value;
        var sName = document.addToCart.sName.value;
        var grIdentifier = document.addToCart.grIdentifier.value;
        var addToCartBtn = document.addToCart.addToCartBtn.value;
        var catEntryId = document.addToCart.catEntryId_1.value;
        var quantity = document.addToCart.quantity_1.value;
        var partNumber = document.addToCart.partNumber.value;
        var grUserType = document.addToCart.grUserType.value;
        var url = "ProductOptionsOrderItemAddCmd?storeId=" + sid + "&langId="+lid+ "&catalogId="+cid+"&indicatorA="+indicatorA+"&vName="+vName+"&cName="+cName+"&sName="+sName+"&grIdentifier="+grIdentifier+"&URL=OrderItemDisplay&quantity_1="+quantity+"&catEntryId_1="+catEntryId+"&partNumber="+partNumber+"&addToCartBtn="+addToCartBtn+"&url=SmartCartUpdateView";
        ajaxCall(url,'addToCartAjax',null,displayValue);
        }
        /* Added for Smart Cart AddToCartAJAX --End 
        else{*/
            document.addToCart.submit();
			document.addToCart.addToCartBtn.value = 'true';
        //}
    }
}

(function($){

$.fn.bgIframe = $.fn.bgiframe = function(s) {
	// This is only for IE6
	if ( $.browser.msie && /6.0/.test(navigator.userAgent) ) {
		s = $.extend({
			top     : 'auto', // auto == .currentStyle.borderTopWidth
			left    : 'auto', // auto == .currentStyle.borderLeftWidth
			width   : 'auto', // auto == offsetWidth
			height  : 'auto', // auto == offsetHeight
			opacity : true,
			src     : 'javascript:false;'
		}, s || {});
		var prop = function(n){return n&&n.constructor==Number?n+'px':n;},
		    html = '<iframe class="bgiframe"frameborder="0"tabindex="-1"src="'+s.src+'"'+
		               'style="display:block;position:absolute;z-index:-1;'+
			               (s.opacity !== false?'filter:Alpha(Opacity=\'0\');':'')+
					       'top:'+(s.top=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderTopWidth)||0)*-1)+\'px\')':prop(s.top))+';'+
					       'left:'+(s.left=='auto'?'expression(((parseInt(this.parentNode.currentStyle.borderLeftWidth)||0)*-1)+\'px\')':prop(s.left))+';'+
					       'width:'+(s.width=='auto'?'expression(this.parentNode.offsetWidth+\'px\')':prop(s.width))+';'+
					       'height:'+(s.height=='auto'?'expression(this.parentNode.offsetHeight+\'px\')':prop(s.height))+';'+
					'"/>';
		return this.each(function() {
			if ( $('> iframe.bgiframe', this).length == 0 )
				this.insertBefore( document.createElement(html), this.firstChild );
		});
	}
	return this;
};

})($);

// Set up document when DOM ready //

$(function($){
    // Quick View Function //
	/* $("a[href='#quickView']").click(function(){
        $.getJSON("js/product.json",function(data){
            SEARS.Item.info(data);
            SEARS.QuickView.launch();
        })
        return false;
    }); */
    qvBtn();
});  

/*This function is to display the glossary. This function is called after the ajaxCall() in case of a glossary link.
We pass the html to be displayed in the pop-up as well as the id of the html element in this case it being a link */
function showGlossary(value,linkId){
    var hyperlinks = document.getElementsByTagName("a");
    for (var i=0; i<hyperlinks.length; i++) {
        if (hyperlinks[i].id == linkId){
            findPos(hyperlinks[i]);
            define(value);
        }
    }
} 

/*This function is to display the glossary. This function is called after the ajaxCall() in case of a glossary image.
We pass the html to be displayed in the pop-up as well as the id of the html element in this case it being an image */
function showImageGlossary(value,imageId){
        
    var images = document.getElementsByTagName("img");
    for (var i=0; i<images.length; i++) {
        if (images[i].id == imageId){
            findPos(images[i]);
            define(value);
        }
    }
}
