﻿function PopupWindow1(url, name, width, height, top, left) {
    left = parseInt((getWidthHeight().width - width) / 2);
    var properties = 'location=yes,width='+width+',height='+height+',top='+top+',left='+left+
    'toolbar=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=yes,resizable=yes';
    popupWin = window.open(url, name, properties); 
    popupWin.focus();
}
function getWidthHeight() {
    var w = 0;
    var h = 0;
    if (typeof(window.innerWidth) == 'number') {
    //Non-IE
        w = window.innerWidth;
        h = window.innerHeight;
    }
    else 
    if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight)) {
    //IE 6+ in 'standards compliant mode'
        w = document.documentElement.clientWidth;
        h = document.documentElement.clientHeight;
    }
    else 
    if (document.body && (document.body.clientWidth || document.body.clientHeight )) {
        //IE 4 compatible
        w = document.body.clientWidth;
        h = document.body.clientHeight;
    }
    return {width:w,height:h};
}

function ValidateForm() {
    var isValid = true;
    var errors = '';

    var type_ = Find_Control("ctl00_Content_Reserving1_TypeDDL").value;
    if (type_ == 0) 
    {
        errors += "- Вкажіть коректно тип послуги <br />";
        isValid = false;
    }

    var pip = Find_Control("ctl00_Content_Reserving1_pip").value;
    if (pip.length < 3) {
        errors += "- Вкажіть коректно Ваше Ім'я <br />";
        isValid = false;
    }
    var contacts = Find_Control("ctl00_Content_Reserving1_Contacts").value;
    if (contacts.length < 3) {
        errors += "- Вкажіть контактну інформацію(тел., e-mail, ...)<br />";
        isValid = false;
    }
    var dateFromTextBox = Find_Control("ctl00_Content_Reserving1_dateFromTextBox").value;
    if (dateFromTextBox.length < 3) {
        errors += "- Вкажіть коректно дату заїзду <br />";
        isValid = false;
    }
    
    if (isValid) {
        return true;
    }
    else {
        showErrors(errors);
        return false;
    }
}
function showErrors(errors) {
    var div = Find_Control("errors");
    div.style.display = "block";
    Find_Control("errors_content").innerHTML = errors;
}

function Find_Control(id) {
    if (document.getElementById)
        var returnVar = document.getElementById(id);
    else if (document.all)
        var returnVar = document.all[id];
    else if (document.layers)
        var returnVar = document.layers[id];
    return returnVar;
}
