function popupDiv(div_id) {   
    var div_obj = $("#"+div_id);   
    var windowWidth = document.documentElement.clientWidth;       
    var windowHeight = document.documentElement.clientHeight;   
    if(document.body.offsetHeight>=document.documentElement.clientHeight)   
    {
       windowHeight = document.body.offsetHeight+15;   
    } 
    var popupHeight = div_obj.height();       
    var popupWidth = div_obj.width();    
    //添加并显示遮罩层   
    $("<div id='mask'><iframe style='position:absolute;z-index:88;width:100%;height:100%;top:0;left:0;scrolling:no;'   frameborder='0'   src='about:blank'></iframe><div id='mask2' style='position:absolute;z-index:89;width:100%;height:100%;'></div></div>").addClass("mask")   
                              .width(windowWidth * 0.99)   
                              .height(windowHeight * 0.99)   
                              .click(function() {hideDiv(div_id); })   
                              .appendTo("body")   
                              .fadeIn(200);  
    $("#mask2").click(function() {hideDiv(div_id); });  
    var topbj= document.documentElement.clientHeight/2-popupHeight/2+scrolltop();
    if(topbj<0)
    {
    topbj=0;
    }
    div_obj.css({"position": "absolute"})   
           .animate({left: windowWidth/2-popupWidth/2,    
                     top:topbj, opacity: "show" }, "slow");   
}   

function scrolltop(){ var cobj = document.body; while(cobj.scrollTop == 0 && cobj.parentNode) { if(cobj.tagName.toLowerCase() == 'html') break; cobj = cobj.parentNode; } return cobj.scrollTop; } 

function hideDiv(div_id) {   
    $("#mask").remove();   
    $("#" + div_id).animate({left: 0, top: 0, opacity: "hide" }, "slow");   
}  
function previewimg(fileid,toimgid,addimgid){ 
var x = document.getElementById(fileid); 
if(!x || !x.value) return; 
var patn = /\.jpg$|\.jpeg$|\.gif$/i; 
if(patn.test(x.value)){ 
var y = document.getElementById(toimgid); 
if(y){ 
y.src = "file://localhost/" + x.value;
}else{ 
var img=document.createElement(addimgid); img.setAttribute("src","file://localhost/"+x.value); 
img.setAttribute("width","120"); 
img.setAttribute("height","90"); 
img.setAttribute("id",toimgid); 
document.getElementById(addimgid).appendChild(img); 
} 
}else{ 
alert("您选择的图像文件格式不符合要求：jpg、jpeg、gif。"); 
}
} 
function isexcel(fileid){ 
var x = document.getElementById(fileid); 
if(!x || !x.value) return false; 
var patn = /\.xls$/i; 
if(patn.test(x.value)){ 
return true;
}else{ 
alert("您文件格式不是电子表格：！"); 
return false;
}
} 
function isexcelortxt(fileid){ 
var x = document.getElementById(fileid); 
if(!x || !x.value) return false; 
var patn = /\.xls$|\.txt$/i; 
if(patn.test(x.value)){ 
return true;
}else{ 
alert("您文件格式不是电子表格或文本文件：.xls，.txt！"); 
return false;
}
} 
function checkisprice(price)
{ 
    var pat=/^\d{1,9}$|^\d{1,9}\.\d{1,2}$/;
    if(!pat.test(price))
    {
        return false;
    }
    else
        return true;
}
function isnumber(fileid){ 
var x = document.getElementById(fileid); 
if(!x || !x.value) return false; 
var patn = /^[-]?[\d]{1,9}$/i; 
if(patn.test(x.value)){ 
return true;
}else{ 
return false;
}
} 
function clearshopcardall(cookieaddstr)
{
   document.cookie=cookieaddstr+"='';path=/";
   freshshopcard();
}
function freshshopcard()
{
   window.location.href=window.location.href;
}