﻿//--------------------------------------------------------------------
//加入收藏
//--------------------------------------------------------------------
function AddFavorite(sURL, sTitle)
{
    try
    {
        window.external.addFavorite(sURL, sTitle);
    }
    catch (e)
    {
        try
        {
            window.sidebar.addPanel(sTitle, sURL, "");
        }
        catch (e)
        {
            alert("加入收藏失败，请使用Ctrl+D进行添加");
        }
    }
}
//--------------------------------------------------------------------


//--------------------------------------------------------------------
//设为首页
//--------------------------------------------------------------------
function SetHome(obj,sURL)
{
    try
    {
            obj.style.behavior='url(#default#homepage)';obj.setHomePage(sURL);
    }
    catch(e){
            if(window.netscape) {
                    try {
                            netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect"); 
                    } 
                    catch (e) { 
                            alert("此操作被浏览器拒绝！\n请在浏览器地址栏输入“about:config”并回车\n然后将[signed.applets.codebase_principal_support]设置为'true'"); 
                    }
                    var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
                    prefs.setCharPref('browser.startup.homepage',sURL);
             }
    }
}
//--------------------------------------------------------------------


//-----------------------------------------------
//防止被人frame
//-------------------- begin --------------------
//if (top.location != self.location)top.location=self.location;
//--------------------- end ---------------------


//--------------------------------------------------------------------
//获取参数对象
//--------------------------------------------------------------------
function $(op_id)
{
    var op = getBid(op_id);
    return op;
}
//--------------------------------------------------------------------


//-----------------------------------------------
//去两边空格
//-------------------- begin --------------------
String.prototype.trim = function()
{
    return this.replace(/(^[\s]*)|([\s]*$)/g, "");
}
//--------------------- end ---------------------


//-----------------------------------------------
//设置文本框背景色
//-------------------- begin --------------------
function SetBackColor(_this, _focus)
{
    if (_focus == 1)
    {
        _this.style.backgroundColor = "#CCFF99";
    }
    else
    {
        _this.style.backgroundColor = "#FFFFFF";
    }
}
//--------------------- end ---------------------


//-----------------------------------------------
//对象的显示与隐藏
//Obj:对象Id值
//ShowOrHide:显示还是隐藏
//-------------------- begin --------------------
function ObjShowOrHidden(Obj,ShowOrHide)
{
    if($(Obj))
    {
        $(Obj).style.display = ShowOrHide;
    }
}
//--------------------- end ---------------------


//-----------------------------------------------
//设置错误提示及样式
//-------------------- begin --------------------
function SetMsgStyle(op_msg, str_msg)
{
    if (str_msg != "")
    {
        $(op_msg).innerHTML = str_msg;
        $(op_msg).className = "msg_error";
    }
    else
    {
        $(op_msg).innerHTML = "<img src='images/sign_right.gif' />";
    }
}
//--------------------- end ---------------------


