function saveUserView(){
	
	var product_id = $("#product-good-id").val() ;
	var url = "" ;
	var v1from = "" ;
	var hostUrl = "";
	var ua_opener = "" ;
	var ua_referrer = "" ;
	
	if(window != undefined && window.location != undefined && window.location.href != undefined)
	{
		url = window.location.href;
	}

	if(url!=""){
		
//		http://v1tuan.com/DetailListAction!getDetail.action?id=724&v1from=hao123
//		var paraString = url.substring(url.indexOf("?")+1,url.length).split("&"); 
//	    var paraObj = {} 
//	    for (i=0; j=paraString[i]; i++){ 
//	    paraObj[j.substring(0,j.indexOf("=")).toLowerCase()] = j.substring(j.indexOf("=")+1,j.length); 
//	    } 
//	    v1from = paraObj["v1from".toLowerCase()]; 
//		http://v1tuan.v1.cn/v1from-v1/index.html
//		http://www.v1tuan.com/id-456/v1from-hao123/show.html
//		var paraUrl = url.substring((url.indexOf("/", 8)+1), url.length) ;

		var index = url.indexOf("v1from") ;
		if(index!=-1){
			var paraUrl = url.substring(index, url.indexOf("/", index)) ;
			var paraMap = paraUrl.split("-") ;
			if(paraMap.length==2){
				var key = paraMap[0];
				var value = paraMap[1] ;
				if("v1from" == key){
					v1from = value ;
				}
			}
		}
		
	    if(typeof(v1from)=="undefined"){ 
	    	v1from = "null"; 
	    }
	    
	    var hostUrl = url.substring(0, url.indexOf("/", 8)) + "/userview?jsoncallback=?";
	    //var hostUrl = "http://127.0.0.1:8080/v1tuanv2/userview?jsoncallback=?";
	}

	try
	{
		if(window != undefined && window.opener != undefined && window.opener.location != undefined)
		{
			ua_opener = window.opener.location.href;
		}
	}
	catch(e){}
	
	try
	{
		if(document != undefined && document.referrer != undefined)
		{
			ua_referrer = document.referrer;
		}
	}
	catch(e){}
	
	$.ajax({
		  type: "get",
		  url: hostUrl,
		  data: {"product_id":product_id,
				 "url":url,
				 "v1from": v1from,
				 "opener": ua_opener,
				 "refer": ua_referrer},
		  dataType: "json",
		  timeout: 1000
		}); 
}

//Label切换
function enableTabSwitch()
{
	$this = $('#deal_tabs');
	   if ($this.length > 0) {
	       $this.children('li').click(function() {
	           $(this).siblings('li').removeClass('selected');
	           $(this).addClass('selected');

	           $(this).siblings('li').each(function(index) {
	               $('#' + $(this).attr('tab')).css('display', 'none');
	           });
	           $('#' + $(this).attr('tab')).css('display', 'block');
	       });
	   };
}
//首页主打商品倒计时
function indexenableCountdown() {
    var a = parseInt($('#time_left').val() * 1000);
    
    var b = (new Date()).getTime();
    
    var e = function() {
        var c = (new Date()).getTime();
        var ls = a + b - c;
        if (ls > 0) {
            var lh = parseInt(ls / 3600000).toString();
            lh = lh.length > 1 ? lh: '0' + lh;

            ls = ls % 3600000;
            var lm = parseInt(ls / 60000).toString();
            lm = lm.length > 1 ? lm: '0' + lm;

            lms = parseInt((ls % 60000) / 100);
            ls = parseInt(lms / 10);
            ms = lms - ls * 10;

            ls = ls.toString().length > 1 ? ls: '0' + ls;

            //11<em>时</em>50<em>分</em>33<em class="dot">&nbsp;</em>1<em>秒</em>
            var html = lh + '<em>时</em>' + lm + '<em>分</em>' + ls + '.' + ms + '<em>秒</em>';
            $('td#timer').html(html);
        } else {
            $("td#timer").stopTime('timer');
            $('td#timer').html('已结束');
            //window.location.reload();
        }
    };
    $("td#timer").everyTime(100, 'timer', e);
}


