/**
 * Created by timur on 20.06.17.
 */
jQuery(function() {

    jQuery('.Oziris_dialog')
        .dialog({
            autoOpen: false,
            width: 840,
            height: 600,
            modal: true,
            dialogClass: 'ui-custom-dialog'
        });
});
function Oziris_open() {
    var params = "";
    var IsPromo = (jQuery('.Oziris_dialog')
                       .attr('ProductCode') == 'ECREDIT') ? true : false;
    if (jQuery('.Oziris_dialog')
            .attr('ProductCode') != null) {
        params += (params != "" ? "&" : "") + "ProductCode=" + jQuery('.Oziris_dialog')
                .attr('ProductCode');
    }
    if (jQuery('.Oziris_dialog')
            .attr('Amount') != null) {
        params += (params != "" ? "&" : "") + "Amount=" + jQuery('.Oziris_dialog')
                .attr('Amount');
    }
    if (jQuery('.Oziris_dialog')
            .attr('SourceId') != null) {
        params += (params != "" ? "&" : "") + "SourceId=" + jQuery('.Oziris_dialog')
                .attr('SourceId');
    }
    if (jQuery('.Oziris_dialog')
            .attr('SourceCode') != null) {
        params += (params != "" ? "&" : "") + "SourceCode=" + jQuery('.Oziris_dialog')
                .attr('SourceCode');
    }
    if (jQuery('.Oziris_dialog')
            .attr('SourceEmail') != null) {
        params += (params != "" ? "&" : "") + "SourceEmail=" + jQuery('.Oziris_dialog')
                .attr('SourceEmail');
    }
    if (jQuery('.Oziris_dialog')
            .attr('SourceEmailCC') != null) {
        params += (params != "" ? "&" : "") + "SourceEmailCC=" + jQuery('.Oziris_dialog')
                .attr('SourceEmailCC');
    }
    if (jQuery('.Oziris_dialog')
            .attr('SourceEmailBCC') != null) {
        params += (params != "" ? "&" : "") + "SourceEmailBCC=" + jQuery('.Oziris_dialog')
                .attr('SourceEmailBCC');
    }

    if (jQuery('.Oziris_dialog')
            .attr('ExtOrderId') != null) {
        params += (params != "" ? "&" : "") + "ExtOrderId=" + jQuery('.Oziris_dialog')
                .attr('ExtOrderId');
    }

    if (jQuery('.Oziris_dialog')
            .attr('Line0Code') != null) {
        params += (params != "" ? "&" : "") + "Line0Code=" + encodeURIComponent(jQuery('.Oziris_dialog')
                .attr('Line0Code'));
    }
    if (jQuery('.Oziris_dialog')
            .attr('Line0Title') != null) {
        params += (params != "" ? "&" : "") + "Line0Title=" + encodeURIComponent(jQuery('.Oziris_dialog')
                .attr('Line0Title'));
    }
    var line0Price = jQuery('.Oziris_dialog')
        .attr('Line0Price');
    if (line0Price != null && line0Price != undefined) {
        params += (params != "" ? "&" : "") + "Line0Price=" + line0Price.toString()
                                                                        .replace(",", ".");
    }

    if (jQuery('.Oziris_dialog')
            .attr('Line1Code') != null) {
        params += (params != "" ? "&" : "") + "Line1Code=" + encodeURIComponent(jQuery('.Oziris_dialog')
                .attr('Line1Code'));
    }
    if (jQuery('.Oziris_dialog')
            .attr('Line1Title') != null) {
        params += (params != "" ? "&" : "") + "Line1Title=" + encodeURIComponent(jQuery('.Oziris_dialog')
                .attr('Line1Title'));
    }
    var line1Price = jQuery('.Oziris_dialog')
        .attr('Line1Price');
    if (line1Price != null && line1Price != undefined) {
        params += (params != "" ? "&" : "") + "Line1Price=" + line1Price.toString()
                                                                        .replace(",", ".");
    }

    if (IsPromo) {
        jQuery('.Oziris_dialog')
            .css('padding', '0 0 0 6px');
        jQuery('.Oziris_dialog')
            .html("<iframe class='noborder' style='width:100%;height:520px;background-color:white;border:none;' src='//xkasa.com.ua/Content/Oziris/3/?" + params + "'></iframe>");
    } else {
        jQuery('.Oziris_dialog')
            .html("<iframe class='noborder' style='width:100%;height:520px;background-color:white;border:none;margin-top:10px;' src='//xkasa.com.ua/Content/Oziris/1/?" + params + "'></iframe>");
    }

    jQuery(".Oziris_dialog")
        .dialog("open");
    return false;
};
