function getUrlVars() {
        var vars = [], URL = window.location.href, 
                params = URL.slice(URL.indexOf('?') + 1), 
                hashes, hash, indices;
        hashes = params.split('&');
        for (indices in hashes) {
                hash = hashes[indices].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
        }
        return vars;
};
var $_GET = getUrlVars();

function popUp(URL) {
    day = new Date();
    id = day.getTime();
    eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=200,height=200');");
}

function getQty(flr){
 var todaysDate = new Date();
 var todaysDay = todaysDate.getDay()+1;
 if(todaysDay<7){
  var offset = todaysDay+1;
 }else{
  var offset = todaysDay-7;
 }
 var cntdn = 7-offset;
 var qty = Math.ceil(Math.random()*4)+(cntdn*2) + flr;
 return qty;
}
 
function dispQty(val){
 if(document.cookie.indexOf('qval')!=-1){
                var eventMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  var eventEnd = new Date();
  if(eventEnd.getDay()<=5){
   eventEnd.setDate(eventEnd.getDate()+(5-eventEnd.getDay()));
  }else{
   eventEnd.setDate(eventEnd.getDate()+6);
  }
  var endDt = 'Fri, '+eventMonth[eventEnd.getMonth()]+' '+eventEnd.getDate();
  if(new Date().getDay()==6){
      endDt = 'TODAY!';
  }
  var endDay = new Array('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
  var endMonth = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
  endDt = endDay[new Date().getDay()]+', '+endMonth[new Date().getMonth()]+' '+(new Date().getDate());
/*if (document.location.href.toLowerCase().indexOf('9propk') > -1 || document.location.href.toLowerCase().indexOf('12propk') > -1 || document.location.href.toLowerCase().indexOf('16propk') > -1) {
    var saleDateToday = new Date();
    if (saleDateToday.getDay() < 3 || saleDateToday.getDay() > 4) {
        endDt = 'Tuesday!';
    } else if (saleDateToday.getDay() >= 3 && saleDateToday.getDay() <= 4) {
        endDt = 'Thursday!';
    }
}*/
                document.write('<t'+'ab'+'le ce'+'llp'+'addin'+'g="0" ce'+'lls'+'pa'+'cing="0" bo'+'rd'+'er="0"><t'+'r><t'+'d st'+'yle='+'"bor'+'der: '+'1px '+'soli'+'d #66'+'6; bac'+'kgro'+'und-c'+'olo'+'r: #ee'+'f; pad'+'din'+'g: 7p'+'x;">');
                document.write('<b'+'>SA'+'LE'+' EN'+'DS:<sp'+'an st'+'yle="co'+'lor: #c0'+'0;"> '+endDt+'</s'+'pan></'+'b> - ');
                document.write('<sp'
                +'an s'
                +'ty'+'le="co'
                +'lo'+'r: #33'
                +'3; fo'
                +'nt-w'+'ei'
                +'ght: b'+'ol'
                +'d;">On'
                +'ly '
                +val
                +' pcs le'+'ft!'
                +' </sp'
                +'an>'
                +'<sp'
                +'an st'
                +'yle="co'
                +'lor:'
                +' #c0'
                +'0; fo'
                +'nt-w'
                +'eig'
                +'ht: '
                +'bol'
                +'d;"'
                +'>B'
                +'uy N'
                +'ow!</sp'
                +'an>'
                +'</sp'
                +'an'
                +'><b'
                +'r />');
                document.write('</t'+'d></t'+'r></t'+'ab'+'le>');
 }
}
 
function chkQty(prodCode,flr){
 if((document.cookie.indexOf('qval'+prodCode+'=')!=-1)||(document.cookie.indexOf(prodCode+'qtypcs')!=-1)){
  dispQty(parseInt(document.cookie.substr((document.cookie.indexOf('qval'+prodCode+'=')+(5+prodCode.length)),document.cookie.indexOf(prodCode+'qtypcs'))));
 }else{
  var ranqty=getQty(flr);
                var expiryDate=new Date();
                expiryDate.setDate(expiryDate.getDate()+1);
                expiryDate.setHours(0,0,0);
  document.cookie="qval"+prodCode+"="+ranqty+prodCode+"qtypcs; expires="+expiryDate.toGMTString()+";path=/";
  dispQty(ranqty);
 }
}

    function wopen(url, name, w, h){
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
        w += 32;
        h += 96;
        var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');
         win.resizeTo(w, h);
         win.focus();
    }
        var timeout	= 500;
        var closetimer	= 0;
        var ddmenuitem	= 0;
        function mopen(id){	
        	mcancelclosetime();
        	if(ddmenuitem){
				ddmenuitem.style.visibility = 'hidden';
			}
        	ddmenuitem = document.getElementById(id);
        	ddmenuitem.style.visibility = 'visible';
        }

        function mclose(){
        	if(ddmenuitem){
				ddmenuitem.style.visibility = 'hidden';
			}
        }
        function mclosetime(){
			closetimer = window.setTimeout(mclose, timeout);
        }
        function mcancelclosetime(){
			if(closetimer){
        		window.clearTimeout(closetimer);
		        closetimer = null;
        	}
        }
        document.onclick = mclose;

var ifrid=new Array();
function sendAffiliateId(affiliateId){
    var ifr=document.createElement('iframe');
    ifrid[ifrid.length]=Math.random();
    ifr.id=ifrid[ifrid.length-1];
    ifr.name=ifr.id;
    ifr.width="0";
    ifr.height="0";
    document.body.appendChild(ifr);
    document.getElementById(ifrid[ifrid.length-1]).src="https://www.closeoutcctv.com/terms_privacy.asp?Click="+affiliateId;
}
function oSpaceProductDescriptionsOut(){
    for(i=0;i<document.getElementsByName('oItemDescriptionP').length;i++)
    {
        var obr1=document.createElement('BR');
        var obr2=document.createElement('BR');
        var obr3=document.createElement('BR');
        document.getElementsByName('oItemDescriptionP')[i].parentNode.appendChild(obr1);
        document.getElementsByName('oItemDescriptionP')[i].parentNode.appendChild(obr2);
        document.getElementsByName('oItemDescriptionP')[i].parentNode.appendChild(obr3);
    }
}

function debug(func) {
    var trueTest = /^(true|(y|yes))$/;
    if(trueTest.test($_GET["debug"])) {
        func();
    }
}
$(document).ready(function() {
    $('#head_cart_link')[0].onmouseover=function() {
        return false;
    };
});

$(function(){
$('table[cellspacing="5"][cellpadding="3"][border="0"] tr td:eq(0)').attr('valign','middle');
$("input[type='text'][name^='QTY.']").each(function(){

if ($(this).attr('size') == "3")
	{
	$(this).parent('td').after('<td valign="middle" style="padding-left:5px;padding-right:5px;" valign="top"><input border="0" type="image" alt="UP" title="Up" name="Up.' + this.name + '" src="/v/vspfiles/templates/90/images/buttons/btn_quantity_up1.gif"><br><br><input border="0" type="image" alt="Down" title="Down" name="Down.' + this.name + '" src="/v/vspfiles/templates/90/images/buttons/btn_quantity_down1.gif"></td>');
	}
	else
	{
	$(this).parent('td').after('<td style="padding-left:5px;padding-right:5px;" valign="top"><input border="0" type="image" alt="UP" title="Up" name="Up.' + this.name + '" src="/v/vspfiles/templates/90/images/buttons/btn_quantity_up1.gif"><br><br><input border="0" type="image" alt="Down" title="Down" name="Down.' + this.name + '" src="/v/vspfiles/templates/90/images/buttons/btn_quantity_down1.gif"></td>');
	}
});


$("input[type='image'][name^='Up.']").click( function() {
var this_name = $(this).attr('name');
this_name = this_name.replace('Up.','');
var current_quan = parseInt($("input[type='text'][name='"+ this_name + "']").val());
current_quan = current_quan + 1;
$("input[type='text'][name='"+ this_name +"']").val(current_quan);
return false;
});

$("input[type='image'][name^='Down.']").click( function() {
var this_name = $(this).attr('name');
this_name = this_name.replace('Down.','');
var current_quan = parseInt($("input[type='text'][name='"+ this_name + "']").val());
if (current_quan > 1){ 
current_quan = current_quan - 1;
}
$("input[type='text'][name='"+ this_name +"']").val(current_quan);
return false;
}); 
});

$(function(){
    var current_val;
    var price_result;
    if ( typeof global_Current_ProductCode != "undefined" && $("[name^=SELECT___] option").length )
    {
        var product_orig_price = parseFloat($('font.pricecolor.colors_productprice:not(.pricecolorsmall)').find('.price1:last').text().replace('$','').replace(/,/g,''));
        //	var product_orig_price = parseFloat($(".price1:last").text().replace('$','').replace(/,/g,''));
        current_val = product_orig_price;

        $("select[name^='SELECT___'],input[name^='SELECT___'][type='radio']").change(function(){
            $("select[name^='SELECT___'],input[name^='SELECT___'][type='radio']").each(function(){
                var recal_var = $(this).find("option:selected").text();

                if (recal_var.indexOf('[Subtract -$') >0){
                    price_result = recal_var.split('$')[1].slice(0,-1).replace(/,/g,'');
                    current_val=current_val-price_result;
                }
                else if (recal_var.indexOf('[Add $') >0){
                    price_result = parseFloat(recal_var.split('$')[1].slice(0,-1).replace(/,/g,''));
                    current_val=current_val+price_result;
                }
            });

            //	$(".price1:last").replaceWith('<span class="price1">$' + $.currency(current_val,{s:",",d:".",c:2}) + '</span>');
            //	$(".price1:last").html('$' + $.currency(current_val,{s:",",d:".",c:2}));
            $('font.pricecolor.colors_productprice:not(.pricecolorsmall)').find('.price1:last').html('$' + $.currency(current_val,{
                s:",",
                d:".",
                c:2
            }));
            current_val=product_orig_price;
        });

        $("a[href^='javascript:change_option']").each(function(){
            var current_val2;
            var price_result2;
            //		var product_orig_price2 = parseFloat($(".price1:last").text().replace('$','').replace(/,/g,''));
            var product_orig_price2 = parseFloat($('font.pricecolor.colors_productprice:not(.pricecolorsmall)').find('.price1:last').text().replace('$','').replace(/,/g,''));
            $(this).click(function() {
                var result_href = $(this).attr('href').match(/\'(.*?)\'/)[1];
                var result_val = $(this).attr('href').match(/\,(.*?)\)/)[1];
                change_option(result_href,result_val);
                current_val2 = product_orig_price2;
                $("select[name^='SELECT___'],input[name^='SELECT___'][type='radio']").each(function(){
                    var recal_var2 = $(this).find("option:selected").text();
                    if (recal_var2.indexOf('[Subtract -$') >0){
                        price_result2 = recal_var2.split('$')[1].slice(0,-1).replace(/,/g,'');
                        current_val2=current_val2-price_result2;
                    }
                    else if (recal_var2.indexOf('[Add $') >0){
                        price_result2 = parseFloat(recal_var2.split('$')[1].slice(0,-1));
                        current_val2=current_val2+price_result2;
                    }
                });
                //$(".price1:last").replaceWith('<span class="price1">$' + $.currency(current_val2,{s:",",d:".",c:2}) + '</span>');
                //$(".price1:last").html('$' + $.currency(current_val2,{s:",",d:".",c:2}));
                $('font.pricecolor.colors_productprice:not(.pricecolorsmall)').find('.price1:last').html('$' + $.currency(current_val,{
                    s:",",
                    d:".",
                    c:2
                }));
                current_val2=product_orig_price2;
                return false;
            });
        });
    }
});

$(function(){
if (typeof(global_Current_ProductCode) !="undefined")
	{
		$('td[colspan="2"]:eq(2)').find('img').remove();
		if ($('#pt493').length == 0 )
			{	
			$('#Header_ProductDetail_ProductDetails').closest('table').before($('table[width="100%"][cellspacing="0"][cellpadding="10"][border="0"]:eq(0)'));
			$('table[width="100%"][cellspacing="0"][cellpadding="10"][border="0"]:eq(0) tr td b').after('<a href="#reviews" style="margin-left:5px;">  Read Reviews</a> | ');
			$('table[width="100%"][cellspacing="0"][cellpadding="10"][border="0"]:eq(0)').find('br:first').remove();
			$('.Reviews:eq(0)').closest('table').before('<table id="reviews" width="100%" cellspacing="0" cellpadding="10"><tr><td>Customer Reviews:</td></tr></table>');
			}
		$('#pt656').parents('table:eq(1)').before($('#pt493'));
		$('#pt493').after('<br>');
	}
});

jQuery(function(){
var rev_text;
var template= '90'; // your template name/number
	jQuery('table.v65-productDisplay').find('a.productnamecolor.colors_productname:not(.skip)').each(function(){
var $this=jQuery(this);
		var star_link = jQuery(this).attr('href');
		var star_link_query_url= '/ProductComparison.asp?ProductCode1=' + star_link.substr(star_link.lastIndexOf('-p/')+3).replace(".htm", "") + '&o=1';
		var rev_link='/ReviewsList.asp?ProductCode='+ star_link.substr(star_link.lastIndexOf('-p/')+3).replace(".htm", "");
		jQuery.ajax({
			url: star_link_query_url,
			type: 'GET',
			cache: false,
			success: function(data){
				if(jQuery(data).find("#pt691").length){
						var rev_number = jQuery(data).find("#pt691").text();
						if (rev_number=="1"){		
							rev_text="Review";
						}else{
							rev_text="Reviews";
						}
					var star_value= jQuery(data).find('#pt691').closest('a').find('img').attr('src');
					var star_number = star_value.substr(star_value.lastIndexOf('/')+1).replace('star','').replace('.gif','');
					switch (star_number){
							case '1': star_text= "Not That Good";
												break;
  						case '1.5': star_text= "Not That Good";
            						break;
  						case '2': star_text= "Needs That Special Something";
            						break;
  						case '2.5': star_text= "Needs That Special Something";
            						break;
  						case '3': star_text= "Average, ordinary";
            						break;
  						case '3.5': star_text= "Average, ordinary";
            						break;
  						case '4': star_text= "That's Good Stuff";
            						break;
  						case '4.5': star_text= "Almost Perfect. Doesn't get much better";
            						break;
  						case '5': star_text= "Perfect. It doesn't get any better";
            						break;
  						default:  star_text= "Perfect. It doesn't get any better";
					}
					if(jQuery($this).closest('table').is('.popular')){
					jQuery($this).closest('table').find('a[href="'+star_link+'"]:not(.smalltext, .colors_text, .no_stars)').closest('td').append('<div align="center"><a href="'+rev_link+'"><img width="64px" height="12px" class="star_new" title="'+star_text+'" alt="'+star_text+'" border="0" src="'+star_value+'"></a><span class="review_quantity">'+rev_number+' '+rev_text+'</span></div>');
					}else{
					jQuery($this).closest('table').find('a[href="'+star_link+'"]:not(.smalltext, .colors_text, .no_stars)').css('font', 'bold 11px Verdana').eq(1).closest('td').append('<br><a href="'+rev_link+'"><img width="64px" height="12px" class="star_new" title="'+star_text+'" alt="'+star_text+'" border="0" src="'+star_value+'"></a><br><span class="review_quantity">'+rev_number+' '+rev_text+'</span>');
					}
					jQuery('.star_new').css('margin-top','10px').css('margin-bottom','5px');
					jQuery('.review_quantity').css('margin-bottom','5px').css('display','block');
				}	
			} 
		})
	}); 
});

function TrackingPopUp()
{
  var windowName = 'userConsole'; 
  var popUp = window.open('/v/vspfiles/templates/Closeout_90_09-08-11/assets/tracking/tracking.html', windowName, 'width=1000, height=725, left=24, top=24, scrollbars, resizable');
  if (popUp == null || typeof(popUp)=='undefined') { 	
	alert('Please disable your pop-up blocker and click the "Track Your Order" link again.'); 
  } 
  else { 	
	popUp.focus();}
}
