function collexUl(theA) {
    var theLi = theA.parentNode.parentNode;
        if (theLi && theLi.tagName && theLi.tagName.toUpperCase() === 'LI') {
            var oChild = theLi.firstChild;
            while (oChild && !(oChild.tagName && oChild.tagName.toUpperCase() === 'UL')) {
                oChild = oChild.nextSibling;
            }
            if (oChild && oChild.tagName && oChild.tagName.toUpperCase() === 'UL') {
                if (oChild.style.display === 'block') {
                    oChild.style.display = 'none';
                    // change image
                    theA.src = '/img/left/menu/close.gif';
					theA.title = 'Развернуть меню';
                } else {
                    oChild.style.display = 'block';
                    // change image
                    theA.src = '/img/left/menu/open.gif';
					theA.title = 'Свернуть меню';						  
                }
            }
        }
        //
        return false;
}

function checkForm(obj, elems) {
var element, pattern; 
var reg = new RegExp("[0-9a-z_]+@[0-9a-z_^.]+\\.[a-z]{2,3}", 'i'); 
    for (var i = 0; i < obj.elements.length; i++) {
        element = obj.elements[i];    //  alert(element.value);
        if (elems != undefined) 
        if (elems.join().indexOf(element.type) < 0) continue;       
        if (!element.getAttribute('required')) continue;   
        if (pattern = element.getAttribute("check_pattern")) {
            pattern = new RegExp(pattern, "g"); 
            if (!pattern.test(element.value)) { 
                alert(element.getAttribute('required'));   
                element.focus();
                return false;
            }   
        }
		else if(/^\s*$/.test(element.value)) { 
            alert(element.getAttribute('required'));
            element.focus();    
            return false;       
        }
		if (null!=element.getAttribute('mail'))
		if (!reg.test(element.value)) {
			alert(element.getAttribute('mail'));
			element.focus(); 
			return false;
		}
		
    }
	
	return true;
}

function submitForm(formId) {
	var form = document.getElementById(formId);
	form.submit();
	return false;
}



function subMenu(theA) {
    var theLi = theA.parentNode;
        if (theLi && theLi.tagName && theLi.tagName.toUpperCase() === 'LI') {
            var oChild = theLi.firstChild;
            while (oChild && !(oChild.tagName && oChild.tagName.toUpperCase() === 'OL')) {
                oChild = oChild.nextSibling;
            }
            if (oChild && oChild.tagName && oChild.tagName.toUpperCase() === 'OL') {
                if (oChild.style.display === 'block') {
                    oChild.style.display = 'none';
                    // change image
                    theA.src = '/img/submenu/close.gif';
					theA.title = 'Развернуть меню';
					theA.parentNode.className = '';
                } else {
                    oChild.style.display = 'block';
                    // change image
                    theA.src = '/img/submenu/open.gif';
					theA.title = 'Свернуть меню';	
					theA.parentNode.className = 'act';					
                }
            }
        }
        //
        return false;
}


function showVac(vacId) {

	var vac_dd = document.getElementById(vacId);
	vac_dd.className=='none' ? vac_dd.className = 'block' : vac_dd.className = 'none';
	return false;

}

function gen_popup(src, width, height, page_header) {
	if(!page_header)
		page_header = "";

	win = window.open("", "_blank", "width=" + (width) + ",height=" + (height) + ",titlebar=no,toolbar=no,location=no,status=no,menubar=no,scrollbars=auto,resizable=no");

	win.document.write("<html><head><title>" + page_header + "</title></head><body leftmargin=0 topmargin=0 marginwidth=0 marginheight=0><table style='height: 100%' cellspacing='0' cellpadding='0' border='0'><tr><td valgin='middle'>");
	win.document.write("<" + "script" + ">document.title = \"" + page_header + "\";\r\nfunction _CloseOnEsc(e) {if(e){ event = e;} if (event.keyCode == 27) { window.close(); return; }} document.onkeydown = _CloseOnEsc;<" + "/script>");
	win.document.write("<img src=\"" + src +  "\" onclick=\"javascript: window.close();\" style=\"cursor: pointer;\" />");
	win.document.write("</td></tr></table></body></html>");
	win.document.close();
	return false;
}