﻿function MovePicsStrip(direction) {

   
    var picsWindow = document.getElementById("ProjectImagesWindow");
    if (picsWindow != null) {

        if (picsWindow.style.left == '') { //Initialize position
            picsWindow.style.left = "0px";
        }

        var numOfPics = $("#numOfPics").html();
        var numOfWindows = Math.round(numOfPics / 3);
        if ((numOfPics % 3) == 1) numOfWindows++;
        var maxLeftPosition = (numOfWindows - 1) * 270; 
        if (direction == 'right') {

            if (picsWindow.style.left.toString() != ("-" + maxLeftPosition + "px")) {
                $(".ProjectImagesWindow").animate({ "left": "-=270px" }, "slow");
            }

     }

     if (direction == 'left') {
         if (picsWindow.style.left != "0px")
         {   
         $(".ProjectImagesWindow").animate({ "left": "+=270px" }, "slow");
         }
        }
       
    }

}


function PageProjects(pageID) {

    if (pageID != 0) {
        window.location = "/" + pageID + "/פרוייקטים/דפי-תוכן" + ".aspx";
    }

}


function ShowSubMenu(id) {

    var openSubMenu = document.getElementById("openSubMenu");
    if (openSubMenu.value != id) {
        HideAllOtherSubMenus(id);
    }
    switch (id) {

        case 1:
            var subMenuId = "projectsSubMenu";
            break;
        case 2:
            var subMenuId = "servicesSubMenu";
          
            break;
        case 3:

            var subMenuId = "clientsSubMenu";
            break;
            break;
        case 4:
            var subMenuId = "aboutSubMenu";
            break;
        case 5:
            var subMenuId = "contactSubMenu";
            break;
           
        default:
            break;

    }

    if (openSubMenu != null) {
    
        if (openSubMenu.value != id) {
            openSubMenu.value = id;

            if (isIe6) {
                $("." + subMenuId).show();
            } else {
                $("." + subMenuId).slideDown(400, function() { HideAllOtherSubMenus(id); });
            }
          
       
        }
    }


}

function isIe6() {
    var bIe6 = false;
    var version = 999; // we assume a sane browser   
    if (navigator.appVersion.indexOf("MSIE") != -1) {
        version = parseFloat(navigator.appVersion.split("MSIE")[1]);
        if (version < 7) {
            bIe6 = true;
        }
    }
    return bIe6
}


function HideAllOtherSubMenus(id) {

    for (var i = 1; i <= 5; i++) {
        if (i != id) {
            HideSubMenu(i);
        }
    }


}

function ShowFastSubMenu(id) {
    
    
    var openSubMenu = document.getElementById("openSubMenu");

    switch (id) {

        case 1:
            var subMenuId = "projectsSubMenu";
            $("#servicesSubMenu").hide();
            $("#clientsSubMenu").hide();
            $("#aboutSubMenu").hide();
            $("#contactSubMenu").hide();
            break;
        case 2:
            var subMenuId = "servicesSubMenu";
            $("#projectsSubMenu").hide();
            $("#clientsSubMenu").hide();
            $("#aboutSubMenu").hide();
            $("#contactSubMenu").hide();

            break;
        case 3:
            var subMenuId = "clientsSubMenu";
            $("#projectsSubMenu").hide();
            $("#servicesSubMenu").hide();
            $("#aboutSubMenu").hide();
            $("#contactSubMenu").hide();
            break;
        case 4:
            var subMenuId = "aboutSubMenu";
            $("#projectsSubMenu").hide();
            $("#clientsSubMenu").hide();
            $("#servicesSubMenu").hide();
            $("#contactSubMenu").hide();
            break;

        case 5:
            var subMenuId = "contactSubMenu";
            $("#projectsSubMenu").hide();
            $("#clientsSubMenu").hide();
            $("#servicesSubMenu").hide();
            $("#aboutSubMenu").hide();
            break;
        default:
            break;

    }

    if (openSubMenu != null) {

        if (openSubMenu.value != id) {
            
            var obj = document.getElementById(subMenuId);
            if (obj != null) {
                
                
                obj.style.display = "";
         
            }
            openSubMenu.value = id;
        }
    }


}



function HideSubMenu(id) {


    var openSubMenu = document.getElementById("openSubMenu");
    
    switch (id) {

        case 1:
            var subMenuId = "projectsSubMenu";
            break;
        case 2:
            var subMenuId = "servicesSubMenu";
            break;
        case 3:
            var subMenuId = "clientsSubMenu";
            break;

        case 4:
            var subMenuId = "aboutSubMenu";
            break;
        case 5:
            var subMenuId = "contactSubMenu";
            break;
        default:
            break;

    }

    $("#" + subMenuId).hide();



}

