﻿function doClear(theText) {
    if (theText.value == (theText.defaultInitValue ? theText.defaultInitValue : theText.defaultValue)) {
        theText.value = ""
    }
}

function doReset(theText) {
    if (theText.value == "") {
        theText.value = theText.defaultInitValue ? theText.defaultInitValue : theText.defaultValue
    }
}


function ShowHousePopup(title, link, cssClass) {
    link += '&TB_iframe=true&width=436&height=478';
    tb_show(title, link,cssClass);
}

function CheckPhone(source, arguments) {
    /*
    var msg = '';
    for (var p in arguments) {
        msg += p + ':' + arguments[p] + '\n' + eval(source.id + '.controltovalidate');
    }
    alert(source + '(' + source.id + ')\n' + arguments + '\n' + msg);
    */

    var sObject = (eval(source.id));

    var input = document.getElementById(sObject.controltovalidate);
    if (arguments.Value == (input.defaultInitValue ? input.defaultInitValue : input.defaultValue)) {
        arguments.IsValid = true;
    }
    else {
        arguments.IsValid = window.RegularExpressionValidatorEvaluateIsValid(sObject);
    }
    return arguments.IsValid;
}


function Penki_OpenPopup(popLocation, popName, popWidth, popHeigth, popOptions) {
    var x = 0;
    var y = 0;
    if (window.screen) {
        if (screen.availWidth && screen.availHeight) {
            x = (screen.availWidth - popWidth) * 0.5;
            y = (screen.availHeight - popHeigth) * 0.5;
        }
        else if (screen.width && screen.heght) {
            x = (screen.width - popWidth) * 0.5;
            y = (screen.heght - popHeigth) * 0.5;
        }
    }
    var popupw;
    var options = 'width=' + popWidth + ',height=' + popHeigth + ',left=' + x + ',top=' + y
    if (popOptions != '') {
        options = options + ',' + popOptions
    }

    popupw = window.open(popLocation, popName, options, true);
    if (popupw) {
        popupw.moveTo(x, y);
        popupw.focus();
    }
    return popupw


}
