function objPosY(obj) {
	absTop = 0;
	while (obj.offsetParent)
	   {
	   absTop += obj.offsetTop;
	   obj = obj.offsetParent;
	   }
	return absTop;
}

function httpQuery (url, data) {
	if (typeof data == 'undefined') {
	    data = '';
	}
	var xmlhttp=false
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp = false
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest()
		} catch (e) {
			xmlhttp=false
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest()
		} catch (e) {
			xmlhttp=false
		}
	}

	/*if (window.XMLHttpRequest) {
	// Mozilla/Safari
	xmlhttp=new XMLHttpRequest();
	}else if (typeof ActiveXObject != "undefined"){
	xmlhttp=new ActiveXObject
	// Internet Explorer
	("Microsoft.XMLHTTP");
	}*/
//	alert(data)
	xmlhttp.open("POST", url, true);
	xmlhttp.setRequestHeader("Content-Length", data.length);
//	xmlhttp.setRequestHeader("Content-Length", 0);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState == 4) {
			var x
			var d = document
//		alert (xmlhttp.responseText);
	        var myObject = eval('('+xmlhttp.responseText+')')
			for (x in myObject) {
	        	if ('eval' == x) {
	        		eval(myObject[x]);
	        		continue;
	        	}
	        	tel = d.getElementById(x);
	        	tel.innerHTML = myObject[x];
	        }
		}
	}
	xmlhttp.send(data);
	return true;
}
function disGender()
{
	a = document.getElementById('gender').disabled; 

	if(a == false) {
		document.getElementById('gender').disabled = true;
	} else { 
		document.getElementById('gender').disabled = false;
	}
}
function disExperience()
{
	a = document.getElementById('experience').disabled; 
	
	if(a == false) {
		document.getElementById('experience').disabled = true;
	} else { 
		document.getElementById('experience').disabled = false;
	}
}

function disAge() {
	a = document.getElementById('agemin').readOnly; 
	if(a == false) {
		document.getElementById('agemin').readOnly = true;
		document.getElementById('agemax').readOnly = true;
		document.getElementById('agemax').style.background = '#DDD';
		document.getElementById('agemin').style.background = '#DDD';
	} else { 
		document.getElementById('agemin').readOnly = false;
		document.getElementById('agemax').readOnly = false;
		document.getElementById('agemax').style.background = 'white';
		document.getElementById('agemin').style.background = 'white';
	}
}


function getPosition(obj) {
 var x=0, y=0;
 while(obj) {
    x+=obj.offsetLeft;
    y+=obj.offsetTop;
    obj=obj.offsetParent;
 }
 return {x:x, y:y};
}

function locationr(obl, cit) {
	str = obl.options[obl.selectedIndex].text;
	
	if ('2' != obl.options[obl.selectedIndex].value) {
		 str = str + ' обл.';
		if ('0' != cit.options[cit.selectedIndex].value) {
		 	str = str + ' г.' + cit.options[cit.selectedIndex].text;
		}
	}
	
	document.getElementById('select_city').innerHTML = str;
	
	
	if ('2' == obl.selectedIndex) {
		cit.style.display = 'none';
	}
}

function go() {
	go = d.getElementById('go');
	go.style.display='block';
	go.style.height = _H;
	go.className = "go";
}

function show(id_vac, el, event) {
  if(!_H) {
    alert('Дождитесь окончания загрузки страницы!');
  } else {

  	var pop = d.getElementById("pop");
  	var pop2 = d.getElementById('pop2');
  	
    pop.style.height = _H+10;
    pop.style.position = 'absolute';
    pop.style.top = 0;
    pop.style.left = 0;

    pop.style.display = 'block';
    pop2.innerHTML = '<center><br><b>Загрузка данных</b><br><br><img src="/www/img/fronted/loading.gif" border="0"></center><br>';
    pop2.style.display = 'block';

//    while(pop2.innerHTML == '');
    var top = objPosY(el);
    top = top - 100 - event.clientY;

    pop2.style.margin = top + 'px 0px 0px 0px';

    
//   alert(topb) ;
	

	if (typeof data == 'undefined') {
	    data = '';
	}
	var xmlhttp=false
	/*@cc_on @*/
	/*@if (@_jscript_version >= 5)
	 try {
	  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP")
	 } catch (e) {
	  try {
	   xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")
	  } catch (E) {
	   xmlhttp = false
	  }
	 }
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		try {
			xmlhttp = new XMLHttpRequest()
		} catch (e) {
			xmlhttp=false
		}
	}
	if (!xmlhttp && window.createRequest) {
		try {
			xmlhttp = window.createRequest()
		} catch (e) {
			xmlhttp=false
		}
	}

	/*if (window.XMLHttpRequest) {
	// Mozilla/Safari
	xmlhttp=new XMLHttpRequest();
	}else if (typeof ActiveXObject != "undefined"){
	xmlhttp=new ActiveXObject
	// Internet Explorer
	("Microsoft.XMLHTTP");
	}*/
//	alert(data)
	poss = '';
	xmlhttp.open("POST", '/ajax/vacancy/'+id_vac+'.html', true);
	xmlhttp.setRequestHeader("Content-Length", data.length);
//	xmlhttp.setRequestHeader("Content-Length", 0);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState == 4) {
			var x
			var d = document
//		alert (xmlhttp.responseText);
	        var myObject = eval('('+xmlhttp.responseText+')')

	        pop2.innerHTML = myObject;
	        	
	        	if (pop2.clientHeight+top > _H) {
		        	if (pop2.clientHeight+top+50 > _H) {
				    	pop.style.padding = '0 0 50 0';
		        	}     		
			    	pop.style.height = pop2.clientHeight+top;
			    } 
		}
	}
	xmlhttp.send(data);

	
  }
 
}

function setCookie (name, value, expires, path, domain, secure) {
      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function setSearchType(obj, type) {
	if ('cvs' == type) {
		document.search.action = '/personnel/search/result/'; 
		document.search[7].value = 'искать резюме'; 
//		document.getElementById('ls').href = '/personnel/search/'; 
		document.getElementById('searchVac').className = 'noact';
		document.getElementById('searchCvs').className = 'act';
	} else {
		document.search.action = '/job/search/result/'; 
		document.search[7].value = 'искать вакансии'; 
//		document.getElementById('ls').href = '/job/search/'; 
		document.getElementById('searchVac').className = 'act';
		document.getElementById('searchCvs').className = 'noact';
	}
	
}


d = document;

