﻿function changeImg(id,toggle) 
{
    var pic = id;
    var hoverPic = id + "o";
    if (toggle == 'hover')
        document.getElementById(id).src = '/img/' + pic + '_o.png';
    else if (toggle == 'selected')
        document.getElementById(id).src = '/img/' + pic + '_o.png';
    else
        document.getElementById(id).src = '/img/' + pic + '.png';
}

function change_menu_out(id, over) 
{
    var pic = id;
    if (over == 'yes') {
        document.getElementById(id).onmouseout = '(' + id + ',' + pic + '_o.png,' + over + ')';
    }
    else {
        document.getElementById(id).src = '/img/' + pic + '.png';
    }
}

function ManagePopup(id, toggle) 
{
    if (toggle == 'open') {
        document.getElementById(id).style.display = '';
    }
    else
        document.getElementById(id).style.display = 'none';
}

function ShowPopupZone(checkId1,checkId2,checkId3, clickId1,clickId2, valueId1,valueId2,valueId3) {
    var idBox1 = document.getElementById(clickId1); // id นี้คือค่าของ div ของ zone,location,price
    var idBox2 = document.getElementById(clickId2); // id นี้คือค่าของ div ของ zone,location,price
    var checkId1 = document.getElementById(checkId1); // id นี้คือค่า hidden ของ zone,location,price 1
    var checkId2 = document.getElementById(checkId2); // id นี้คือค่า hidden ของ zone,location,price 2
    var checkId3 = document.getElementById(checkId3); // id นี้คือค่า hidden ของ zone,location,price 2
    var clearId1 = document.getElementById(valueId1); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 1
    var clearId2 = document.getElementById(valueId2); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 2
    var clearId3 = document.getElementById(valueId3); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 2
    var idImg1 = document.getElementById(clickId1 + 'Img'); //location pic
    var idImg2 = document.getElementById(clickId2 + 'Img'); //budget pic
    if (idImg1) {
        if (checkId1.value) {
            if (idBox1.style.display == 'none') {
                idBox1.style.display = '';
                idImg1.src = '/img/btnDown.png';
            }
        } else {
            
            clearId1.value = '';
            idImg1.src = '/img/btnNext_Gray.png';
            idBox1.style.display = 'none';
            clearId2.value = '';
            if (checkId2) {
                checkId2.value = '';
            }
            idImg2.src = '/img/btnNext_Gray.png';
            idBox2.style.display = 'none';
            clearId3.value = '';
            if (checkId3) {
                checkId3.value = '';
            }
            }

        }
}

function ShowPopupLocation(checkId1, checkId2, clickId, valueId1, valueId2) {
    var idBox = document.getElementById(clickId); // id นี้คือค่าของ div ของ location,price
    var checkId1 = document.getElementById(checkId1); // id นี้คือค่า hidden ของ location,price 1
    var checkId2 = document.getElementById(checkId2); // id นี้คือค่า hidden ของ location,price 2
    var clearId1 = document.getElementById(valueId1); // id สำหรับ โชว์ค่าเมื่อทำการเลือก location,price แล้ว 1
    var clearId2 = document.getElementById(valueId2); // id สำหรับ โชว์ค่าเมื่อทำการเลือก location,price แล้ว 2
    var idImg = document.getElementById(clickId + 'Img'); //budget pic
    if (idImg) {
        if (checkId1.value) {
            if (idBox.style.display == 'none') {
                idBox.style.display = '';
                idImg.src = '/img/btnDown.png';
            }
        } else {
            clearId1.value = '';
            idImg.src = '/img/btnNext_Gray.png';
            idBox.style.display = 'none';
            clearId2.value = '';
            if (checkId2) {
                checkId2.value = '';
            }
        }

    }
}

function bShowPopupZone(checkId1, checkId2, checkId3, clickId1, clickId2, valueId1, valueId2, valueId3) {
    var idBox1 = document.getElementById(clickId1); // id นี้คือค่าของ div ของ zone,location,price
    var idBox2 = document.getElementById(clickId2); // id นี้คือค่าของ div ของ zone,location,price
    var checkId1 = document.getElementById(checkId1); // id นี้คือค่า hidden ของ zone,location,price 1
    var checkId2 = document.getElementById(checkId2); // id นี้คือค่า hidden ของ zone,location,price 2
    var checkId3 = document.getElementById(checkId3); // id นี้คือค่า hidden ของ zone,location,price 2
    var clearId1 = document.getElementById(valueId1); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 1
    var clearId2 = document.getElementById(valueId2); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 2
    var clearId3 = document.getElementById(valueId3); // id สำหรับ โชว์ค่าเมื่อทำการเลือก zone,location,price แล้ว 2
    var idImg1 = document.getElementById(clickId1 + 'Img'); //location pic
    var idImg2 = document.getElementById(clickId2 + 'Img'); //budget pic
    if (idImg1) {
        if (checkId1.value) {
            if (idBox1.style.display == 'none') {
                idBox1.style.display = '';
                idImg1.src = '/img/btnDown.png';
            }
        } else {

            clearId1.value = '';
            idImg1.src = '/img/btnNext_Gray.png';
            idBox1.style.display = 'none';
            clearId2.value = '';
            if (checkId2) {
                checkId2.value = '';
            }
            idImg2.src = '/img/btnNext_Gray.png';
            idBox2.style.display = 'none';
            clearId3.value = '';
            if (checkId3) {
                checkId3.value = '';
            }
        }

    }
}

