﻿
var TopMenuHandler = {
    Init: function() {

        try {
            $$(".menu-wrapper").each(function(el) {
                el.addEvent('mouseenter', function() {
                    TopMenuHandler.realMeyEdenLeave();
                    TopMenuHandler.yMeyEdenLeave();
                });
            });


            $$(".menu-wrapper")[0].addEvent('mouseenter', function() {
                TopMenuHandler.yMeyEdenOver();
                TopMenuHandler.realMeyEdenLeave();
            });

            $$(".menu-wrapper")[1].addEvent('mouseenter', function() {
                TopMenuHandler.realMeyEdenOver();
                TopMenuHandler.yMeyEdenLeave();
            });

            $$(".y-eyeden-items")[0].addEvent('mouseleave', function() {
                TopMenuHandler.yMeyEdenLeave();
            });

            $$(".real-meyeden-items").addEvent('mouseleave', function() {
                TopMenuHandler.realMeyEdenLeave();
            });
        }
        catch (Error) {

        }

    },


    yMeyEdenOver: function() {
        $("y-meyeden-wrapper").setStyle("display", "block");
    },

    yMeyEdenLeave: function() {
        $("y-meyeden-wrapper").setStyle("display", "none");
    },


    realMeyEdenOver: function() {
        $("real-meyeden-warpper").setStyle("display", "block");
    },

    realMeyEdenLeave: function() {
        $("real-meyeden-warpper").setStyle("display", "none");
    }

};






//lpCurrentStateVoice
var GeneralContactSalesLightBox = {
    Lightbox: null,
    Init: function() {
        wrapperId = "ContactSalesLightboxWrap";
        GeneralContactSalesLightBox.Lightbox = new Lightbox($(wrapperId));
        if ($("btContactSalesLightboxClose")) $("btContactSalesLightboxClose").addEvent("click", GeneralContactSalesLightBox.Close);

    },

    Open: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        GeneralContactSalesLightBox.Lightbox.show();
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);

    },
    OpenReal: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        GeneralContactSalesLightBox.Lightbox.show();
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        $("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    Close: function() {
        GeneralContactSalesLightBox.Lightbox.hide();
        _gaq.push(['_trackPageview', '/virtual/hp-banner/form-close']);
    }

};




