// JScript 文件
jQuery.noConflict();
function ChoosePic(id,strUrl){
    //alert(jQuery("propic"+id))
    if(jQuery("#propic"+id).css("display")!="none"){
        jQuery("#propic"+id).css("display","none");
    }else{
        jQuery("#propic"+id).css("position","absolute");
        jQuery("#propic"+id).prev("a").prev("input").each(function(){
            jQuery("#propic"+id).css("top",getOffsetTop(this)+this.offsetHeight);
            jQuery("#propic"+id).css("left",getOffsetLeft(this));
        });
        jQuery("#propic"+id).css("display","block");
        jQuery("#propic"+id+" iframe").each(function(){
            if(""==this.src)
                this.src="ShowMyPicture.aspx?"+strUrl+"&DivID=propic"+id;
            this.width="100%";
            this.height="320px";
        });
    }
}
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

function SelectTo(obj,fileUrl){
    //alert(parent.jQuery("#"+obj).val());
    //parent.jQuery("#"+obj).val(fileUrl);
    parent.document.getElementById(obj).value=fileUrl;
}

function ReSetPicture(w,h,obj){
    if(obj.width>obj.height){
        if(obj.width>w)
            obj.width=w;
    }else{
        if(obj.height>h)
            obj.height=h;
    }
}
function ChangeSearch(divid){
    jQuery("#ctl00_sdll").val(divid);
    if(5==divid){divid=2;}
    jQuery("#SearchSpan1").css("display","none");
    jQuery("#SearchSpan2").css("display","none");
    jQuery("#SearchSpan3").css("display","none");
    jQuery("#SearchSpan4").css("display","none");
    jQuery("#SearchSpan"+divid).css("display","");
    if(4==divid||1==divid){
        jQuery("#SearchAdd").css("display","");
    }else{
        jQuery("#SearchAdd").css("display","none");
    }
}
function ChkSearch(){
    var id=jQuery("#ctl00_sdll").val();
    var n=jQuery("#ctl00_sdll").val();
    if(1==id){
        if(""==jQuery.trim(theProKey)){
            alert("产品库供求商机必须填写。");
            return false;
        }
    }else if(2==id){
        if(""==jQuery.trim(theProKey)){
            alert("产品库供求商机必须填写。");
            return false;
        }
    }else if(3==id){
        if(""==jQuery.trim(theTelKey)){
            alert("电话号码必须填写。");
            return false;
        }
    }else if(4==id){
        if(""==jQuery.trim(thesa)){
            alert("地址关键字必须填写。");
            return false;
        }
    }else if(5==id){
        if(""==jQuery.trim(theCataKey)){
            alert("分类关键字必须填写。");
            return false;
        }
    }else if(6==id){
        if(""==jQuery.trim(theComNames)){
            alert("公司名称，产品，关键词必须填写。");
            return false;
        }
    }
}

function PostGetCitys(p,c){
    var now=new Date();
    var theP=jQuery("#"+p).val();
    jQuery.get("/GetCity.aspx",{pid:theP,pT:now.getTime()},function(xhtml){
        var theSelect=jQuery("#"+c)[0];
        var j=theSelect.length;
        for(var i=0;i<=j;i++){
            theSelect.remove(1);
        }
        var theGL=xhtml.split("|||");
        var ii=1;
        for(var i=1;i<theGL.length;i=i+2){
            theSelect.options[ii]=new Option(theGL[i-1], theGL[i]);
            ii++;
        }
    });
}
function SetCitys(p,c){
    var now=new Date();
    var theP=jQuery("#"+p).val();
    var theC=jQuery("#"+c).val();
    jQuery.post("/GetCity.aspx",{pid:theP,cid:theC});
}

function PostGetCity(c){
    var now=new Date();
    var theP=jQuery("#SS_Province select").val();
    jQuery.get("/GetCity.aspx",{pid:theP,no:0,pT:now.getTime()},function(xhtml){
        var theSelect=jQuery("#SS_City select")[0];
        var j=theSelect.length;
        for(var i=0;i<=j;i++){
            theSelect.remove(1);
        }
        var theGL=xhtml.split("|||");
        var ii=1;
        for(var i=1;i<theGL.length;i=i+2){
            theSelect.options[ii]=new Option(theGL[i-1], theGL[i]);
            ii++;
        }
    });
}
function inputkeydown(e,obj){
	if(e.keyCode==13){
	    e.keyCode=9;
	    jQuery("#"+obj).click();
	    return false;
	}
	return true;
}

function SetPageHome(t,u){
	if(jQuery.browser.msie){
		document.body.style.behavior='url(#default#homepage)';
		document.body.setHomePage(u);
	}else if(jQuery.browser.mozilla){
		window.sidebar.addPanel(t,u,'');
	}
}
function AddCollection(t,u){
	if(jQuery.browser.msie){
	window.external.AddFavorite(u,t);
	}else if(jQuery.browser.mozilla){
	window.sidebar.addPanel(t,u,'')
	}
}
function ClickYpKw(b,s,str){
    if(""==b.value&&1==s){
        b.value=str;
        b.style.color="#999";
    }else if(str==b.value&&2==s){
        b.value="";
        b.style.color="#000";
    }
}
function ChooseImageSize(objID,w,h){
	var Obj=jQuery("#"+objID);
	var ImgObj=(Obj.is("img"))?Obj:Obj.find("img");
	if(!ImgObj.is("img")){return;}
	ImgObj.each(function(){
	    //alert(this.offsetWidth);
		if(this.width>this.height){
		//宽大于高，改变宽
			if(this.width>w){
				this.width=w;
				jQuery(this).css("height","auto");
			}
		}else{
			if(this.height>h){
				this.height=h;
				jQuery(this).css("width","auto");
			}
		}
	});
}
//document.oncontextmenu=new Function("event.returnValue=false;");
//document.onselectstart=new Function("event.returnValue=false;");
