window.onerror = null; var tooltip_attr_name = "tooltip";
var tooltip_blank_text = "(apparirà nel nuovo finestrino)";
var tooltip_newline_entity = "  ";
var tooltip_max_width = "300"
window.onload = function(e) { if (document.createElement) tooltip.d(); }
tooltip = { t: document.createElement("div"), c: null, g: false, m: function(e) { if (tooltip.g) { oCanvas = document.getElementsByTagName( (document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY" )[0]; x = window.event ? event.clientX + oCanvas.scrollLeft : e.pageX; y = window.event ? event.clientY + oCanvas.scrollTop : e.pageY; tooltip.a(x, y); } }, d: function() {	tooltip.t.setAttribute("id", "tooltip");
document.body.appendChild(tooltip.t); a = document.all ? document.all : document.getElementsByTagName("*"); aLength = a.length; for (var i = 0; i < aLength; i++) { tooltip_title = a[i].getAttribute("title"); tooltip_alt = a[i].getAttribute("alt"); tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip_blank_text; if (tooltip_title || tooltip_blank) { a[i].setAttribute(tooltip_attr_name, tooltip_blank ? (tooltip_title ? tooltip_title + " " + tooltip_blank_text : tooltip_blank_text) : tooltip_title); if (a[i].getAttribute(tooltip_attr_name)) { a[i].removeAttribute("title"); if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt"); tooltip.l(a[i], "mouseover", tooltip.s); tooltip.l(a[i], "mouseout", tooltip.h); } } else if (tooltip_alt && a[i].complete) { a[i].setAttribute(tooltip_attr_name, tooltip_alt); if (a[i].getAttribute(tooltip_attr_name)) { a[i].removeAttribute("alt"); tooltip.l(a[i], "mouseover", tooltip.s); tooltip.l(a[i], "mouseout", tooltip.h); } } if (!a[i].getAttribute(tooltip_attr_name) && tooltip_blank) { } } document.onmousemove = tooltip.m; window.onscroll = tooltip.h; }, s: function(e) { d = window.event ? window.event.srcElement : e.currentTarget; if (!d.getAttribute(tooltip_attr_name)) return; if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild); tooltip.t.appendChild(document.createTextNode(d.getAttribute(tooltip_attr_name))); r = d.getAttribute(tooltip_attr_name); tooltip.t.innerHTML = r.replace(tooltip_newline_entity, "<br />"); tooltip.c = setTimeout("tooltip.t.style.visibility = 'visible';", 1); tooltip.g = true; }, h: function(e) { tooltip.t.style.visibility = "hidden"; if (!tooltip_newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild); clearTimeout(tooltip.c); tooltip.g = false; tooltip.a(-99, -99); }, l: function(o, e, a) { if (o.addEventListener) o.addEventListener(e, a, false); else if (o.attachEvent) o.attachEvent("on" + e, a); else return null; }, a: function(x, y) { oCanvas = document.getElementsByTagName( (document.compatMode && document.compatMode == "CSS1Compat") ? "HTML" : "BODY" )[0]; w_width = window.innerWidth ? window.innerWidth + window.pageXOffset : oCanvas.clientWidth + oCanvas.scrollLeft; w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : oCanvas.clientHeight + oCanvas.scrollTop; tooltip.t.style.width = "auto"; t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth; t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight; if (t_width > tooltip_max_width) { tooltip.t.style.width = tooltip_max_width + "px"; t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth; } t_extra_width = 7; t_extra_height = 5; tooltip.t.style.left = x + 8 + "px"; tooltip.t.style.top = y + 8 + "px"; while (x + t_width + t_extra_width > w_width) { --x; tooltip.t.style.left = x + "px"; t_width = window.event ? tooltip.t.clientWidth : tooltip.t.offsetWidth;	} while (y + t_height + t_extra_height > w_height) { --y;	tooltip.t.style.top = y + "px";	t_height = window.event ? tooltip.t.clientHeight : tooltip.t.offsetHeight; } } }

var agt = navigator.userAgent.toLowerCase();
var is_ie = (agt.indexOf("msie") != -1);
var is_ie5 = (agt.indexOf("msie 5") != -1);
var is_opera = (agt.indexOf("opera") != -1);
var is_mac = (agt.indexOf("mac") != -1);
var is_gecko = (agt.indexOf("gecko") != -1);
var is_safari = (agt.indexOf("safari") != -1);

function CreateXmlHttpReq(handler) {

var xmlhttp = null;
if (is_ie) {
// Guaranteed to be ie5 or ie6
var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP";

try {
xmlhttp = new ActiveXObject(control);
xmlhttp.onreadystatechange = handler;
} catch (ex) {
// TODO: better help message
alert("You need to enable active scripting and activeX controls");
}

} else {

// Mozilla
xmlhttp = new XMLHttpRequest();
xmlhttp.onload = handler;
xmlhttp.onerror = handler;

}

return xmlhttp;
}

function XmlHttpPOST(xmlhttp, url, data) {
try {
xmlhttp.open("POST", url, true);
xmlhttp.send(data);

} catch (ex) {
// do nothing
}
}

// XMLHttp send GEt request
function XmlHttpGET(xmlhttp, url) {
try {
xmlhttp.open("GET", url, true);
xmlhttp.send(null);

} catch (ex) {
// do nothing
}
}

function parseResponseHeader(key, header) {

var lines = header.split("\n");
var re = new RegExp("^" + key + ":\\s");

for (var i in lines) {
if (re.exec(lines[i])) {
var returnValue = trim(RegExp.rightContext);
return returnValue;
}
}
return "";
}

function trim(value) {
var temp = value;
var obj = /^(\s*)([\W\w]*)(\b\s*$)/;
if (obj.test(temp)) {
temp = temp.replace(obj, '$2');
}
return temp;
}

function getAvailableNames(param) {
 var t_t;
 var atr;
 atr = "";
 qwe = document.s_vacancy.slova.checked;
 if(document.s_vacancy.slova.checked) atr = "`";
 t_t = document.s_vacancy.razdel_input.value;
 if(t_t.length <4) {
	if(t_t.length == 0) {
 		alert('Non hai riempito il campo Catalogo di professioni/cariche');
 	}else{
 		alert('Il campo Catalogo di professioni/cariche contiene meno di 4 caratteri');
 	}
 }else{ 	
 t_t=escape(t_t);
 if(param==0) var url = "popup/razdel/index.php?text="+t_t+"&atr="+atr;
 if(param==1) var url = "popup/razdel/index.php?sr_text="+t_t+"&atr="+atr;
myxmlhttp = CreateXmlHttpReq(CheckAvailXmlHttpHandler);
XmlHttpGET(myxmlhttp, url);

 }
}
function CheckAvailXmlHttpHandler() {

/* Ready when readystate == 4
* Success when status == 200
*/
if (myxmlhttp.readyState != 4 || myxmlhttp.status != 200) {
return;
}


var responseHeader = myxmlhttp.getAllResponseHeaders();
var nextIndex = parseResponseHeader("NextIndex", responseHeader);

document.getElementById("raz").innerHTML=myxmlhttp.responseText;

   document.getElementById("img1").src="images/next.gif";
   document.getElementById("img1").width="87";
   document.getElementById("img1").height="20";
   document.getElementById("img1").alt="Avanti";
}
function reg(elm,reg,forma) {
	var s = '';
	var pole = document.forms[forma].elements[elm];
	var len = pole.value.length;
	var error = 0;
	for(i=0;i<len;i++) {
		if(reg.test(pole.value)) {
			error = 1;
			pole.value = pole.value.substring(0,len - (i+1));
		}
	}
	if(error == 1) {
		alert('Nel campo sono presenti i caratteri scorretti. \n Presti attenzione alla lingua della tastiera.');
		pole.focus();
	}
}

function change_eng_rus(elm,reg,forma) {
	symb = new Array();
	
	//Заглавные
	symb[65] = "Ф";
	symb[66] = "И";
	symb[67] = "С";
	symb[68] = "В";
	symb[69] = "У";
	symb[70] = "А";
	symb[71] = "П";
	symb[72] = "Р";
	symb[73] = "Ш";
	symb[74] = "О";
	symb[75] = "Л";
	symb[76] = "Д";
	symb[77] = "Ь";
	symb[78] = "Т";
	symb[79] = "Щ";
	symb[80] = "З";
	symb[81] = "Й";
	symb[82] = "К";
	symb[83] = "Ы";
	symb[84] = "Е";
	symb[85] = "Г";
	symb[86] = "М";
	symb[87] = "Ц";
	symb[88] = "Ч";
	symb[89] = "Н";
	symb[90] = "Я";
	symb[126] = "Ё";
	symb[123] = "Х";
	symb[125] = "Ъ";
	symb[58] = "Ж";
	symb[34] = "Э";
	symb[60] = "Б";
	symb[62] = "Ю";
	
	//Прописные
	symb[97] = "ф";
	symb[98] = "и";
	symb[99] = "с";
	symb[100] = "в";
	symb[101] = "у";
	symb[102] = "а";
	symb[103] = "п";
	symb[104] = "р";
	symb[105] = "ш";
	symb[106] = "о";
	symb[107] = "л";
	symb[108] = "д";
	symb[109] = "ь";
	symb[110] = "т";
	symb[111] = "щ";
	symb[112] = "з";
	symb[113] = "й";
	symb[114] = "к";
	symb[115] = "ы";
	symb[116] = "е";
	symb[117] = "г";
	symb[118] = "м";
	symb[119] = "ц";
	symb[120] = "ч";
	symb[121] = "н";
	symb[122] = "я";
	symb[96] = "ё";
	symb[91] = "х";
	symb[93] = "ъ";
	symb[59] = "ж";
	symb[39] = "э";
	symb[44] = "б";
	symb[46] = "ю";
	
	//Знаки пунктуации
	symb[64] = String.fromCharCode(34);
	symb[38] = "?";
	symb[47] = ".";
	symb[63] = ",";
	symb[35] = " ";
	symb[37] = " ";
	symb[42] = " ";
	symb[43] = " ";
	symb[47] = " ";
	symb[61] = " ";
	symb[92] = " ";
	symb[94] = " ";
	symb[95] = " ";
	symb[124] = " ";
	
	var pole = document.forms[forma].elements[elm];
	var bro = navigator.appName;
	if(bro == "Microsoft Internet Explorer") {
		var key = this.event.keyCode;
		if(symb[key]) {
			this.event.keyCode = symb[key];
			document.forms[forma].elements[elm].value = pole.value + symb[key];
			var re = pole.createTextRange();
			re.collapse(false);
			re.select();
		}
	}else{
		var len = pole.value.length;
		var error = 0;
		for(i=0;i<len;i++) {
			if(reg.test(pole.value)) {
				error = 1;
				pole.value = pole.value.substring(0,len - (i+1));
			}
		}
		if(error == 1) {
			alert('Nel campo sono presenti i caratteri scorretti. \n Presti attenzione alla lingua del tastiera.');
			pole.focus();
		}
	}
}


function change_rus_eng(elm,reg,forma) {
	symb = new Array();
	
	//Заглавные
	symb[1040] = "F";
	symb[1041] = " ";
	symb[1042] = "D";
	symb[1043] = "U";
	symb[1044] = "L";
	symb[1045] = "T";
	symb[1046] = " ";
	symb[1047] = "P";
	symb[1048] = "B";
	symb[1049] = "Q";
	symb[1050] = "R";
	symb[1051] = "K";
	symb[1052] = "V";
	symb[1053] = "Y";
	symb[1054] = "J";
	symb[1055] = "G";
	symb[1056] = "H";
	symb[1057] = "C";
	symb[1058] = "N";
	symb[1059] = "E";
	symb[1060] = "A";
	symb[1061] = " ";
	symb[1062] = "W";
	symb[1063] = "X";
	symb[1064] = "I";
	symb[1065] = "O";
	symb[1066] = " ";
	symb[1067] = "S";
	symb[1068] = "M";
	symb[168] = "@";
	symb[1070] = " ";
	symb[1071] = "Z";
	
	symb[1072] = "f";
	symb[1073] = " ";
	symb[1074] = "d";
	symb[1075] = "u";
	symb[1076] = "l";
	symb[1077] = "t";
	symb[1078] = " ";
	symb[1079] = "p";
	symb[1080] = "b";
	symb[1081] = "q";
	symb[1082] = "r";
	symb[1083] = "k";
	symb[1084] = "v";
	symb[1085] = "y";
	symb[1086] = "j";
	symb[1087] = "g";
	symb[1088] = "h";
	symb[1089] = "c";
	symb[1090] = "n";
	symb[1091] = "e";
	symb[1092] = "a";
	symb[1093] = " ";
	symb[1094] = "w";
	symb[1095] = "x";
	symb[1096] = "i";
	symb[1097] = "o";
	symb[1098] = " ";
	symb[1099] = "s";
	symb[1100] = "m";
	symb[1101] = " ";
	symb[1102] = ".";
	symb[1103] = "z";
	
	//Знаки пунктуации
	symb[35] = " ";
	symb[36] = " ";
	symb[37] = " ";
	symb[38] = "&";
	symb[39] = " ";
	symb[42] = " ";
	symb[43] = " ";
	symb[46] = ".";
	symb[47] = "/";
	symb[58] = ":";
	symb[59] = " ";
	symb[60] = " ";
	symb[61] = " ";
	symb[62] = " ";
	symb[91] = " ";
	symb[92] = " ";
	symb[93] = " ";
	symb[94] = " ";
	symb[95] = "_";
	symb[96] = " ";
	symb[123] = " ";
	symb[124] = " ";
	symb[125] = " ";
	symb[126] = " ";
	symb[34] = "@";
	
	var pole = document.forms[forma].elements[elm];
	var bro = navigator.appName;


	var len = pole.value.length;
		var error = 0;
		for(i=0;i<len;i++) {
			if(reg.test(pole.value)) {
				error = 1;
				pole.value = pole.value.substring(0,len - (i+1));
			}
		}
		if(error == 1) {
			alert('Nel campo sono presenti i caratteri scorretti. \n Presti attenzione alla lingua del tastiera.');
			pole.focus();
		}
	}

function reg_area1(elm,forma,num) {	
	var pole = document.forms[forma].elements[elm];
	var pole_sym = document.forms[forma].elements[elm+'_sym'];
	var len = pole.value.length;
	var num_sym = num - pole.value.length
	pole_sym.value = num_sym;	
	if(num_sym < 0) {			
			pole.value = pole.value.substring(0,num);
			pole_sym.value = '0';
		}
}

function reg_area(elm,reg,forma,num) {
	var s = '';
	var pole = document.forms[forma].elements[elm];
	var pole_sym = document.forms[forma].elements[elm+'_sym'];
	var len = pole.value.length;
	var error = 0;
	var num_sym = num - pole.value.length
	pole_sym.value = num_sym;
	for(i=0;i<len;i++) {
		if(reg.test(pole.value)) {
			error = 1;
			pole.value = pole.value.substring(0,len - (i+1));
		}
	}
	if(num_sym < 0) {
			//pole.value = pole.value.substring(0,len - (num - num_sym));
			pole.value = pole.value.substring(0,num);
			pole_sym.value = '0';
		}
	if(error == 1) {
		alert('Nel campo sono presenti i caratteri scorretti. \nPresti attenzione alla lingua del tastiera.');
		pole.focus();
	}
}

function null_str(elm,forma,name) {
	var pole = document.forms[forma].elements[elm];
	if(pole.value == '') {
		alert('Non hai riempito il campo '+name);
		pole.focus();
	}
	if(pole.value.length < 4 && pole.value != '') {
		alert('Hai inserito meno di 4 caratteri nel campo '+name);
		pole.focus();
	}
}
//#################################################################################




function submit_form(forma) {
	
	if(forma == "s_vacancy") {
		var er = 0;
		var pole = document.forms['s_vacancy'].elements['razdel_input'];
		if(pole.value.length == 0) {
			var er = 1;
			alert('Non hai riempito il campo Catalogo di professioni/cariche');
			pole.focus();
		}
		if(pole.value.length < 4 && pole.value.length > 0 && er == 0) {
			var er = 1;
			alert('Il campo Catalogo di professioni/cariche contiene meno di 4 caratteri');
			pole.focus();
		}
		
	}
}

//#### функция сворачивания полей
function minimize(obj)
{
tr1 = window.parent.document.getElementById(obj);
if(tr1.className=="TABLE_nv")
tr1.className="TABLE_v";
else
tr1.className="TABLE_nv";
}

function profs(i){
	document.s_vacancy.prof_i.value=i;
}
function ans(text)
{
if(confirm(text)) return true
else return false;
}
function ansb(text,forma)
{
if(confirm(text)){
	document.forms[forma].check.value=1;
	document.forms[forma].submit();	
}
else return false;
}

function AllChecked(check){
	var len = document.s_vacancy.elements.length;
	for( var i=0; i < len-2; i++ ) {
		var chbox = document.s_vacancy.elements[i];
		if( chbox.type == "checkbox" && chbox.id!="slovo" && chbox.id!="full" && chbox.name!="convert_currency" && chbox.id!="seen_photo")	chbox.checked = check;
	}
}

function ShowRazdel(atr) {
 document.all.raz.value = atr;
}

function popup_region() {
 window.open("popup/region/index.php?zahod=0","","channel mode=0,toolbar=0,location=0,menubar=0,status=0,height=500,width=400,scrollbars=1,top=150,left=150");
}

function popup_region_agency() {
 window.open("popup/region_agency/index.php?zahod=0","","channel mode=0,toolbar=0,location=0,menubar=0,status=0,height=500,width=400,scrollbars=1,top=150,left=150");
}

function AddOpt(vtext,vvalue) {
// Добавляет Ooption выбранного в дочернем окне
 flink=document.forms.s_vacancy.elements.select_razdel;
 flen=flink.length;
 fcount=flen-1;
 document.forms.s_vacancy.elements.select_razdel[fcount].selected=true;
 flink.options[fcount].text=vtext;
 flink.options[fcount].value=vvalue;
 flink.options[fcount+1].text='';
 flink.options[fcount+1].value='';
}

function AddOpt1(vtext,vvalue) {
// Добавляет Ooption выбранного в дочернем окне
 document.forms.s_vacancy.elements.f_region.value=vtext;
 document.forms.s_vacancy.elements.f_region.size=vtext.length;
 document.forms.s_vacancy.elements.select_region.value=vvalue;
}

function ShowHelp(atr2) {
window.open("help/index.php?f="+atr2,"","toolbar=0,location=0,menubar=0,status=0,height=400,width=400,scrollbars=1,top=150,left=150");
}


function print_resume(pid) {	
	window.open("module/center/search_resume/print.php?pid="+pid,"","top=10,left=100,width=700,height=1000,toolbar=0,scrollbars=1,menubar=0,location=0,status=0,resizeable=0");		
}
function print_vacancy(pid) {	
	window.open("module/center/search_vacancy/print.php?pid="+pid,"","top=10,left=100,width=700,height=1000,toolbar=0,scrollbars=1,menubar=0,location=0,status=0,resizeable=0");		
}
function add_prof() {	
	window.open("popup/razdel/add_new_prof.php","","top=10,left=100,width=400,height=400,toolbar=0,scrollbars=0,menubar=0,location=0,status=0,resizeable=0");		
}

function proverka(forma) {
	var s = '';
	var pole = document.forms[forma];
	var error = 0;k=0;
    for (i=0;i<=(pole.elements.length-1);i++)
    {
         if ((pole.elements(i).checked==true) && (pole.elements(i).type!="checkbox"))
         {
         	k = 1;
         }
    }
         
         if (k == 0)
         {
         	alert("Non hai scelto nessuna professione del catalogo\nClicca \"Trovare\"\n vicino al campo \"Catalogo di professioni/cariche\"\n e scegli una professione della lista apparsa\n");
         	return false;
         }
         return true;
	}
	function proverka1(forma) {
	var s = '';
	var pole = document.forms[forma];
	var error = 0;k=0;
    for (i=0;i<=(pole.elements.length-1);i++)
    {
         if ((pole.elements(i).checked==true) && (pole.elements(i).type=="checkbox"))
         {
         	k = 1;
         }
    }
         
         if (k == 0)
         {
         	alert("Non hai scelto nessuna professione del catalogo\nClicca \"Trovare\"\n vicino al campo \"Catalogo di professioni/cariche\"\n e scegli una professione della lista apparsa\n");
         	return false;
         }
         return true;
	}
	function regp(elm,forma,num)
{    zapr = new Array();
    var s = '';
	var pole = document.forms[forma].elements[elm];
	var pole_sym = document.forms[forma].elements[elm+'_sym'];
	var len = pole.value.length;
	var error = 0;
	var str,result;
	
	var num_sym = num - pole.value.length
	pole_sym.value = num_sym;
	  str=pole.value;
      re=new RegExp ("\\%|{|}|<|>|\\?|\\*","i");
      if (result=str.match(re))

	  {
	  	pole.value = pole.value.substring(0,pole.value.length-1);
	  	alert("carattere proibito");
	  }
	
    if(num_sym < 0) {
			//pole.value = pole.value.substring(0,len - (num - num_sym));
			pole.value = pole.value.substring(0,num);
			pole_sym.value = '0';
			alert("quantità dei caratteri è oltrepassata")
		}
}