var GeneralKravitzLightBox = {
    Lightbox: null,
    wrapperId: "",
    Init: function() {
        try {

            $("go-to-site").addEvent('click', function() {
                //GeneralKravitzLightBox.OpenReal();
            window.location.href = "http://www.meyeden.co.il/baby.asp";   });
        }
        catch (Error) {
        }

        try {
            $("kravitz-close").addEvent('click', function() {
                GeneralKravitzLightBox.Close();
            });
        }
        catch (Error) {
        }


        GeneralKravitzLightBox.wrapperId = "kravitzLightboxWrap";
        GeneralKravitzLightBox.Lightbox = new Lightbox($(GeneralKravitzLightBox.wrapperId));

        if ($("kravitz-close")) $("kravitz-close").addEvent("click", GeneralKravitzLightBox.Close);

    },

    Open: function() {
        //$(ContactLightbox.wrapperId).show();
        //ContactLightbox.Lightbox.show();
        ////urchinTracker('/outbound/Main_banner_open');
        //_gaq.push(['_trackPageview', '/virtual/hp-banner/click']);


    },
    OpenReal: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        GeneralKravitzLightBox.Lightbox.show();

        // $("kravitz-wrapper").setStyle("height", "1800px");
        $("kravitz-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    OpenRealCenter: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        GeneralKravitzLightBox.Lightbox.show();
        $("kravitz-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    Close: function() {
        $(GeneralKravitzLightBox.wrapperId).hide();
        GeneralKravitzLightBox.Lightbox.hide();
        $("kravitz-wrapper").setStyle("display", "none");
        $$(".meyeden-body")[0].setStyle("top", "0px");
        $$(".meyeden-body")[0].setStyle("left", "0px");
        //urchinTracker('/outbound/Main_banner_close');
        _gaq.push(['_trackPageview', '/virtual/hp-banner/form-close']);

    }

};


var JoinRealLightBox = {
    Lightbox: null,
    wrapperId: "",
    allreadySent: false,
    Init: function() {
        try {

            $$(".banner-btn")[0].addEvent('click', function() {
                scrollTo(0, 0);
                JoinRealLightBox.OpenReal();
                return false;
            });

            $$(".press-here")[0].addEvent('click', function() {
                scrollTo(0, 0);
                JoinRealLightBox.OpenReal();
            });

            $("support").addEvent('click', function() {
                scrollTo(0, 0);
                JoinRealLightBox.OpenReal();
            });
        }
        catch (Error) {
        }

        try {
            $("JoinReal-close").addEvent('click', function() {
                JoinRealLightBox.Close();
            });
        }
        catch (Error) {
            //console.log("error");
        }


        JoinRealLightBox.wrapperId = "JoinRealLightboxWrap";
        JoinRealLightBox.Lightbox = new Lightbox($(JoinRealLightBox.wrapperId));

        if ($("JoinReal-close")) $("JoinReal-close").addEvent("click", JoinRealLightBox.Close);
        if ($("JoinReal-close1")) $("JoinReal-close1").addEvent("click", JoinRealLightBox.Close);
        if ($("join-real-form2")) $("join-real-form2").addEvent("click", JoinRealLightBox.Close);
        
        
        

    },

    Open: function() {
        //$(ContactLightbox.wrapperId).show();
        //ContactLightbox.Lightbox.show();
        ////urchinTracker('/outbound/Main_banner_open');
        //_gaq.push(['_trackPageview', '/virtual/hp-banner/click']);


    },
    OpenReal: function() {

        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        if (this.allreadySent == false) {
            $("JoinReal-wrapper").setStyle("display", "block");
            $("joinReal-Ok").setStyle("display", "none");
        }
        else {
            $("JoinReal-wrapper").setStyle("display", "none");
            $("joinReal-Ok").setStyle("display", "block");
        }
        JoinRealLightBox.Lightbox.show();

        // $("kravitz-wrapper").setStyle("height", "1800px");
        //$("JoinReal-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    OpenRealCenter: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        JoinRealLightBox.Lightbox.show();
        $("JoinReal-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    Close: function() {

        $(JoinRealLightBox.wrapperId).hide();
        JoinRealLightBox.Lightbox.hide();
        $("JoinReal-wrapper").setStyle("display", "none");
        //$$(".meyeden-body")[0].setStyle("top", "0px");
        //$$(".meyeden-body")[0].setStyle("left", "0px");
        //urchinTracker('/outbound/Main_banner_close');
        _gaq.push(['_trackPageview', '/virtual/hp-banner/form-close']);

    }

};






////////join buisness lightbox start/////////////////

var BuisnessJoinRealLightBox = {
    Lightbox: null,
    wrapperId: "",
    allreadySent: false,
    Init: function() {
        try {
            $("more-form").addEvent('click', function() {
                scrollTo(0, 0);
                BuisnessJoinRealLightBox.OpenReal();
                return false;
            });
        }
        catch (Error) {
        }

        try {
            $("JoinBusiness-close").addEvent('click', function() {
                BuisnessJoinRealLightBox.Close();
            });
        }
        catch (Error) {
            //console.log("error");
        }


        BuisnessJoinRealLightBox.wrapperId = "JoinBusinessLightBoxWrap";
        BuisnessJoinRealLightBox.Lightbox = new Lightbox($(BuisnessJoinRealLightBox.wrapperId));

        if ($("JoinBusiness-close")) $("JoinBusiness-close").addEvent("click", BuisnessJoinRealLightBox.Close);
        if ($("Business-JoinReal-close1")) $("Business-JoinReal-close1").addEvent("click", BuisnessJoinRealLightBox.Close);
        if ($("Business-join-real-form2")) $("Business-join-real-form2").addEvent("click", BuisnessJoinRealLightBox.Close);

    },

    Open: function() {
        //$(ContactLightbox.wrapperId).show();
        //ContactLightbox.Lightbox.show();
        ////urchinTracker('/outbound/Main_banner_open');
        //_gaq.push(['_trackPageview', '/virtual/hp-banner/click']);


    },
    OpenReal: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        if (this.allreadySent == false) {
            $("JoinBusiness-wrapper").setStyle("display", "block");
            $("Business-joinReal-Ok").setStyle("display", "none");
        }
        else {
            $("JoinBusiness-wrapper").setStyle("display", "none");
            $("Business-joinReal-Ok").setStyle("display", "block");
        }
        BuisnessJoinRealLightBox.Lightbox.show();


        // $("kravitz-wrapper").setStyle("height", "1800px");
        //$("JoinReal-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    OpenRealCenter: function() {
        _gaq.push(['_trackPageview', '/virtual/callrequest']);
        BuisnessJoinRealLightBox.Lightbox.show();
        $("JoinReal-wrapper").setStyle("display", "block");
        _gaq.push(['_trackPageview', '/virtual/hp-banner/click']);
        //$("ContactSalesLightboxWrap").getParent().setStyle('top', '573px')

    },
    Close: function() {
       
        $(BuisnessJoinRealLightBox.wrapperId).hide();
        BuisnessJoinRealLightBox.Lightbox.hide();
        $("JoinBusiness-wrapper").setStyle("display", "none");
        //$$(".meyeden-body")[0].setStyle("top", "0px");
        //$$(".meyeden-body")[0].setStyle("left", "0px");
        //urchinTracker('/outbound/Main_banner_close');
        _gaq.push(['_trackPageview', '/virtual/hp-banner/form-close']);

    }

};






////////join buisness lightbox start/////////////////










function validateLightbox(oForm) {
    var err = 0;
    if (oForm.fullname.value == "" && err == 0) {
        alert("נא להזין שם");
        oForm.fullname.focus();
        err++;
    }

    if (oForm.phone.value == "" && err == 0) {
        alert("נא להזין טלפון");
        oForm.phone.focus();
        err++;
    }
    if (!checkPhone(oForm.phone.value) && err == 0) {
        alert("נא להזין טלפון חוקי");
        oForm.phone.focus();
        err++;
    }
    if (err == 0) {
        $("lightboxMsg").innerHTML = "שולח... נא להמתין";
        $("lightboxMsg2").innerHTML = "";
        $("contactForm").hide();

        return true;
    } else {
        return false;
    }

}
function checkPhone(str) {
    var phone2 = /^(([0-9]{1})*[- .(]*([0-9a-zA-Z]{3})*[- .)]*[0-9a-zA-Z]{3}[- .]*[0-9a-zA-Z]{4})+$/;
    if (str.match(phone2)) {
        return true;
    } else {
        return false;
    }
}

function validateEmail(email) {
    var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    if (!filter.test(email))
        return false;
    return true;
}



/////home page form start

//mini from handler
function miniFormClicked() {
    var name = $("mini-name").value;
    var phone = $("mini-phone").value;
    var email = $("mini-email").value;
    var mailing = 0;
    var formId = $("formId").value;

    $("err-message").setHTML("");
    if (name == "" || name == "שם") {
        $("err-message").setHTML("נא מלא/י את השם");
        return false;
    }

    if (!validateEmail(email)) {
        $("err-message").setHTML("כתובת אימייל לא תקינה");
        return false;
    }
    if (phone == "" || phone == "טלפון") {
        $("err-message").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    if (email == "") {
        $("err-message").setHTML("נא מלא/י את כתובת האימייל");
        return false;
    }
    if (!checkPhone(phone)) {
        $("err-message").setHTML("נא להזין טלפון חוקי");
        return false;
    }





    $("err-message").setHTML("שולח נתונים ...");
    var qString = Object.toQueryString({ action: "register", name: name, phone: phone, email: "", mailing: mailing, formId: formId });
    var url = _SitePath + "services/generalLightboxSaleRelay.asp?" + qString;

    if ($("submit-form"))
        $("submit-form").addClass('hidden');

    var ajaxSender = new Ajax(url, { method: 'get' });
    ajaxSender.addEvent('onComplete', eventMiniJoinUsCompleted);
    ajaxSender.request();

}



function eventMiniJoinUsCompleted(e) {
    $("err-message").setHTML("");
    //  $("hp-form-wrapper").addClass('hidden');
    //  $("hpFormConfitmation").removeClass('hidden');
    $("mini-form").setStyle("display", "none");
    $("submit-form").setStyle("display", "none");
    $("hpFormConfirmation").setStyle("display", "block");

}


///////////////////////////
////start join real logic//
///////////////////////////


function joinUsRealClicked() {
    var contactPerson = $("contact-person").value;
    var company = $("company").value;
    var workers = $("workers").value;
    var phone = $("phone12").value;
    var email = $("mail").value;


    var mailing = 0;
    var formId = $("joinRealFormId").value;



    $("err-message").setHTML("");
    if (contactPerson == "") {
        $("err-message").setHTML("נא מלא/י את שם איש הקשר");
        return false;
    }
    if (company == "") {
        $("err-message").setHTML(" נא מלא/י את שם החברה");
        return false;
    }
    if (workers == "") {
        $("err-message").setHTML(" נא מלא/י את מספר העובדים");
        return false;
    }


    if (phone == "") {
        $("err-message").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    if (email == "") {
        $("err-message").setHTML("נא מלא/י את כתובת האימייל");
        return false;
    }
    if (!validateEmail(email)) {
        $("err-message").setHTML("כתובת אימייל לא תקינה");
        return false;
    }


    if (!checkPhone(phone)) {
        $("err-message").setHTML("נא להזין טלפון חוקי");
        return false;
    }





    $("err-message").setHTML("שולח נתונים ...");

    var xReq = Browser.XML.HTTP();
    siteUrl = "";
    var postData = "fullName=" + contactPerson + "\
    &company=" + company + "\
    &phone=" + phone + "\
    &numEmployees=" + workers + "\
    &email=" + email;
    var siteUrl = "bennf@sdf.com";
    var ajaxSiteUrl = "http://meyeden.co.il";
    if (window.location.toString().indexOf('http://www.') == -1 && siteUrl.indexOf('http://www.') != -1) {
        ajaxSiteUrl = siteUrl.replace('http://www.', 'http://');
    }

    var query = "fullName=" + contactPerson + "&company=" + company + "&phone=" + phone + "&numEmployees=" + workers + "&email=" + email;

    xReq.open("GET", ajaxSiteUrl + "/Business2011/formSend.asp?" + query, true);

    xReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    xReq.onreadystatechange = function() {
        if (xReq.readyState == 4) {
            if (xReq.responseText == "OK") {
                document.getElementById("JoinReal-wrapper").style.display = "none";
                document.getElementById("joinReal-Ok").style.display = "block";
                JoinRealLightBox.allreadySent = true;
                //track('/Business2008/detailssent');
            }
            else {
                $("err-message").setHTML("ארעה תקלה אנא נסה מאוחר יותר");
            }

        }
    };

    //console.log(postData);
    xReq.send(postData);
}


function eventHPJoinUsCompleted(e) {
    $("err-message").setHTML("");
    //  $("hp-form-wrapper").addClass('hidden');
    //  $("hpFormConfitmation").removeClass('hidden');
    $$(".btn-wrapper")[0].addClass('hidden');
    $("submit-form").setStyle("display", "none");
    $("thank-u").setStyle("display", "block");

}










///////////////////////////
////end join real logic//
///////////////////////////






///////////////////////////
////start Business join real logic//
///////////////////////////


function BusinessjoinUsRealClicked() {
    var contactPerson = $("Business-contact-person").value;
    var company = $("Business-company").value;
    var workers = $("Business-workers").value;
    var phone = $("Business-phone12").value;
    var email = $("Business-mail").value;


    var mailing = 0;
    var formId = $("JoinBusinessFormId").value;



    $("err-message").setHTML("");
    if (contactPerson == "") {
        $("err-message").setHTML("נא מלא/י את שם איש הקשר");
        return false;
    }
    if (company == "") {
        $("err-message").setHTML(" נא מלא/י את שם החברה");
        return false;
    }
    if (workers == "") {
        $("err-message").setHTML(" נא מלא/י את מספר העובדים");
        return false;
    }


    if (phone == "") {
        $("err-message").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    if (email == "") {
        $("err-message").setHTML("נא מלא/י את כתובת האימייל");
        return false;
    }
    if (!validateEmail(email)) {
        $("err-message").setHTML("כתובת אימייל לא תקינה");
        return false;
    }


    if (!checkPhone(phone)) {
        $("err-message").setHTML("נא להזין טלפון חוקי");
        return false;
    }





    $("err-message").setHTML("שולח נתונים ...");

    var xReq = Browser.XML.HTTP();
    siteUrl = "";
    var postData = "fullName=" + contactPerson + "\
    &company=" + company + "\
    &phone=" + phone + "\
    &numEmployees=" + workers + "\
    &email=" + email;
    var siteUrl = "bennf@sdf.com";
    var ajaxSiteUrl = "http://www.meyeden.co.il/";
    if (window.location.toString().indexOf('http://www.') == -1 && siteUrl.indexOf('http://www.') != -1) {
        ajaxSiteUrl = siteUrl.replace('http://www.', 'http://');
    }

    var query = "fullName=" + contactPerson + "&company=" + company + "&phone=" + phone + "&numEmployees=" + workers + "&email=" + email;

    xReq.open("GET", ajaxSiteUrl + "/Business2011/formSend.asp?" + query, true);

    xReq.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");

    xReq.onreadystatechange = function() {
        if (xReq.readyState == 4) {
            if (xReq.responseText == "OK") {
                document.getElementById("JoinBusiness-wrapper").style.display = "none";
                document.getElementById("Business-joinReal-Ok").style.display = "block";
                JoinRealLightBox.allreadySent = true;
                //track('/Business2008/detailssent');
            }
            else {
                $("err-message").setHTML("ארעה תקלה אנא נסה מאוחר יותר");
            }

        }
    };

   // console.log(postData);
    xReq.send(postData);
}


function BusinesseventHPJoinUsCompleted(e) {
    $("err-message").setHTML("");
    //  $("hp-form-wrapper").addClass('hidden');
    //  $("hpFormConfitmation").removeClass('hidden');
    $$(".btn-wrapper")[0].addClass('hidden');
    $("submit-form").setStyle("display", "none");
    $("thank-u").setStyle("display", "block");

}










///////////////////////////
////end Business join real logic//
///////////////////////////






















function joinUsHpClicked() {
    var form = $('contact-form');
    var firstName = form.getElement('input[name=firstname]').value;
    var lastName = form.getElement('input[name=lastname]').value;
    var phone = form.getElement('input[name=phone]').value;
    var email = form.getElement('input[name=email]').value;
    var mailing = 0;
    var formId = form.getElement('input[name=formId]').value;
    var fullname = firstName + lastName;

    $("err-message").setHTML("");
    if (firstName == "" || firstName == "שם פרטי") {
        $("err-message").setHTML("נא מלא/י את השם");
        return false;
    }

    if (!validateEmail(email)) {
        $("err-message").setHTML("כתובת אימייל לא תקינה");
        return false;
    }
    if (phone == "" || phone == "טלפון") {
        $("err-message").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    if (email == "") {
        $("lightboxMsg2").setHTML("נא מלא/י את כתובת האימייל");
        return false;
    }
    if (!checkPhone(phone)) {
        $("err-message").setHTML("נא להזין טלפון חוקי");
        return false;
    }





    $("err-message").setHTML("שולח נתונים ...");
    var qString = Object.toQueryString({ action: "register", name: name, phone: phone, email: "", mailing: mailing, formId: formId });
    var url = _SitePath + "services/generalLightboxSaleRelay.asp?" + qString;

    if ($("submit-form"))
        $("submit-form").addClass('hidden');

    var ajaxSender = new Ajax(url, { method: 'get' });
    ajaxSender.addEvent('onComplete', eventHPJoinUsCompleted);
    ajaxSender.request();
}


function eventHPJoinUsCompleted(e) {
    $("err-message").setHTML("");
    //  $("hp-form-wrapper").addClass('hidden');
    //  $("hpFormConfitmation").removeClass('hidden');
    $$(".btn-wrapper")[0].addClass('hidden');
    $("submit-form").setStyle("display", "none");
    $("thank-u").setStyle("display", "block");

}




//////home page form end















function joinUsClicked() {
    var form = $('contactForm');
    var name = form.getElement('input[name=fullname]').value;
    var phone = form.getElement('input[name=phone]').value;
    var email = form.getElement('input[name=email]').value;
    var mailing = form.getElement('input[name=mailing]').checked;
    var formId = form.getElement('input[name=formId]').value;

    $("lightboxMsg2").setHTML("");
    if (name == "") {
        $("lightboxMsg2").setHTML("נא מלא/י את השם");
        return false;
    }
    if (phone == "") {
        $("lightboxMsg2").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    /*if (email==""){
    $("lightboxMsg2").setHTML("נא מלא/י את כתובת האימייל");
    return false;
    }*/
    if (!checkPhone(phone)) {
        $("lightboxMsg2").setHTML("נא להזין טלפון חוקי");
        return false;
    }

    /*if (!validateEmail(email)){
    $("lightboxMsg2").setHTML("כתובת אימייל לא תקינה");
    return false;
    }*/

    $("lightboxMsg2").setHTML("שולח נתונים ...");
    var qString = Object.toQueryString({ action: "register", name: name, phone: phone, email: email, mailing: mailing, formId: formId });
    var url = _SitePath + "services/generalLightboxSaleRelay.asp?" + qString;

    if ($("contact-send-button"))
        $("contact-send-button").addClass('hidden');

    var ajaxSender = new Ajax(url, { method: 'get' });
    ajaxSender.addEvent('onComplete', eventJoinUsCompleted);
    ajaxSender.request();
}


function eventJoinUsCompleted(e) {
    $("lightboxMsg2").setHTML("");
    $("theForm").addClass('hidden');
    $("form_thanks").removeClass('hidden');

}

function ContactSalesPersonClicked() {
    var form = $('ContactSalesLightboxForm');
    var name = form.getElement('input[name=fullname]').value;
    var phone = form.getElement('input[name=phone]').value;
    var email = form.getElement('input[name=email]').value;
    var mailing = form.getElement('input[name=mailing]').checked;
    var formId = form.getElement('input[name=formId]').value;


    form.getElement(".lightboxMsg_small").setHTML("");
    if (name == "") {
        form.getElement(".lightboxMsg_small").setHTML("נא מלא/י את השם");
        return false;
    }
    if (phone == "") {
        form.getElement(".lightboxMsg_small").setHTML("נא מלא/י את הטלפון");
        return false;
    }
    /*if (email==""){
    $("lightboxMsg2").setHTML("נא מלא/י את כתובת האימייל");
    return false;
    }*/
    if (!checkPhone(phone)) {
        form.getElement(".lightboxMsg_small").setHTML("נא להזין טלפון חוקי");
        return false;
    }

    /*if (!validateEmail(email)){
    $("lightboxMsg2").setHTML("כתובת אימייל לא תקינה");
    return false;
    }*/
    _gaq.push(['_trackPageview', '/virtual/callresponse']);

    form.getElement(".lightboxMsg_small").setHTML("שולח נתונים ...");
    var qString = Object.toQueryString({ action: "register", name: name, phone: phone, email: email, mailing: mailing, formId: formId });
    var url = _SitePath + "services/generalLightboxSaleRelay.asp?" + qString;

    if (form.getElement(".contact-send-button"))
        form.getElement(".contact-send-button").addClass('hidden');

    var ajaxSender = new Ajax(url, { method: 'get' });
    ajaxSender.addEvent('onComplete', eventContactSalesPersonCompleted);
    ajaxSender.request();
}

function eventContactSalesPersonCompleted(e) {
    _gaq.push(['_setCustomVar', 1, 'visitor-type', 'lead-call', '1']);
    $('ContactSalesLightboxForm').getElement(".lightboxMsg_small").setHTML("");
    $('ContactSalesLightboxWrap').getElement(".theForm").addClass('hidden');
    $("salesform_thanks").removeClass('hidden');
    gaq.push(['_setCustomVar', 2, 'visitor-type', 'lead-hp-banner', 1], ['_trackPageview', '/virtual/hp-banner-form/thankyou/']);

}

function domreadyFunc() {


    //general lightbox
    ContactLightbox.Init();
    // general contact sales lightbox
    GeneralContactSalesLightBox.Init();
    //  window.setTimeout("initLivePerson()", 1000);

    GeneralKravitzLightBox.Init();

    TopMenuHandler.Init();
    JoinRealLightBox.Init();

    BuisnessJoinRealLightBox.Init();
	

};

function initLivePerson() {
    // console.log(lpCurrentStateVoice);
    /*  if (lpCurrentStateVoice != 'online')
    $$(".live-person-div").each(function(el) {
    $(el).setProperty('onclick', '');
    $(el).addEvent('click', function(event) {
    var e = new Event(event);
    e.stop();
    e.preventDefault();
    GeneralContactSalesLightBox.Open();
    return false;
    });
    });*/

}

window.addListener("load", domreadyFunc);
document.addListener("DOMContentLoaded", domreadyFunc);




function popup() {
   // console.log("flash popup");
}