function bShowPopupLocation(checkId1, checkId2, clickId, valueId1, valueId2) {
    var idBox = document.getElementById(clickId); // id นี้คือค่าของ div ของ location,price
    var checkId1 = document.getElementById(checkId1); // id นี้คือค่า hidden ของ location,price 1
    var checkId2 = document.getElementById(checkId2); // id นี้คือค่า hidden ของ location,price 2
    var clearId1 = document.getElementById(valueId1); // id สำหรับ โชว์ค่าเมื่อทำการเลือก location,price แล้ว 1
    var clearId2 = document.getElementById(valueId2); // id สำหรับ โชว์ค่าเมื่อทำการเลือก location,price แล้ว 2
    var idImg = document.getElementById(clickId + 'Img'); //budget pic
    if (idImg) {
        if (checkId1.value) {
            if (idBox.style.display == 'none') {
                idBox.style.display = '';
                idImg.src = '/img/btnDown.png';
            }
        } else {
            clearId1.value = '';
            idImg.src = '/img/btnNext_Gray.png';
            idBox.style.display = 'none';
            clearId2.value = '';
            if (checkId2) {
                checkId2.value = '';
            }
        }

    }
}

function openPopup(id) 
{    
    var idBox = document.getElementById(id);
    var idImg = document.getElementById(id + 'Img');
    if (id != 'chooseZone') {
        if (idImg) {
            if (idBox.style.display == 'none') {
                idBox.style.display = '';
                idImg.src = '/img/btnDown.png';
            }
            else {
                idBox.style.display = 'none';
                idImg.src = '/img/btnNext_Gray.png';
            }
        }
    }
    else {
        idBox.style.display = '';
        idImg.src = '/img/btnDown.png';
    }
}

function bOpenPopup(id) {
    var idBox = document.getElementById(id);
    var idImg = document.getElementById(id + 'Img');
    if (id != 'bChooseZone') {
        if (idImg) {
            if (idBox.style.display == 'none') {
                idBox.style.display = '';
                idImg.src = '/img/btnDown.png';
            }
            else {
                idBox.style.display = 'none';
                idImg.src = '/img/btnNext_Gray.png';
            }
        }
    }
    else {
        idBox.style.display = '';
        idImg.src = '/img/btnDown.png';
    }
}

function ClosePopup(id) 
{
    var idBox = document.getElementById(id);
    var idImg = document.getElementById(id + 'Img');
    idBox.style.display = 'none';
    idImg.src = '/img/btnNext_Gray.png';
}

function bClosePopup(id) {
    var idBox = document.getElementById(id);
    var idImg = document.getElementById(id + 'Img');
    idBox.style.display = 'none';
    idImg.src = '/img/btnNext_Gray.png';
}

function ManageDetail(id) {
    var getId = document.getElementById(id);
    var count;
    //Clear Content
    for (count = 1; count <= 4; count++) 
    {
        var newId = "menu" + count;
        document.getElementById(newId).style.display = 'none'
    }

    //Load Content
    for (count = 1; count <= 4; count++) 
    {
        var newId = "menu" + count;

        if (newId == id) {
            getId.style.display = '';
            break;
        }
        else {
            getId.style.display = 'none';
        }
    }
}

//function ManageDetail(id, imgId) {
//    var getId = document.getElementById(id);
//    var count;
//    //Clear Content
//    for (count = 1; count <= 4; count++) {
//        var newId = "menu" + count;
//        document.getElementById(newId).style.display = 'none'
//    }

//    //Load Content
//    for (count = 1; count <= 4; count++) {
//        var newId = "menu" + count;

//        if (newId == id) {
//            document.getElementById("ContentProject").value = "";
//            changeImg(imgId, 'selected');
//            change_menu_out(imgId, 'yes')
//            getId.style.display = '';
//            break;
//        }
//        else {
//            getId.style.display = 'none';
//        }
//    }
//}

function clearValue(id, hiddenId) {
    if (document.getElementById(id).value != "" || document.getElementById(id).value != null) {
        document.getElementById(id).value = "";

        if (document.getElementById(hiddenId)) {
            document.getElementById(hiddenId).value = "";
        }
    } 
}