function HideAllSubMenus() {

  

    var obj = document.getElementById("projectsSubMenu");
    if (obj != null) {
        obj.style.display = "none";
    }
    var obj = document.getElementById("servicesSubMenu");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("clientsSubMenu");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("aboutSubMenu");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("contactSubMenu");
    if (obj != null) {
        obj.style.display = "none";
    }
    
    var openSubMenu = document.getElementById("openSubMenu");
    if (openSubMenu != null) {
        openSubMenu.value = "";
    }
}

function ShowVSDMovie() {

    swfobject.embedSWF("/video/movie-vsd.swf", "videoContainer", "803", "478", "9.0.0", "", '', { allowfullscreen: "true", allowScriptAccess: "always" });

    var obj = document.getElementById("PlayerBg");
    if (obj != null) {
        obj.style.display = "";
    }
    var obj = document.getElementById("videoPlayer");
    if (obj != null) {
        obj.style.display = "";
    }

    var obj = document.getElementById("imageMain");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("imageMainNoFlash");
    if (obj != null) {
        obj.style.display = "";
    }

    var obj = document.getElementById("customersFlash");
    if (obj != null) {
        obj.style.display = "none";
    }



}

function CloseVideo() {


    var videoPlayer = document.getElementById("videoPlayer");
    if (videoPlayer != null) {

        var newDiv = document.createElement("div");
        newDiv.id = "videoContainer";
        videoPlayer.removeChild(videoPlayer.lastChild);
        videoPlayer.appendChild(newDiv);
    }


    var obj = document.getElementById("PlayerBg");
    if (obj != null) {
        obj.style.display = "none";
    }
    var obj = document.getElementById("videoPlayer");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("imageMain");
    if (obj != null) {
        obj.style.display = "";
    }

    var obj = document.getElementById("imageMainNoFlash");
    if (obj != null) {
        obj.style.display = "none";
    }

    var obj = document.getElementById("customersFlash");
    if (obj != null) {
        obj.style.display = "";
    }

}

function ShowProjectPic() {

  
    var links = document.getElementsByName("SliderPicsLinks");
    if (links.length > 0) {
        links[0].click();
    }

}

function SendContactForm() {

    var txtName = document.getElementById("txtName");
    var txtMail = document.getElementById("txtMail");
    var txtCompany = document.getElementById("txtCompany");
    var txtPhone = document.getElementById("txtPhone");
    var contactStatus = document.getElementById("contactStatus");
    var txtMsg = document.getElementById("txtMsg");
    var isMail = false;
    var name = "";
    var mail = "";
    var company = "";
    var phone = "";
    var msg = "";

    if (txtName != null) {
        if (txtName.value != "") {
            name = txtName.value;
        } else {
        if (contactStatus != null) {
            contactStatus.innerHTML = "נא למלא שם";
            return;
        }
        }
    }

    if (txtMail != null) {
        if (txtMail.value != "") {
            mail = txtMail.value;
            isMail = true;
        } 
        
    }

    if (txtCompany != null) {
        company = txtCompany.value;
    }

    if (txtPhone != null) {
      
        if (txtPhone.value == "" && !isMail) {
            if (contactStatus != null) {
                contactStatus.innerHTML = "נא למלא מייל/טלפון";
                return;
            }

        } else {
            phone = txtPhone.value;
        }
    }

    if (txtMsg != null) {
        msg = txtMsg.value;
    }


    ContactService.AddContact(name, mail, company, phone, msg, ContactSuccess, ContactFailed);

}

function ContactSuccess() {


    var contactHeader = document.getElementById("contactHeader");
    var contactStatus = document.getElementById("contactStatus");
    if (contactHeader != null && contactStatus != null ) {  //Homepage
        contactHeader.innerHTML = "פרטיך נשלחו בהצלחה"; 
        contactStatus.innerHTML = "";
    } else { //Contact Page
        contactStatus.innerHTML = "פרטיך נשלחו בהצלחה"; 
    }
    
   

}

function ContactFailed() {

    var contactStatus = document.getElementById("contactStatus");
    if (contactStatus != null) {
        contactStatus.innerHTML = "שגיאה בשליחת ההודעה";
    }
    
}
