// #号和&符号转义
function StrCode(str)
{
    if(encodeURIComponent)
    {
        return encodeURIComponent(str);
    }
    if(escape)
    {
        return escape(str);
    }
    return str;
}

var site_conf ={
        'chemchinanet':{
            'post': "/leads-*/",
            'product': "/wholesale-*/",
            'company': "/supplier-*/"
        },
        'autochinanet':{
            'post': "/leads-*/",
            'product': "/wholesale-*/",
            'company': "/supplier-*/"
        },
        'foodchinanet':{
          'product': "/*-sale/",
          'company': "/supplier/*.html"
        },
        'hardware-wholesale':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/suppliers/*.html"
        },
        'qualitytoyschina':{
            'post': "/ps-*/",
            'product': "/buy-*/"
        },
        'qualitymp3player':{
            'post': "/ps-*/",
            'product': "/buy-*/"
        },
        'qualitydress':{
            'post': "http://buyer.qualitydress.com/*-buyer.html",
            'product': "/buy-*/",
            'company': "http://wholesaler.qualitydress.com/*-wholesale.html"
        },
        'xpshou':{
            'post': "/qb-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'callurl':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'call2url':{
          'product': "/*-sale/",
          'company': "/supplier/*.html"
        },
        'chinaqualitycrafts':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'chinacomputerparts':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'chinaqualitydigital':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'chinaqualitylighting':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'chinaqualityshoes':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/wholesaler-*/"
        },
        'himfr':{
            'post': "/ps-*/",
            'product': "/buy-*/",
            'company': "/cs-*/"
        },        
        'buildingmaterials-china':{
            'post': "/",
            'product': "/*-products.html",
            'company': "/*-manufacturers.html"
        },
        'chinahomeappliances':{
            'post': "/",
            'product': "/*-products.html",
            'company': "/*-manufacturers.html"
        },
        'furnitureschina':{
            'post': "/",
            'product': "/*-products.html",
            'company': "/*-manufacturers.html"
        },
        'cheaponsale':{
            'Buying Leads': "http://suppliers.superexporter.com/ms-*/",
            'Products': "http://www.superexporter.com/buy-*/",
            'Manufacturers': "http://leads.superexporter.com/ps-*/",
            'inquiry': "http://leads.superexporter.com/ps-*/",
            'product': "http://www.superexporter.com/buy-*/"
        }
}

function del_kw(kw){
    kw=kw.replace(new RegExp('[^a-zA-Z0-9\-]+','g'),'_').toLowerCase()
    kw=kw.replace(new RegExp("-+", "gi"), "_");
    kw=kw.replace(/(^[_\\^]*)/g, "").replace(/([_\\^]*$)/g, "");
    return kw
}

function search_form(form,website){
    if (form.kw.value == "") {
        form.kw.focus();
        return false;
    }
    var kw = del_kw(form.kw.value)    
    var static_url;
    var src = form.src.value;
    if (site_conf[website]) {
        static_url = site_conf[website][src].replace('*',kw);
        location = static_url;
    }
    return false;
}
//图片缩放
function setImgSize(theURL,sImage,stand,ctand) {
    var imgObj;
    var sizeStand=stand;
    var CStand=ctand;
    if(arguments.length>=3) {
        sizeStand=arguments[2];
    }
    imgObj=new Image();
    imgObj.src=theURL;
    if(ctand==0) {
        if((imgObj.width!=0)&&(imgObj.height!=0)) {
            if(imgObj.width>sizeStand||imgObj.height>sizeStand) {
                if(imgObj.width>imgObj.height) {
                    var iHeight=imgObj.height*sizeStand/imgObj.width;
                    sImage.height=iHeight;
                    sImage.width=sizeStand;
                }
                else {
                    var iWidth=imgObj.width*sizeStand/imgObj.height;
                    sImage.width=iWidth;
                    sImage.height=sizeStand;
                }
            }
            else {
                sImage.width=imgObj.width;
                sImage.height=imgObj.height;
            }
        }
        else {
            sImage.width=sizeStand;
            sImage.height=sizeStand;
        }
    }
    else {
        if((imgObj.width!=0)&&(imgObj.height!=0)) {
            if(imgObj.width>sizeStand||imgObj.height>CStand) {
                var wi=imgObj.width/sizeStand;
                var hi=imgObj.height/CStand;
                if(wi>hi) {
                    var iHeight=imgObj.height*sizeStand/imgObj.width;
                    sImage.height=iHeight;
                    sImage.width=sizeStand;
                }
                else {
                    var iWidth=imgObj.width*CStand/imgObj.height;
                    sImage.width=iWidth;
                    sImage.height=CStand;
                }
            }
            else {
                sImage.width=imgObj.width;
                sImage.height=imgObj.height;
            }
        }
        else {
            sImage.width=sizeStand;
            sImage.height=CStand;
        }
    }
}


