
function WordReplace(){

var docurl = document.location.href;
if( docurl.search(/one-page-checkout.asp/)!=-1) 
{
     var content = document.getElementById("content_area").innerHTML;
	 var newstring = "<div style='text-align:right;margin-right:3px;padding-right:2px;font-weight:bold;'>Leave a comment about our<br>website and WIN an IPod!!<br><span style='color:#FF0000'>*Ten winners randomly<br>chosen each month.</span><table><tr><td colspan='2'>Our "+strWinnersMonth+" iPod Winners!</td></tr><tr><td><img border=0 src='/v/vspfiles/templates/disctest/images/iPodBLUE_thumb.jpg'></td><td style=\"width:118px;vertical-align:top;margin:0px;padding:0px;\" valign=\"top\">"+strWinners+"</td></tr></table></div>";
	 document.getElementById("content_area").innerHTML = content.replace(new RegExp("Order Comments:&nbsp;\<br\>", "i"),newstring);
  }
SiteFixes();
fnShowUserComments();
jQuery(function(){ 
    jQuery("ul#ticker01").liScroll();
	//OrderFinished.asp?Order=Finished&OrderID=2
	if("OrderFinished.asp" == jQuery.url.attr('file') && jQuery.url.param('Order') && "Finished" == jQuery.url.param('Order'))
	{
		if(jQuery.cookie("referrer_cust_id"))
		{
			intOrderId = jQuery.url.param('OrderID');
			strProtocol = jQuery.url.attr('protocol');
			if("" == strProtocol)
			{
				strProtocol = "http";	
			}
			intOrderId = jQuery.url.param('OrderID');
			referrer_cust_id = jQuery.cookie("referrer_cust_id");
			var objImg = new Image(0,0);
			referrer_cust_id = jQuery.cookie("referrer_cust_id");
			objImg.src = strProtocol+"://vip.discountsupplements.com/isn/instantScript.php?user_id="+referrer_cust_id+"&OrderID="+intOrderId;
		}
	}
	//for testing only
	if(0)//("one-page-checkout.asp" == jQuery.url.attr('file'))
	{
		intOrderId = jQuery.url.param('OrderID');
		//http://vip.discountsupplements.com/isn/instantScript.php?user_id=140&referer_email=vija_moncure@yahoo.com
		strProtocol = jQuery.url.attr('protocol');
		if("" == strProtocol)
		{
			strProtocol = "http";	
		}
		var objImg = new Image(0,0);
		referrer_cust_id = jQuery.cookie("referrer_cust_id");
		intOrderId=16039;
		objImg.src = strProtocol+"://vip.discountsupplements.com/isn/instantScript.php?user_id="+referrer_cust_id+"&OrderID="+intOrderId;
	}
	
	if(jQuery.url.param('referrer_id'))
	{
		var referrer_cust_id = jQuery.url.param('referrer_id');
		var arrCookieOptions = { path: '/', expires: 365 };
		// set cookie for 1000 days
		jQuery.cookie("referrer_cust_id", referrer_cust_id, arrCookieOptions);
	}
}); 
}
function fnSelectTshirtSize()
{
	var strSelectedSize = jQuery('#slSize').val();
	jQuery('input[name=CouponCode]').val(strSelectedSize);
	jQuery('#divWinner').hide('slow');
	jQuery('input[name=CouponCode]').focus();
	document.forms['form'].submit();
}
var flgFound = false;
var totalPrice = 0.0;
var couponAdded = false;
jQuery(document).ready(function(){
  jQuery('b').each(function(i, objEle){
	if(objEle.innerHTML.match(/Free T-Shirt/i))
	{
		couponAdded = true;
		return;
	}
  	if(flgFound)
	{
		totalPrice = jQuery.trim(objEle.innerHTML);;
		return;
	}
	if(objEle.innerHTML.match(/Total:/i))
	{
		flgFound = true;
	}
  });
  if(!couponAdded)
  {
	  var strLocation = ""+window.location+"";
	  if(strLocation.match(/ShoppingCart/i))
	  {
		  totalPrice = parseFloat(totalPrice.replace(/[\$,]/g,""));
		  if(totalPrice >= 1000)
		  {
			//show winner window
			jQuery('#divWinner').show('slow');
			jQuery("#divWinner").load("https://www.discountsupplements.com/v/vspfiles/templates/disctest/winner_window.html");
			//alert("TotalPrice: "+totalPrice);
		  }
	  }
  }
  if(jQuery('#display_customer_comments_all'))
  {
  	fnShowPage('1')
  }
});

//for comment scrolling
jQuery.fn.liScroll = function(settings) {
		settings = jQuery.extend({
		travelocity: 0.01
		}, settings);		
		return this.each(function(){
				var $strip = jQuery(this);
				$strip.addClass("clsCommentScroll")
				var stripWidth = 0;
				var $mask = $strip.wrap("<div class='mask'></div>");
				var $tickercontainer = $strip.parent().wrap("<div class='tickercontainer'></div>");								
				var containerWidth = $strip.parent().parent().width();	//a.k.a. 'mask' width 	
				$strip.find("li").each(function(i){
				stripWidth += jQuery(this, i).width();
				});
				$strip.width(stripWidth);			
				var totalTravel = stripWidth+containerWidth;
				var defTiming = totalTravel/settings.travelocity;	// thanks to Scott Waye		
				function scrollComments(spazio, tempo){
				$strip.animate({left: '-='+ spazio}, tempo, "linear", function(){$strip.css("left", containerWidth); scrollComments(totalTravel, defTiming);});
				}
				scrollComments(totalTravel, defTiming);				
				$strip.hover(function(){
				jQuery(this).stop();
				},
				function(){
				var offset = jQuery(this).offset();
				var residualSpace = offset.left + stripWidth;
				var residualTime = residualSpace/settings.travelocity;
				scrollComments(residualSpace, residualTime);
				});			
		});	
};
function fnShowPage(intPageNo)
{
   jQuery.ajax({
		  url: '/v/vspfiles/templates/disctest/comments_'+intPageNo+'.html',
		  cache:false,
		  success: function(data) {
			jQuery('#display_customer_comments_all').html(data);
			//alert(data);
		  }
		});
}
function fnShowPageWinner(intPageNo)
{
   jQuery.ajax({
		  url: '/v/vspfiles/templates/disctest/winners_'+intPageNo+'.html',
		  cache:false,
		  success: function(data) {
			jQuery('#display_customer_comments_all').html(data);
			//alert(data);
		  }
		});
}