//-----------------------------------------------
//创建XMLHttpRequest对象
//-------------------- begin --------------------
function createXMLHttpRequest()
{
	var myhttp=null;
	try
	{
		myhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(ie)
	{
	    try
	    {
			myhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(huohu)
		{
			myhttp = new XMLHttpRequest();
		}
	}
	return myhttp;
}
//--------------------- end ---------------------



//-----------------------------------------------
//设置内嵌操作菜单页面高度
//-------------------- begin --------------------
function reinitIframe(iframe_name)
{
	try
	{
        var iframe = window.parent.getBid("OpMenu");
        if (!iframe)
        {
            iframe = window.parent.getBid(iframe_name);
        }
		var bHeight = window.document.body.scrollHeight;
		var dHeight = window.document.documentElement.scrollHeight;
		var height = Math.max(bHeight, dHeight);
	    
		iframe.height = height;
		
		//alert(height);
	}
	catch(ex)
	{
	} 
}
//--------------------- end ---------------------
   
//6.4更新产品信息    
function loadInfo(id,type)
{
    var info;              //页面代码
    var userProperty;      //会员类型
     //判断会员类型
     
    userProperty = getBid("HUserProperty").value;
    if(userProperty == -1)
    {
        userProperty=type;
    }
    if(userProperty=="p")
    {
        info = user_userquote.LoadProvideInfo(id).value;
    }
    else if(userProperty=="n")
    {
        info = user_userquote.LoadDemandInfo(id).value;
    }
    else if(userProperty=="xlbyQ")
    {
        info = user_userquote.LoadXLBYInfo(id).value;
    }
    else if(userProperty=="clpjQ")
    {
        info = user_userquote.LoadCLPJInfo(id).value;
    }
    else if(userProperty=="clxsQ")
    {
        info = user_userquote.LoadCLXSInfo(id).value;
    }
    else if(userProperty=="clbxQ")
    {
        info = user_userquote.LoadCLBXInfo(id).value;
    }
    
    getBid("infoMore").innerHTML = "";
    getBid("infoMore").innerHTML = info;

}
//6.4更新用车信息    
function loadDemandInfo(id)
{
    var info;              //页面代码
    var userProperty;      //会员类型
    
    getBid("need").src = "../DemandPalaver.aspx?DemandId="+id;
}

function getBid(s)
{
    return document.getElementById(s);
}
function getBmc(s)
{
    return document.getElementsByName(s);
}
    
////首页的搜索范围框显示输入的值  
//var fw = parent.getBid("txtFW");
////首页的范围阴影层显示
//var indexFW = parent.getBid("SearchFW");    

////显示搜索范围阴影框弹出层确定按钮
//function searchFW()
//{   
//    fw.value =  getBid("txtFW").value;        

//    //计算显示位置，以点击的位置为中心，“+10”和“+13”是消除图片标示点误差  
//    var f = getBid("txtFW").value;
//    if(f >= 10)
//    {
//        f = 10;
//    }

//    //计算显示大小
//    indexFW.style.width = (f*1000/10)+"px";
//    indexFW.style.height = (f*1000/10)+"px";   
//    //显示位置
//    indexFW.style.left = (parent.getBid('hywz').style.left.replace("px","")-(f*1000/10/2)+10)+"px";
//    indexFW.style.top = (parent.getBid('hywz').style.top.replace("px","")-(f*1000/10/2)+13)+"px";


//    //显示
//    indexFW.style.display = "block";
//    parent.getBid('hywz').style.display = "block";//标示点

//    //关闭弹出层        
//    parent.getBid('dialogBox').style.display='none';      
//    parent.getBid('dialogBoxBG').style.display='none';
//    parent.getBid('dialogBoxShadow').style.display='none';
//    parent.getBid('dialogBody').innerHTML='';
//}

////显示搜索范围阴影框弹出层取消按钮
//function clearFW()
//{
//    fw.value = "";
//    getBid('txtFW').value="";
//    indexFW.style.display = "none";
//    parent.getBid('hywz').style.display = "none";//标示点隐藏
//    parent.getBid('SearchFW').style.display = "none";//范围阴影框隐藏

//    //关闭弹出层        
//    parent.getBid('dialogBox').style.display='none';      
//    parent.getBid('dialogBoxBG').style.display='none';
//    parent.getBid('dialogBoxShadow').style.display='none';
//    parent.getBid('dialogBody').innerHTML='';
//   
//}


//显示搜索范围阴影框弹出层确定按钮
function searchFW()
{  

    //首页的搜索范围框显示输入的值  
    var fw = parent.getBid("txtFW");
    
    //首页的范围阴影层显示
    var indexFW = parent.getBid("SearchFW");    


    fw.value =  getBid("txtFW").value;        

    //计算显示位置，以点击的位置为中心，“+10”和“+13”是消除图片标示点误差  
    var f = getBid("txtFW").value;
    if(f >= 10)
    {
        f = 10;
    }

    //计算显示大小
    indexFW.style.width = (f*1000/10)+"px";
    indexFW.style.height = (f*1000/10)+"px";   
    //显示位置
    indexFW.style.left = (parent.getBid('hywz').style.left.replace("px","")-(f*1000/10/2)+10)+"px";
    indexFW.style.top = (parent.getBid('hywz').style.top.replace("px","")-(f*1000/10/2)+13)+"px";


    //显示
    indexFW.style.display = "block";
    parent.getBid('hywz').style.display = "block";//标示点

    //关闭弹出层        
    parent.getBid('dialogBox').style.display='none';      
    parent.getBid('dialogBoxBG').style.display='none';
    parent.getBid('dialogBoxShadow').style.display='none';
    parent.getBid('dialogBody').innerHTML='';
//    
//    //确定范围后在首页地图上显示出此范围里的信息
//    var v = indexSeachFW.AjaxShowUser(l,t,w,h,getBid("HProvince").value,getBid("HCity").value).value;          
//    parent.getBid("divAjaxInfo").innerHTML = "";
//    parent.getBid("divAjaxInfo").innerHTML = v;
//    parent.getBid("divAjaxInfo").style.display = "block";//信息层
}

//显示搜索范围阴影框弹出层取消按钮
function clearFW()
{
     //首页的搜索范围框显示输入的值  
    var fw = parent.getBid("txtFW");
    
    //首页的范围阴影层显示
    var indexFW = parent.getBid("SearchFW");    

    fw.value = "";
    getBid('txtFW').value="";
    indexFW.style.display = "none";
    parent.getBid('hywz').style.display = "none";//标示点隐藏
    parent.getBid('SearchFW').style.display = "none";//范围阴影框隐藏

    //关闭弹出层        
    parent.getBid('dialogBox').style.display='none';      
    parent.getBid('dialogBoxBG').style.display='none';
    parent.getBid('dialogBoxShadow').style.display='none';
    parent.getBid('dialogBody').innerHTML='';
   
}


