﻿/**
 * @author binli
 */
/**
 * 表格效果
 */
var tableId;
function tableEffect(value)
{
	tableId = value;
}
tableEffect.prototype.start = function(){
	var list_goods_type=""
	var $ul = $(tableId + '>ul');
	var $liArr = $ul.children('li').not('.Content_oneR_BdA');
				
	$liArr.css({'position':'relative','cursor':'pointer'});
	var data = {'pic':'productImages/gia.jpg','code':'GIA-1106490543','price':'9,850','weight':'0.310Ct','color':'F'}

	$list_arr_dl=$liArr.children('dl')

	for(var i=0;i<$list_arr_dl.length;i++){
		$list_arr_dd=$list_arr_dl[i].getElementsByTagName("dd")
		list_spec_id=$list_arr_dl[i].getElementsByTagName("input")[1].value
		for(var j=0;j<10;j++){
			$list_arr_dd[j].onclick=function(){
				if(document.getElementById("goods_type")!=undefined){
					 list_goods_type=document.getElementById("goods_type").value
				}
				window.open("diamond_detail.asp?id="+list_spec_id+"&goods_type="+list_goods_type)
			}
		
		}
	}

	$liArr.bind('mouseover',function(e){
		$liArr.removeClass('mouseover_li');
		$(this).addClass('mouseover_li');
		list_spec_id=this.getElementsByTagName("input")[1].value
		$.ajax({type:'post',
		url:'../../ajax_getDiamondDetail.asp',
		data:'spec_id='+list_spec_id,
		async :false,
		dataType:"json",
		success:function(result){
			data=result.items;
			
		}
			   
		});
		createPreview($(this),data);
	});
	$liArr.bind('mouseout',function(e){
		$(this).removeClass('mouseover_li');
		//$('#previewCon').remove();
		});	
	$('#Content_oneR_BcA').bind('mouseover',function(e){
		 $('#previewCon').remove();
	 }); 
}
function createPreview(parentNode,data){
	if($('#previewCon')){
		$('#previewCon').remove();
	}
	var previewCon = document.createElement('div');
	previewCon.id = 'previewCon';
	var items=data
	
	//alert(items[0].goods_cert);
	//$(previewCon).css({'position':"absolute",'z-index':999999});
	var certImg = "http://www.dxjc.com/SKIN/images/gia.jpg";//证书图片
	var certNum = items[0].goods_cert_type;//"GIA-17656219";//证书号
	var certLink="http://www2.gia.edu/reportcheck/index.cfm?fuseaction=home.showReportVerification&reportno="+items[0].goods_cert+"&weight="+parseFloat(items[0].goods_kela).toFixed(2);//证书链接
	var normalPrice = items[0].market_price;//市场价
	var dxPrice = items[0].goods_price;//东祥价
	var weight = items[0].goods_kela ;//钻重
	var clarity = items[0].goods_clarity ;//净度
	var color = items[0].goods_color ;//颜色
	var cut = items[0].goods_cut ;//切工
	var shape = items[0].goods_shape ;//形状
	
	var polish =items[0].goods_polish ;//抛光
	var light = items[0].d_yinguang ;//荧光
	var dimension = items[0].d_chicun;//尺寸 
	if(items[0].goods_location=="1"){
		certNum="请联系客服！"
	}
	var html = "";
	html+="   <div>";
	html+="     <div class=\"floatL\">";
	html+="       <img width=\"54\" height=\"54\" src=\"" + certImg + "\" />";
	html+="     </div>";
	html+="     <div style=\"padding-top: 15px;\" class=\"floatL left\">";
	html+="       <div class=\"left gia_font\">";
	html+="         证书编号查询";
	html+="       </div>";
	html+="       <div>";
	html+="         <a href=\""+ certLink +"\" target=\"_blank\" ><span class=\"titcolor\"  style=\"color:red\">"+ certNum + "</span></a>";
	html+="       </div>";
	html+="     </div>";
	html+="   </div>";
	html+="   <div class=\"left\">";
	html+="     <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"right\">";
	html+="       <tbody>";
	html+="         <tr>";
	html+="           <td valign=\"middle\" height=\"11\">";
	html+="             <div class=\"dotline\"></div>";
	html+="           </td>";
	html+="         </tr>";
	html+="       </tbody>";
	html+="      </table>";
	html+="    </div>";
	html+="    <div class=\"resetClear\"></div>";
	html+="    <div class=\"left\">";
	html+="      市场参考价:" + normalPrice + "元";
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      东祥实价:" + dxPrice + "元";
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      <table width=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"right\">";
	html+="        <tbody>";
	html+="          <tr>";
	html+="            <td valign=\"middle\" height=\"11\">";
	html+="              <div class=\"dotline\"></div>";
	html+="            </td>";
	html+="          </tr>";
	html+="        </tbody>";
	html+="      </table>";
	html+="    </div>";
	html+="    <div class=\"resetClear\"></div>";
	html+="    <div class=\"left\">";
	html+="      钻重:" + weight + "Ct" ;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      净度:" +  clarity;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      颜色:" + color;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      切工:" + cut;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      形状:" + shape;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      抛光:" + polish;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      荧光:" + light;
	html+="    </div>";
	html+="    <div class=\"left\">";
	html+="      尺寸:" + dimension + "mm";
	html+="    </div>";
	html+="    <div class=\"resetClear\"></div>";
	html+="    <div style=\"height: 9px; line-height: 9px;\" class=\"resetClear\">";
	html+="      <div class=\"dotline\"></div>";
	html+="    </div>";
	
	var popbar = document.createElement("div");
	popbar.id = "popbar";
	$(popbar).css({"left":0,"top":0});
	var popbarHtml = "<div style=\"border-right: 1px solid rgb(204, 204, 204); overflow: hidden; position: absolute; left: 169px; top: 0px; width: 10px; height: 141px; font-size: 0px; line-height: 0px;\" id=\"popDetailTopLine\"></div>";
popbarHtml += "<div style=\"position: absolute; left: 178px; top: 141px; width: 11px; text-align: right;\" id=\"popDetailArrow\"><img width=\"11\" height=\"18\" border=\"0\" src=\"SKIN/images/poparrow.gif\"/></div>";
popbarHtml += "<div style=\"border-right: 1px solid rgb(204, 204, 204); overflow: hidden; position: absolute; left: 169px; top: 159px; width: 10px; height: 141px; font-size: 0px; line-height: 0px;\" id=\"popDetailBottomLine\"></div>";
	$(popbar).html(popbarHtml);
	
	var popDetailMBAr = document.createElement('div');
	popDetailMBAr.id = "popDetailMBAr";
	$(popDetailMBAr).css({"border": "1px solid rgb(204, 204, 204)","border-style":" solid none solid solid", "overflow": "hidden", "position": "absolute", "top": "0px","left": "0px", "width": "178px","background-color": "rgb(255, 255, 255)"});
	var popDetailMBArHtml =  "<table width=\"100%\" height=\"100%\" cellspacing=\"0\" cellpadding=\"0\" border=\"0\" align=\"center\"><tbody><tr valign=\"top\"><td width=\"100%\"><div style=\"padding: 5px; line-height: 180%;\" id=\"popDetailContent\"><div id=\"showDetail\">";
	popDetailMBArHtml += html ;
	popDetailMBArHtml += "</div></div></td></tr></tbody></table>";
	$(popDetailMBAr).html(popDetailMBArHtml);
	$(popDetailMBAr).appendTo(popbar);
	
	$(popbar).appendTo(previewCon);
//	alert($(previewCon).html());
	$(previewCon).appendTo(parentNode);
	
}
                                                                                                     