<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<?php include(DDROOTPATH.'/cache/title/'.$pagetag.'_title.php');?>
<link href="/template/<?=MOBAN?>/css/common.css" rel="stylesheet" />
<link href="/template/<?=MOBAN?>/css/shai_c.css" rel="stylesheet" />
<style>
   #ad12 table{ width:290px;}
   #ad12 table,tbody,tr,td{ border:none;}
   </style>
<script language="javascript" type="text/javascript" src="template/<?=MOBAN?>/js/jquery.js"></script>
<script>
$(document).ready(function(){
	 $('#form').submit(function(){
		var comment=$('#formComment').val();
		if(comment==''){
		    alert('评论内容不能为空');
			$('#formComment').focus();
		}
		else if($('#num').attr('class')=='remind'){
            alert('评论内容超出50个字');
			$('#formComment').focus();
		}
		else{
		    $.post("a.php",{fun:'save_comment',shai_id:<?=$id?>,xs:'<?=$info['xs']?>',comment:comment},function(data){//alert(data);
		        if(data==10 || data==11 || data==12){
				    alert(msg[data]);
				}
				else{
				    $('#formComment').val('');
				    $('#num').text(50);
				    $(".morecomments ul").prepend(data);
				    $('.morecomments ul .show').show('slow');
				    $('#expression').hide('slow');
				    $('#comment_num').text(parseInt($('#comment_num').text())+1);
				}
		    });
		}
	    return false;
	});
});


function imgAuto(img, maxW, maxH) {
	var oriImg = document.createElement("img");
	oriImg.onload = function(){
		if (oriImg.width == 0 || oriImg.height == 0)
			return;
		var oriW$H = oriImg.width / oriImg.height;
		// var maxW$H = maxW / maxH;

		if (oriImg.height > maxH) {
			img.height = maxH;
			// img.removeAttribute("width");
			img.width = maxH * oriW$H;
		}
		if (img.width > maxW) {
			img.width = maxW;
			// img.removeAttribute("height");
			img.height = maxW / oriW$H;
		}

		if (maxH) {// if it defined the maxH argument
			if (img.height > 0)
				img.style.marginTop = (maxH - img.height) / 2 + "px";
		}
	};
	oriImg.src = img.src;
}

expressionShouldShow=0;

msg=new Array();
msg[6]='您已经送过红心';
msg[7]='登陆才能送红心哦';
msg[10]='两次评论间隔10秒';
msg[11]='您的等级不足，不能评论';
msg[12]='评论不能为空或者含有敏感词';

function addExpression(myField, myValue)
{
	var h=$("#"+myField).val();
	h+=myValue;
	$("#"+myField).val(h);/*
    myField = document.getElementById(myField);
    //IE
    if (document.selection)
    {
        myField.focus();
        sel = document.selection.createRange();
        myValue = myValue;
        sel.text = myValue;
        sel.select();
    }
    //MOZILLA
    else if (myField.selectionStart || myField.selectionStart == '0')
    {
        var startPos = myField.selectionStart;
        var endPos = myField.selectionEnd;
        // save scrollTop before insert
        var restoreTop = myField.scrollTop;
        myValue = expression[myValue];
        myField.value = myField.value.substring(0, startPos) + myValue + myField.value.substring(endPos,myField.value.length);
        if (restoreTop > 0)
        {
            // restore previous scrollTop
            myField.scrollTop = restoreTop;
        }
        myField.focus();
        myField.selectionStart = startPos + myValue.length;
        myField.selectionEnd = startPos + myValue.length;
    }
    else
    {
        myField.value += myValue;
        myField.focus();
    }
	*/
}

function openShare(name){
	var url=window.location.href;
	if(name=='sina'){
	    var url='http://v.t.sina.com.cn/share/share.php?&title=<?=urlencode($info['title'])?>&url='+url+'&source=anzhong&retcode=0';
	}
	if(name=='renren'){
	    var url='http://share.renren.com/share/buttonshare.do?link='+url+'&title=<?=urlencode($info['title'])?>';
	}
	if(name=='tx'){
	    var url='http://v.t.qq.com/share/share.php?title=<?=urlencode($info['title'])?>&url='+url;
	}
    window.open(url,name,"top=100,left=400,width=610,height=570,toolbar=no,menubar=no,scrollbars=yes,resizable=no,location=no,status=no");
}

