﻿// JScript 文件
var Browser={};
Browser.isMozilla = (typeof document.implementation != 'undefined') && (typeof document.implementation.createDocument != 'undefined') && (typeof HTMLDocument!='undefined');
Browser.isIE = window.ActiveXObject ? true : false;
Browser.isFirefox = (navigator.userAgent.toLowerCase().indexOf("firefox")!=-1);
Browser.isSafari = (navigator.userAgent.toLowerCase().indexOf("safari")!=-1);
Browser.isOpera = (navigator.userAgent.toLowerCase().indexOf("opera")!=-1);

function addfavorite(url,title){
    if(Browser.isIE){//IE
        window.external.AddFavorite(url,title);
    }else if(Browser.isFirefox){//FireFox
        window.sidebar.addPanel(title, url, "");
    }else{//other
        alert("Please use the Ctrl+D to add into the favorite");
    }
}
var Search = {
    SellSearch:function(obj){
        if(""!=document.getElementById(obj).value){
            return true;
        }else{
            alert("Please enter the keywords for searching");
            document.getElementById(obj).focus();
            return false;
        }
    }
}
function viewTool(obj){
    if($("#"+obj).css("display")=="block"){
        $("#"+obj).css("display","none");
    }else{
        $("#"+obj).css("display","block");
    }
}

function ChoosePic(id,strUrl){
    //alert($("#propic"+id).css("display"))
    if($("#propic"+id).css("display")!="none"){
        $("#propic"+id).css("display","none");
    }else{
        $("#propic"+id).css("position","absolute");
        $("#propic"+id).prev("a").prev("input").each(function(){
            $("#propic"+id).css("top",getOffsetTop(this)+this.offsetHeight);
            $("#propic"+id).css("left",getOffsetLeft(this));
        });
        $("#propic"+id).css("display","block");
        $("#propic"+id+" iframe").each(function(){
            if(""==this.src)
                this.src="ShowMyPicture.aspx?"+strUrl;
            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.$("#"+obj).val());
    parent.$("#"+obj).val(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;
    }
}

if(Browser.isIE){
    document.oncontextmenu=new Function("event.returnValue=false;");
    document.onselectstart=new Function("event.returnValue=false;");
}