/**
functions
**/
function clearSearchText() {
	if (event.srcElement != null && event.srcElement.value.length > 0)
	event.srcElement.value = "";
}

function chPartnerImg(obj, n) {
    var sf = '';
    var nn = 0;
    if (n == 1) {
        sf = 'color.png';
        nn = 8;
    }
    if (n == 0) {
        sf = 'gray.png';
        nn = 9;
    }
    obj.src = obj.src.substr(0, obj.src.length - nn) + sf;
}


/**
<p><a href="javascript: shide('answ')">Quest</a></p><p id="answ" style="display:none;"><br/>Answ answ answ<br/></p>
**/
function ge() {
    var ea;
    for (var i = 0; i < arguments.length; i++) {
        var e = arguments[i];
        if (typeof e == 'string') e = document.getElementById(e);
        if (arguments.length == 1) return e;
        if (!ea) ea = new Array();
        ea[ea.length] = e;
    }
    return ea;
}

function show() {
    for (var i = 0; i < arguments.length; i++) {
        var element = ge(arguments[i]);
        if (element && element.style) element.style.display = 'block';
    }
}

function hide() {
    for (var i = 0; i < arguments.length; i++) {
        var element = ge(arguments[i]);
        if (element && element.style) element.style.display = 'none';
    }
}

function shown(el) {
    el = ge(el);
    return (el.style.display != 'none');
}

function shide(el) {
    if (shown(el)) {
        hide(el);
    } else {
        show(el);
    }
}


/**
Cross-browser PoPup image <a href="javascript:Start('big.png',800,600)"><img src="small.png" alt="" border="0"/></a>
**/
timeout = 0;

function Start(url, width, height) {
    windowprops = "width=" + (width + 2) + ",height=" + (height + 2);
    text = "<html><head><title>Photo</title></head><body bgcolor='#fefefe' style='padding: 1px; margin: 0'";
    if (timeout != 0) text += " onLoad=\"setTimeout('window.close()', " + timeout * 1000 + ");\"";
    text += "><div align=center><a href='javascript:top.window.close();'><img src='" + url + "' border='0'>";
    if (timeout != 0) text += "<br><span style='tahoma, arial' size='-1'>Preview closes after " + timeout + " seconds.</span>";
    text += "</a></div></body></html>";
    preview = window.open("", "preview", windowprops);
    preview.document.open();
    preview.document.write(text);
    preview.document.close();
}

/**
Toogle
**/
var toggleA = function () {
    var currentDiv = null;

    function open(divElement) {
        divElement.style.display = "block";
        currentDiv = divElement;
    }

    function close(divElement) {
        divElement.style.display = "none";
        currentDiv = null;
    }
    return function (divID) {
        var divElement = document.getElementById(divID);
        if (divElement) {
            if (divElement === currentDiv) {
                close(currentDiv);
            } else if (currentDiv != null) {
                close(currentDiv);
                open(divElement);
            } else {
                open(divElement);
            }
        }
    }
}();

/**
refreshCaptcha
use:
<input type="hidden" name="captcha_sid" value="31fc87e85f3f2b95fa6eaef2b2068ecb" /><img src="http://www.expodns.org/bitrix/tools/captcha.php?captcha_sid=31fc87e85f3f2b95fa6eaef2b2068ecb" width="180" height="40" id="capchaHolder"/> <a class="reload" href="javascript:refreshCaptcha('capchaHolder')">Link</a>
**/
function refreshCaptcha(imgId) {
    var dtNowDate;
    dtNowDate = new Date();
    nMilliseconds = dtNowDate.getTime();
    document.getElementById(imgId).src += '&refresh=' + nMilliseconds;
}