function mouseLocation(e){
	rightX=(document.body.offsetWidth-950)/2;
    if(e.pageX<rightX || e.pageX>rightX+700 || e.pageY<640 || e.pageY>765){
	    $('#expression').fadeOut('slow');
	}
}

$.ajaxSetup ({
    cache: false //关闭AJAX相应的缓存
});
$(function(){;
	//$('body').click(mouseLocation);
	$('#formComment').bind('focus keyup input paste',function(){  //采用几个事件来触发（已增加鼠标粘贴事件）   
	    $('#num').text(50-$(this).attr("value").length);  //获取评论框字符长度并添加到ID="num"元素上
		if((50-$(this).attr("value").length)<0){
			$('#num').addClass('remind');
        }
		else{
		    $('#num').removeClass('remind');
		}
	});
	
	$('.like').click(function(){
	    var hart=parseInt($('#hart_num').text());
		var user_hart=parseInt($('#user_hart').text());
		$.post("a.php",{fun:'inc_hart',shai_id:<?=$id?>,xs:'<?=$info['xs']?>'},function(data){//alert(data);
			var data= eval("(" + data + ")");
			if(data.err==0){
				$('#hart_num').text(hart+1);
				$('#user_hart').text(user_hart+1);
			}
			else{
			    alert(msg[data.msg]);
			}
		});
	});
	var ssdsd=$("#pro_phos").attr("src");
	if(ssdsd==""){alert("没有了");history.back();}
	var godrt=$(".good").height()+15;
	$(".good-right").css("height",godrt+"px");
});
function tiaozhuan(n){
	id=<?=$id?>;
	if(n==0){id-=1;window.location.href="baobei.php?id="+id;};
	if(n==1){id+=1;window.location.href="baobei.php?id="+id;};
};
</script>
</head>

<body>
<?php include('header.tpl.php');?>
<?php include('nav.tpl.php');?>
<div id="weizhi"></div>
<div class="main">
<div class="white_top"><div class="white_top_left"></div><div class="white_top_middle"></div><div class="white_top_right"></div></div>
<div class="white_bg">
  <table class="cat" border="0" >
    <tr>
      <td <?php if($catid==''){?> class="curcat"<?php }?>><a href="baobeilist<?=$end?>">最新分享</a></td>
      <?php foreach($shaicat_arr as $k=>$v){?>
      <td <?php if($k==$catid){?> class="curcat"<?php }?>><a href="baobeilist<?=$url_head_catid?><?=$k?><?=$url_head_sort?><?=$sort?><?=$url_head_key?><?=$url_head_page?>1<?=$url_end?>"><?=$v?></a></td>
      <?php }?>
    </tr>
  </table>
  <div class="space">
    <div class="space-left" style="float:left;">
      <div style="float:left; padding:15px;">
      <a href="userbao.php?id=<?=$info['dduserid']?>" style="font-size:30px">
      <img onerror="this.src='images/noavatar_middle.gif'" src="upload/avatar/<?=get_avatar_filepath($info['dduserid'], $size = 'middle', $type = '')?>" /></a>
      </div>
    </div>
    <div class="space-center">
      <div class="username">
          <table border="0">
  <tr>
    <td><a href="userbao.php?id=<?=$info['dduserid']?>" style="font-size:30px"><?=$info['ddusername']?></a></td>
    <td width="25" align="center"><div style="width:1px; height:30px; border-left:1px #C5C5C5 dotted">&nbsp;</div></td>
    <td style="font-size:18px"><b style="font-family:'宋体'; color:#666666">晒单</b><b style="color:#FF6699; margin-left:10px"><?=$shai_nums?></b>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b style="font-family:'宋体'; color:#666666">分享</b><b style="color:#FF6699; margin-left:10px"><?=$share_nums?></b></td>
  </tr>
