function open_sort( arg )
{
  location.href = '/front/php/category.php?cate_no=' + arg + '&sort_method='+frm.sort_method.selectedIndex ;
}

function getPosition(e)
{
    var mouseX = e.pageX ? e.pageX : document.documentElement.scrollLeft + event.clientX;
    var mouseY = e.pageX ? e.pageX : document.documentElement.scrollLeft + event.clientY;

    return {x: mouseX, y: mouseY}; 
}

var PSS_FCTL = {
    init : function ()
    {
        this.bIsInit = true ;
        this.aItemList = new Array();
        this.hSelItemList = document.getElementById('hsel_pss_item');
        this.iCurGroupSeq = 0 ;
    },
    itemListReq : function ( hselGroupList )
    {
        if ( !this.bIsInit ) this.init() ;
        var hOptsGroupList = hselGroupList.options ;
        var iGroupSeq = 0;
        try {
            iGroupSeq = hOptsGroupList[hOptsGroupList.selectedIndex].value.split(':')[0] ;
        } catch ( e ) {}
        if ( !iGroupSeq ) return;
        if ( this.aItemList[iGroupSeq] && this.aItemList[iGroupSeq]['bIsLoad'] ) {
            this.itemListUpdate( this.aItemList[iGroupSeq]['aDataList'] );
        } else {
            var str_param = '&mode=req_item_list' ;
            str_param += '&group_seq=' + iGroupSeq ;
            sendRequest( PSS_FCTL.itemListRes, str_param, 'POST', '/front/php/aj_pss_res.php', true, true ) ;
        }
    },
    itemListRes : function ( oAjRes )
    {
        if ( !PSS_FCTL.bIsInit ) PSS_FCTL.init() ;
        if ( !oAjRes || !oAjRes.responseText ) {
            return false ;
        }
        var aItemListJson = '' ;
        try {
           eval( "var aItemListJson =" + oAjRes.responseText ) ;
        } catch ( e ) { }
        PSS_FCTL.itemListUpdate( aItemListJson );
    },
    itemListUpdate : function ( aItemListJson )
    {
        if ( !this.bIsInit ) this.init() ;
        this.itemClear() ;
        try {
            this.iCurGroupSeq = aItemListJson[0]['pssi_group_seq'];
            this.aItemList[this.iCurGroupSeq] = new Array() ;
            this.aItemList[this.iCurGroupSeq]['aDataList'] = aItemListJson ;
            this.aItemList[this.iCurGroupSeq]['bIsLoad'] = true ;
            for ( var iCnt = 0, iLen = aItemListJson.length ; iCnt < iLen ; iCnt++ )
            {
                PSS_FCTL.itemAdd( aItemListJson[iCnt]['pssi_target_value'], aItemListJson[iCnt]['pssi_target_value'] ) ;
            }
        } catch ( e ) {
            return false ;
        }
    },
    itemAdd : function ( sText, sValue )
    {
        if ( !this.bIsInit ) this.init() ;
        var hOptItem = document.createElement( 'option' );
        hOptItem.value = sValue;
        hOptItem.text = sText;
        this.hSelItemList.add( hOptItem );
    },
    itemClear : function ()
    {
        if ( !this.bIsInit ) this.init() ;
        var hOptList = this.hSelItemList.options ;
        for ( var iCnt = 1, iLen = hOptList.length ; iCnt < iLen ; iCnt++ )
        {
            this.hSelItemList.remove( 1 );
        }
    },
    getSelectValue : function ( hObj )
    {
        var sValue = '';
        try {
            sValue = hObj.options[hObj.options.selectedIndex].value ;
        } catch ( e ) {}
        return sValue ;
    },
    search : function (hsel_pss_group, hsel_pss_item, hiPssParm)
    {
        var sUrl = '/front/php/category.php?' ;
        var g, i, u ;
        try {
            i = this.getSelectValue( document.getElementById( hsel_pss_item ) ) ;
            u =document.getElementById( hiPssParm ).value ;
            g =this.getSelectValue( document.getElementById( hsel_pss_group ) ) ;
            g = g.split(':')[1];
        } catch ( e ) {}
        if ( !g ) {
            alert( 'Á¶°ÇÀ» ¼±ÅÃÇØÁÖ¼¼¿ä' ) ;
            return ;
        } else if ( !i ) {
            alert( '¼¼ºÎÇ×¸ñÀ» ¼±ÅÃÇØÁÖ¼¼¿ä' ) ;
            return ;
        }
        if (!g || !u || !i ) return ;
        sUrl += u ;
        sUrl += '&pss_group=' + g ;
        sUrl += '&pss_item=' + i ;
        //sUrl += '#normal_list' ;
        document.location.href = sUrl ;
    }
}
var PRDT_COMP_CTL = {
    compare_check : function ( checkbox_name, max_comp_number )
    {
        if ( !max_comp_number || parseInt( max_comp_number ) > 20 ) max_comp_number = 20 ;
        var hobj_list = document.getElementsByName( checkbox_name ) ;
        var compare_cnt = 0 ;
        var req_data = '';
        for ( var cnt = 0, len = hobj_list.length ; cnt < len ; cnt++ )
        {
            if ( hobj_list[cnt].checked ) compare_cnt++ ;
        }
        if ( compare_cnt <= 1 )
        {
            alert( 'ÃÖ¼Ò 2°³ ÀÌ»ó ¼±ÅÃÇÏ¼¼¿ä.' ) ;
            return ;
        }
        if ( compare_cnt > max_comp_number )
        {
            alert( max_comp_number + '°³ ±îÁö ºñ±³ °¡´ÉÇÕ´Ï´Ù.' ) ;
            return ;
        }
        for ( var cnt = 0, len = hobj_list.length ; cnt < len ; cnt++ )
        {
            if ( hobj_list[cnt].checked )
            {
                this.add_checkbox( hobj_list[cnt].value ) ;
            }
        }
        this.f.submit() ;
    },
    init_form : function ()
    {
        if ( this.f )
        {
            this.f.innerHTML = '' ;
            return this.f ;
        }
        this.f = document.createElement( 'FORM' ) ;
        this.f.style.display = 'none' ;
        this.f.method = 'get' ;
        this.f.action = 'prdt_comp_list.php' ;
        document.body.appendChild( this.f ) ;
    },
    add_checkbox : function ( value )
    {
        if ( !this.f ) this.init_form() ;
        var hobj = this.create_input_from( 'prdt_comp_list[]', value, 'checkbox' ) ;
        this.f.appendChild( hobj ) ;
        hobj.checked = true ;
    },
	create_input_from : function ( name, value, type )
	{
		var hobj_input = null ;
		if ( !type ) type = 'hidden' ;
		try {
			hobj_input = document.createElement( '<input type="'+type+'" name="'+name+'" value="'+value+'" />' ) ;
		}
		catch ( e )
		{
			hobj_input = document.createElement( 'input' ) ;
			hobj_input.type = type ;
			hobj_input.name = name ;
			hobj_input.value = value ? value : '' ;
		}
		return hobj_input ;
	}
}