﻿try  {  document.domain='dangdang.com';  }
catch(err) {} 

function AddPDNothing(ProdID)
{
	var url='http://misc.dangdang.com/lackproduct/pdnothing.aspx?pdname='+ProdID;   
    
    var width=448;
    var height=227;
    var w = 1024;
    var h = 768;
    if (document.all || document.layers)
    {
              w = screen.availWidth;
              h = screen.availHeight;
    }
    var leftPos = (w/2-width/2);
    var topPos = (h/2.3-height/2.3);
    var ew=window.open(url,"","width="+width+",height="+height+",top="+topPos+",left="+leftPos);
}

function DrawImage(img,width,height){
//if(width==null) width=78;
//if(height==null) height=106;
//var image=new Image(); 
//image.src=img.src; 
//	if(image.width>0 && image.height>0)
//	{
//	  if(image.width!=width)
//	  {
//	  	rate=image.height/image.width;
//	  	newHeight=rate*width;
//	  	img.width=width;
//	  	img.height=newHeight;
//	  } 
//	}
//	if(img.height>height)
//	{
//		rate=image.width/image.height;
//		newWidth=rate*height;
//		img.height=height;
//		img.width=newWidth;
//	}
}

function setCookie (name, value, days) {
  var expires = new Date();
  expires.setTime (expires.getTime() + (86400 * 1000 * days));
  document.cookie = name + "=" + escape(value) +   "; expires=" + expires.toGMTString() +  "; path=/";
}

function getCookie(name) {
  var search;
  search = name + "="
  offset = document.cookie.indexOf(search) 
  if (offset != -1) {
    offset += search.length ;
    end = document.cookie.indexOf(";", offset) ;
    if (end == -1)
      end = document.cookie.length;
    return unescape(document.cookie.substring(offset, end));
  }
  else
    return "";
}

function deleteCookie(name) {
  var expdate = new Date();
  expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
  setCookie(name, "", expdate);
}

var currId = "li_bang_p1";
function viewbangProd(num) {
  if(document.getElementById(currId)!=null){
    if(currId!=null){
      //document.getElementById(currId).style.display="";
      //document.getElementById(currId+"_b").style.display="none";
    }
    currId = "li_bang_p"+num;
    //document.getElementById(currId).style.display="none";
    //document.getElementById(currId+"_b").style.display="";
  }   
}
//prosurfer
function getposOffset(what, offsettype)
{ 
    var totaloffset=(offsettype=="left")? what.offsetLeft : what.offsetTop; 
    var parentEl=what.offsetParent; 
    while (parentEl!=null)
    { 
        totaloffset=(offsettype=="left")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop; 
         parentEl=parentEl.offsetParent; 
    } 
    return totaloffset; 
} 
function showGiftInfo(obj,pid,ev,r)
{
    var score_data = document.getElementById(pid+"_sdata");
    var divGiftBox = document.getElementById("Giftmemo");
    if(score_data!=null && divGiftBox!=null){
        var dt = score_data.innerHTML;
        var dts = dt.split(",");
        var sHtml = divGiftBox.innerHTML;
            sHtml = sHtml.replace("$url$", dts[0]);
            sHtml = sHtml.replace("$pic$", dts[1]);
            sHtml = sHtml.replace("$name$", dts[2]);
            sHtml = sHtml.replace("$price$", dts[3]);
        var x = getposOffset(obj,"left")+2;
        var y = getposOffset(obj,"top")+24;
        popwin.show(ev,sHtml,false,x,y);
    }
}

function hideGiftBox()
{
var divGiftBox = document.getElementById("Giftmemo");
if(divGiftBox!=null){divGiftBox.style.display="none";}
}