</table>
      </div>
      <div class="goods-top">
      <ul>
        <li <?php if($xs=='all'){?> class="cur"<?php }?>><a href="userbao<?=$url_head_id?><?=$info['dduserid']?><?=WJT?'-':'&catid='?><?=$catid?><?=$url_head_xs?>all<?=$url_head_page?>1<?=$url_end?>">Ta的宝贝</a></li>
        <li <?php if($xs=='like'){?> class="cur"<?php }?>><a href="userbao<?=$url_head_id?><?=$info['dduserid']?><?=WJT?'-':'&catid='?><?=$catid?><?=$url_head_xs?>like<?=$url_head_page?>1<?=$url_end?>">Ta的喜欢</a></li>
      </ul>
    </div>
    </div>
    <div class="space-right">
      <div style="border:#FF0099 1px solid; width:110px; height:28px; color:#FF6699;">
        <div style="margin-top:7px; margin-left:22px">
          <div style="float:left; height:19px; line-height:19px; font-size:16px">收到的</div>
          <div style=" width:16px" class="icon2"></div>
        </div>
      </div>
      <div id="user_hart" style="border:#8C8C8C 1px dashed; border-top:0px; width:110px; height:44px; color:#FF3261; text-align:center; font-size:24px; font-weight:bold; line-height:44px">
	  <?=$info['hart_num']?$info['hart_num']:0?></div>
    </div>
    
  </div>
  <div style="height:2px; overflow:hidden; background:#F0F0F0">&nbsp;</div>
  <div class="good" style="padding-top:15px">
    <div class="good-left">
      <div class="info">
      <a name="p"></a>
      <script type="text/javascript">
		 function loadImg(){
				var w=$("#pro_phos").attr("width");
				var h=$("#pro_phos").attr("height");
				if(w>430){
					h=430*h/w
					$("#pro_phos").attr("height",h);
					$("#pro_phos").attr("width","430");
				};
			};
        </script>
        <div class="img">
        <div id="info_top">
        <h3 style="width:270px;">
        <a target="_blank" title="<?=$info['title']?>" href="<?=$gotoitem?>" style="font-family:宋体"><?=$info['title']?></a>
        </h3>
        <span style="float:left; padding-left:15px; color:#669900; font-family:黑体; font-size:14px">$<?=$info['price']?><?php if($info['price']>0){?>[<span style="font-size:11px">返</span>$<?=$info['fxje']?>]<?php }?></span></div>
        <a id="goumai" target="_blank" title="<?=$info['title']?>" href="<?=$gotoitem?>">购买链接</a>
        <div id="img_pic">
        <div id="shangyige" onclick="tiaozhuan(0)"></div>
        <div id="xiayige" onclick="tiaozhuan(1)"></div>
        <a target="_blank" style="color:#FFF; font-size:14px" href="<?=$gotoitem?>">
        <img id="pro_phos" src="topic.php?pic=<?=base64_encode($info['image'])?>" align="<?=$info['title']?>" onload="loadImg()" />
        </a>
        </div>
        
        <div id="info_btm">
        <div id="pinglun">
             <div class="pinglun_s pinglun_s1 like" title="送红心" style="cursor:pointer;"><span></span></div>
             <div class="pinglun_s pinglun_s2"></div>
             <div class="pinglun_s pinglun_s3"><span id="hart_num"><?=$info['hart']?></span></div>
             <div class="pinglun_s pinglun_s4">
             </div>
          </div>
             <div style=" width:350px; height:30px; position:relative; left:330px; *left:130px; top:-35px; overflow:hidden;">
                <table width="350" border="0" cellspacing="0" cellpadding="0">
 <!-- Baidu Button BEGIN -->
    <div id="bdshare" class="bdshare_t bds_tools get-codes-bdshare">
        <a class="bds_tsina">新浪微博</a>
        <a class="bds_tqq">腾讯微博</a>
        <a class="bds_qzone">QQ空间</a>
        <a class="bds_renren">人人网</a>
        <span class="bds_more">更多</span>
    </div>
<script type="text/javascript" id="bdshare_js" data="type=tools&amp;uid=446177" ></script>
<script type="text/javascript" id="bdshell_js"></script>
<script type="text/javascript">
	document.getElementById("bdshell_js").src = "http://share.baidu.com/static/js/shell_v2.js?t=" + new Date().getHours();
