<?php
defined('_JEXEC') or die;

/**
* @version 6.6
* @package OS CCK select currency
* @copyright 2019 OrdaSoft
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @description Select currency for OS CCK Component
*/


    echo '<div class="module_select_currency">';
    echo $currencySelect;
    echo '</div>';

    
    /** ensure this file is being included by a parent file */

    ?>


<script type="text/javascript">
    function change_currency(){
        var currency = jQuerOs('#instance_currency').val();
        
        var href = window.location.href;
        if (href.indexOf('?index.php') > -1) {
            if (href.indexOf('&currency') > -1) {
                var new_href = href.substring(0, href.indexOf('&currency') )+ "&currency=" + currency;
                document.location.href = new_href;
            }else {
                var new_href =  href + "&currency=" + currency;
                document.location.href = new_href;
            }
        }else{
            if (href.indexOf('&currency') > -1) {
                var new_href = href.substring(0, href.indexOf('&currency') )+ "&currency=" + currency;
                document.location.href = new_href;
            }else if(href.indexOf('?currency') > -1){
                var new_href = href.substring(0, href.indexOf('?currency') )+ "?currency=" + currency;
                document.location.href = new_href;
            }else if(href.indexOf('?') == -1){
                var new_href =  href + "?currency=" + currency;
                document.location.href = new_href;
            }else if(href.indexOf('?') > -1){
                var new_href =  href + "&currency=" + currency;
                document.location.href = new_href;
            }

        }
    }

</script>