﻿/*
copyright wzfc.net 2010
*/
//绝对定位函数
function getAbsoluteTop(element) { 
if (arguments.length != 1 || element == null) { 
return null; 
} 
var offsetTop = element.offsetTop; 
while (element = element.offsetParent) { 
offsetTop += element.offsetTop; 
} 
return offsetTop; 
}

/*
*首页收缩框下拉菜单
* @parame x 微调偏移量
* @parame y 微调偏移量
*/
function ddlSelectInit(){
   var px = 0;
   var py = 0;
   if(arguments.length > 0)
   {
        if(parseInt(arguments[0]) == arguments[0])
            px = arguments[0];
            
        if(parseInt(arguments[1]) == arguments[1])
            py = arguments[1];
   }
    $(".searchItem").each(function(){
        var item = $(this);
        var head = item.find(".searchHead");
        
        item.find(".searchHead").mouseover(function(){
                item.find(".searchText").css("left",head.offset().left + px);
                item.find(".searchText").css("top",head.offset().top + head.height() + py);
			    //$(".searchText").hide();
				item.find('.searchText').show();
				
		});
        
        //item.find(".searchText").bind("mouseleave",function(){
        item.bind("mouseleave", function(event){
            item.find(".searchText").hide();
            return false;
        });
        
        item.find(".searchText a").click(function(event){
            head.text( $(this).text() );
            item.find(".searchHead + input").attr("value",$(this).attr("value"));
            item.find(".searchHead_r").text($(this).text());
            item.find(".searchText").hide();
        });
    });
    
}

/* 设定选项值
* @param objId string 
* @param value string
*/
function setSelectValue(objId,value){
    $("#" + objId).find(".searchHead").text(value);
    $("#" + objId).find(".searchHead_r").text(value);
}

/* 自定义价格
* @param objId      string
* @param tbxIdarr   string[]
*/
function btnPrice(objId, tbxIdarr, unit){
    var text;
    var item = $("#" + objId);
    var pricex = $.trim( $("#" + tbxIdarr[0]).attr("value") );
    var pricey = $.trim( $("#" + tbxIdarr[1]).attr("value") );
    
    if(pricex == "" || parseInt(pricex) != pricex) pricex = 0;  
    if(pricey == "" || parseInt(pricey) != pricey) pricey = 0;
        
    if(pricex == 0) $("#" + tbxIdarr[0]).attr("value","");
    if(pricey == 0) $("#" + tbxIdarr[1]).attr("value","");
    
    
    
    if(pricex != 0) text = pricex + unit + "以上";
    if(pricey != 0) text = pricey + unit + "以下";
    if(pricex != 0 && pricey != 0) text = pricex + "-" + pricey;
        
    
    item.find(".searchHead").text( text );
    item.find(".searchHead + input").attr("value",pricex + "," + pricey);
    
    item.find(".searchText").hide();
    
    return false;
}


//miniLogin
        $(document).ready(function() {
            $.jqm.params.modal = true;
            $('#miniLogin').jqm({
                modal: true
                });
        });
        
        function dialogloginOepn()
         {
            $('#miniLogin').jqmShow(); 
         }
         
         function dialogloginClose()
         {
            $('#miniLogin').jqmHide(); 
         }