</script>
<!-- Baidu Button END -->
</table>
             </div>
        </div>
        </div>
        <div class="more">
          <div class="comment">
            <div style="margin-top:10px; margin-left:10px">
            <dl>
            	<dt><img onerror="this.src='images/noavatar_middle.gif'" src="upload/avatar/<?=get_avatar_filepath($info['dduserid'], $size = 'small', $type = '')?>" /></dt>
                <dd style="color:#e71f8d; font-weight:bold; height:25px; overflow:hidden;"><?=$info['ddusername']?></dd>
                <dd><span style="float:left;"><?=$info['comment']?></span><span style="float:right; font-size:12px; padding-top:10px; padding-right:10px;"><?=date('m月d日 H:s',$info['time'])?></span></dd>
            </dl>
            </div>
          </div>
        </div>
        <div style="clear:both"></div>
      </div>
      <div class="comments">
      <div>
        <div class="form" style="margin-bottom:50px;">
        <div style="height:37px; text-align:right; padding-right:30px; line-height:37px; vertical-align:middle; overflow:hidden;">还可以输入<span id="num">50</span>个字</div>
          <form id="form">
            <textarea class="text" id="formComment"></textarea>
            <input type="submit" class="submit" value="评论" id="formSubmit" <?php if($_SESSION['dduserid']<$shai_set['limit_level']){?>  title="等级不足，不能评论" disabled="disabled"<?php }?> />
          </form>
          <div id="biaoqngtianjia" style=" width:100%; height:30px; text-indent:20px; cursor:pointer; clear:both; overflow:hidden;">
          <span id="addExpression" onclick="$('#expression').fadeIn();">添加</span>
          </div>
          <div id="expression">
          <ul>
            <?php foreach($expression as $k=>$v){?>
            <li><img src="<?=$navheadurl?>images/emoticons/<?=$k?>.gif" style="cursor:pointer" onclick="addExpression('formComment','{<?=$v?>}');"/></li>
            <?php }?>
          </ul>
          <div style=" float:left; margin-left:3px;cursor:pointer; width:30px" onclick="$('#expression').fadeOut('slow');">关闭</div>
          </div>
        </div>
        </div>
        <div class="clear"></div>
        <script type="text/javascript">
        $(document).ready(function(){
			var h=$("#hhnjknjmkd").height();
			if(h>400){$("#hhnjknjmkd").css("height","400px");}
		});
        </script>
        <div class="morecomments">
          <ul id="hhnjknjmkd" style="height:auto; overflow:hidden">
          <?php foreach($comment_arr as $row){?>
            <li style="width:630px; height:60px; border-bottom:#a8b190 1 dotted; padding:0; margin:0; margin-bottom:5px; overflow:hidden;">
              <div style="width:40px; height:55px; text-align:left; float:left; padding-top:5px; overflow:hidden;">
              <a href="userbao.php?id=<?=$row['dduserid']?>">
              <img onerror="this.src='images/noavatar_small.gif'" width="32" height="32" src="upload/avatar/<?=get_avatar_filepath($row['dduserid'], $size = 'small', $type = '')?>" />
              </a>
              </div>
              <div style=" width:570px; height:60px; line-height:20px; float:left; overflow:hidden;">
              	<span style="color:#ff7fa6; font-size:14px;"><?=$row['ddusername']?><span style="color:#b3b3b3; font-size:12px;">(<?=date('m月d日 H:i',$row['time'])?>)</span></span><br />
              	<span style="color:#666666; font-size:12px;"><?=$row['comment']?></span>
              </div>
            </li>
           <?php }?>
          </ul>
        </div>
        <div class="megas512" style="text-align:center; margin-top:5px;"><?php pageft($comment_nums,$pagesize,1,0,0,10,$page_baobei);echo $pagenav;?></div>
      </div>
      <div class="clear"></div>
    </div>
    <div class="good-right">
    <div style=" width:290px; height:20px;position:absolute; z-index:55; margin-top:-15px; *margin-left:-17px; background:#f7f7f7; overflow:hidden;"></div>
    <h3 style=" color:#5a6243;text-indent:18px; padding-top:10px; padding-bottom:10px;">猜你喜欢的其他宝贝</h3>
    <div style="width:290px; height:auto; overflow:hidden;">
      <?php $n=0; foreach($orther_baobei as $arr){$n++;?>
        <a href="baobei<?=$url_head_id?><?=$arr['id']?><?=$url_end?>"><img style="width:118px; height:118px; float:left; margin-left:18px; margin-bottom:18px; overflow:hidden;" width="118" height="118" src="topic.php?pic=<?=base64_encode($arr['image'])?>" alt="<?=$arr['title']?>" /></a>
        <?php if($n==2){?>
        <?php }?>
      <?php }?>
</div>
	<div style="width:270px; height:780px; overflow:hidden; border:none; margin-top:10px">
    <div id="ad12"><?=AD(12)?></div>
    </div>
    </div>
    <div class="clear"></div>
  </div>
</div>
<div class="white_bottomm"><div class="white_bottom_left"></div><div class="white_bottom_middle"></div><div class="white_bottom_right"></div>
</div></div>
<?php include('footer.tpl.php');?>
</body>
</html>
