<?php
define('_NL',"\n");
class jxHtml {
	function quickiconButton( $link, $image, $text ) {
    ?>
    		<div style="float:left;">
    			<div class="icon">
        		<a href="<?php echo $link; ?>">
        			<img src="components/com_jcommerce/images/cpanel/<? echo $image?>" border="0">
        			<span><?php echo $text; ?></span>
        		</a>
    			</div>
    		</div>
    <?php
    }
    function jcLoadEffects()
    {
        Global $mainframe;
        $document =& JFactory::getDocument();
        $document->addScript(JURI::root().'/administrator/components/com_jcommerce/js/scriptaculous/prototype.js');
        $document->addScript(JURI::root().'/administrator/components/com_jcommerce/js/scriptaculous/scriptaculous.js');
        $document->addScript(JURI::root().'/administrator/components/com_jcommerce/js/scriptaculous/effects.js');
    }
    function jcProdImage($id, $image)
    {
        global $mainframe;
        // TODO: This Icon should show(load) thumbnail on mose over
        $img = '<img align="absmiddle" id="img_'.$id.'" style="cursor:pointer" onclick="return overlib(\'<img src='.JURI::root().'/images/cancel_f2.png>\', WIDTH, 100);" onmouseout="return nd();" src="components/com_jcommerce/images/media.png">';
        return $img;
    }
    
    function jxRating($num)
    {
        $num = round($num);
        global $mainframe;
        $sit=JURI::root();
        $sit .= '/administrator/';
        //return "sdfsdfsdfsdfsdf";
        if($num >= 100)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 90)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star05.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 80)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 70)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star05.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 60)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 50)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star05.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 40)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 30)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star05.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 20)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star10.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        elseif($num >= 10)
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star05.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />
            '; //<?
        }
        else
        {
            $rate = '
            <img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" /><img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" /><img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" /><img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" /><img src="'.$sit.'components/com_jxplorer/images/star00.png" align="absmiddle" />'; //<?
        }
        return $rate;
    }
}

class jxHelper
{
    
    /**
     * This function generates Ajax Access lable
     *
     * @param Object $row 
     * @param string $prefix the task prefix
     * @param string $table Tabl? name
     * @return void
     */
    function AccessProcessingX( &$row, $table) 
    {
        if ( !$row->access ) {
            $color_access = 'style="color: green;"';
        } else if ( $row->access == 1 ) {
            $color_access = 'style="color: red;"';
        } else {
            $color_access = 'style="color: black;"';
        }
        
        $href = "
        <div id=\"adiv_$row->id\">
          <a href=\"javascript:void(0);\"  id=\"access_$row->id\" 
          $color_access onclick=\"document.getElementById('adiv_$row->id').innerHTML = '<img src=components/com_jxplorer/images/load.gif>';xajax_jcAccess('$row->id', '$table', 
          '$row->access')\">".jcText::_( $row->groupname )."</a><div>";
    
        return $href;
    }
    
    /**
     * Enter description here...
     *
     * @param Object $row curent row
     * @param string $table table name
     * @return xml
     */
    function PublishedProcessingX( &$row, $table) {
      
        $img    = $row->published ? $imgY='tick.png' : $imgX='publish_x.png';
        $task   = $row->published ? $prefix.'unpublish' : $prefix.'publish';
        $alt    = $row->published ? jcText::_( 'Published' ) : jcText::_( 'Unpublished' );
        $action = $row->published ? jcText::_( 'Unpublish Item' ) : jcText::_( 'Publish item' );
        
        $href = '<a href="javascript:void(0);" onclick="return listItemTask(\'cb'. $i .'\',\''. $task .'\')" title="'. $action .'"><img src="images/'. $img .'" border="0" alt="'. $alt .'" /></a>';
        $href = "<div id=\"pdiv_$row->id\"><a href=\"javascript:void(0);\"  id=\"publish_$row->id\" onclick=\"document.getElementById('pdiv_$row->id').innerHTML = '<img src=components/com_jxplorer/images/load.gif>';xajax_jcPublish('$row->id', '$table', '$row->published', document.getElementById('sd').checked)\"><img src=\"images/$img\" border=\"0\" alt=\"$alt\"/></a><div>";

        return $href;
    }
    function ElementName($var, $row, $i, $file, $add = 0)
    {
        $name = sprintf(
            '<a href="javascript:void(0);" onclick="editItem(\'cb%d\', \'%s\', \'%s\' )"><span id="row_%s_%d">%s</span></a>',
            $i, $file, ($add ? $add : 0), $var, $row->id, $row->{$var} 
        );
        return $name;
    }
}


?>