//首页其他商品倒计时
function otherenableCountdown() {
	
	
	$("input[name='othergoods_time_left']").each(function(i, n){
		
		var temp_id = $(this).attr("teamp_id") ;

		var show_temp = $("#"+temp_id) ;
		
		  var a = parseInt($(this).attr('value') * 1000);
		    
		  
		    var b = (new Date()).getTime();
		    
		    var e = function() {
		        var c = (new Date()).getTime();
		        var ls = a + b - c;
		        if (ls > 0) {
		            var lh = parseInt(ls / 3600000).toString();
		            lh = lh.length > 1 ? lh: '0' + lh;

		            ls = ls % 3600000;
		            var lm = parseInt(ls / 60000).toString();
		            lm = lm.length > 1 ? lm: '0' + lm;

		            lms = parseInt((ls % 60000) / 100);
		            ls = parseInt(lms / 10);
		            ms = lms - ls * 10;

		            ls = ls.toString().length > 1 ? ls: '0' + ls;

		            //11<em>时</em>50<em>分</em>33<em class="dot">&nbsp;</em>1<em>秒</em>
		            var html = lh + '<em>时</em>' + lm + '<em>分</em>' + ls + '.' + ms + '<em>秒</em>';
		            show_temp.html(html);
		        } else {
		        	show_temp.stopTime('timer');
		        	show_temp.html('已结束');
		           
		        }
		    };
		    show_temp.everyTime(100, show_temp.attr('id'), e);
		
	}) ;
	
	
	
  
}
//倒计时
function enableCountdown() {
    var a = parseInt($('#time_left').val() * 1000);
    var b = (new Date()).getTime();
    var e = function() {
        var c = (new Date()).getTime();
        var ls = a + b - c;
        if (ls > 0) {
            var lh = parseInt(ls / 3600000).toString();
            lh = lh.length > 1 ? lh: '0' + lh;

            ls = ls % 3600000;
            var lm = parseInt(ls / 60000).toString();
            lm = lm.length > 1 ? lm: '0' + lm;

            lms = parseInt((ls % 60000) / 100);
            ls = parseInt(lms / 10);
            ms = lms - ls * 10;

            ls = ls.toString().length > 1 ? ls: '0' + ls;

            //11<em>时</em>50<em>分</em>33<em class="dot">&nbsp;</em>1<em>秒</em>
            var html = lh + '<em>时</em>' + lm + '<em>分</em>' + ls + '.' + ms + '<em>秒</em>';
            $('div#timer').html(html);
        } else {
            $("div#timer").stopTime('timer');
            $('div#timer').html('已结束');
            //window.location.reload();
        }
    };
    $("div#timer").everyTime(100, 'timer', e);
}

//评论滚动
function enableCommentScroller() {
	var _currentCommentIndex = 0;
	var _currentCommentRecord;
	var _currentComment;
	var _$currentComment
	var _$lastComment;
	var _currentCommentHeight;
	var _$commentContainer = $('#sidebar .comment_container');
	var _$commentSource = $('.comment_content');
	if (_$commentContainer.length > 0 && _$commentSource.length>0) {

			var _commentRecords = new Array();
			_$commentSource.each(function(index) {
				var comment = {
				'title': $(this).find('.desc').html(),
				'comments': $(this).find('.content').html()
				}
				_commentRecords.push(comment);
			});
			
			if (_commentRecords.length>0) {
				_$commentContainer.everyTime(4000,function() {
					_$commentContainer.children('p').remove();
					_currentCommentRecord = _commentRecords[(_currentCommentIndex++) % _commentRecords.length];
					with(_currentCommentRecord) {
						comments = comments.length>30 ? comments.substr(0,30)+"..." : comments;
						_currentComment = "<div class='comment_content'>"+
							title+"<br  />"+
							"<div class='quote'>"+comments+"</div>"+
							"</div>";
						_$currentComment = $(_currentComment);
						// append
						_$commentContainer.append(_$currentComment);
						// slide
						if (_currentCommentIndex==1) {
							_$lastComment = _$currentComment;
						}
						else {
							_$commentContainer.animate({'top':'-=110px'}, 'slow', function() {
								// remove last one
								if (_$lastComment!=undefined && _$lastComment.length>0) {
									_$lastComment.remove();
								};
								_$lastComment = _$currentComment;
								_$commentContainer.css('top', 0);
							});
						};
					}
				});
			} else {
				_$commentContainer.append("<p style='margin-left:10px'>没有评论</p>");
			}
	};
}
