function getBrowserInfo() {
 var t,v = undefined;
 if (window.opera) t = 'Opera';
 else if (document.all) {
  t = 'IE';
  var nv = navigator.appVersion;
  var s = nv.indexOf('MSIE')+5;
  v = nv.substring(s,s+1);
 }
 else if (window.sidebar) t = 'Netscape';
 return {type:t,version:v};
}
function isNotMax(e,div){
	e = e || window.event;
	var target = e.target || e.srcElement;
	var code=e.keyCode?e.keyCode:(e.which?e.which:e.charCode)
	if(target.value.length > target.getAttribute('maxlength')) target.value=target.value.substr(0,target.getAttribute('maxlength'))
	document.getElementById(div).innerHTML=target.value.length;
	return target.value.length <= target.getAttribute('maxlength');
}
function bookmark(a){
// var id_connection=document.getElementById('code_connection_user').value;
 var url = window.document.location;
 var title = window.document.title;
 var b = getBrowserInfo();
 if (b.type == 'IE') window.external.AddFavorite(url,title);
 else if (b.type == 'Opera') {
  a.href = url;
  a.rel = "sidebar";
  a.title = title;
  return true;
 }
 else if (b.type == "Netscape") window.sidebar.addPanel(title,url,"");
 else alert("Нажмите CTRL-D, чтобы добавить страницу в закладки.");
// SM1(id_connection,'addfav');
 return false;
}

function ShowDiv(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.display='block';
}
function HideDiv(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.display='none';
}
function Visible(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.visibility='visible';
}
function UnVisible(div)
{
if(document.getElementById(div)!=null)
document.getElementById(div).style.visibility='hidden';
}
function ShowHideDiv(div)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).style.display!='block')
document.getElementById(div).style.display='block';
else
document.getElementById(div).style.display='none';
}
function ShowHideDesc(div,link)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).style.display!='block')
{document.getElementById(div).style.display='block';
document.getElementById(link).className="showdeschover";}
else
{document.getElementById(div).style.display='none';
document.getElementById(link).className="showdesc";}
}
function ShowHideDesc1(div,link)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).style.display!='block')
{document.getElementById(div).style.display='block';
document.getElementById(link).className="showdeschover1";}
else
{document.getElementById(div).style.display='none';
document.getElementById(link).className="showdesc1";}
}
function SelectCat(id,page)
{
for(i=0;i<9;i++)
if(document.getElementById("divcat"+i)!=null && document.getElementById("linkcat"+i)!=null)
{
	document.getElementById("linkcat"+i).style.color='#2b619e';
	document.getElementById("divcat"+i).className="category";
}
if(document.getElementById("divcat"+id)!=null && document.getElementById("linkcat"+id)!=null)
{
	document.getElementById("linkcat"+id).style.color='#f58022';
	document.getElementById("divcat"+id).className="categoryhover";
	SendToServer(1+'|'+4+'|'+id,'showgoods','prodlist');
}
}
function SelectPage(id,page)
{
for(i=0;i<=document.getElementById('maxpage').value;i++)
if(document.getElementById("page"+i)!=null)
{
	document.getElementById("page"+i).className="noselpage";
}
if(document.getElementById("page"+page)!=null)
{
	document.getElementById("page"+page).className="selpage";
	SendToServer(page+'|'+4+'|'+id,'showgoods','prodlist');
}
}

function HoverProduct(id)
{
	Visible("link"+id);
	if(document.getElementById("product"+id)!=null)
	{
		document.getElementById("product"+id).className="hover";
	}
}

function unHoverProduct(id)
{
	UnVisible("link"+id);
	if(document.getElementById("product"+id)!=null)
	{
		document.getElementById("product"+id).className="";
	}
}
function HoverCatalog(id)
{
	document.getElementById("td"+id).style.background="#e4e6e8";
	document.getElementById("div"+id).style.backgroundPosition="-240px center";
}

function unHoverCatalog(id)
{
	document.getElementById("td"+id).style.background="transparent";
	document.getElementById("div"+id).style.backgroundPosition="0px center";
}

function Showmenu(id)
{
	//ShowDiv("mark"+id);
	if(document.getElementById("menu"+id)!=null)
	{
		document.getElementById("menu"+id).className="hover";
	}
}

function Hidemenu(id)
{
	//HideDiv("mark"+id);
	if(document.getElementById("menu"+id)!=null)
	{
		document.getElementById("menu"+id).className="";
	}
}
function testmessage()
{
document.getElementById('stop').value=1;
//alert(document.getElementById('stop').value)
}
function testmessage1()
{
document.getElementById('stop1').value=1;
//alert(document.getElementById('stop').value)
}
function SendBlank(f,i,o,phone,text)
{
	var feedback=true;
	//var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	
	var textf=document.getElementById(f).value;
	var texti=document.getElementById(i).value;
	var texto=document.getElementById(o).value;
	var textphone=document.getElementById(phone).value;
	var texttext=document.getElementById(text).value;	
	if(textphone==="") {feedback=false;pole=phone;}
	if(texto==="") {feedback=false;pole=o;}
	if(texti==="") {feedback=false;pole=i;}
	if(textf==="") {feedback=false;pole=f;}
	if(feedback==true)
	{
		SendToServer(textf+'|'+texti+'|'+texto+'|'+textphone+'|'+texttext,"manager",'ansmanager');
		document.getElementById(f).value="";
		document.getElementById(i).value="";
		document.getElementById(o).value="";
		document.getElementById(phone).value="";
		document.getElementById(text).value="";		
		setTimeout('HideDiv("manager")',2500);
		HideDiv("mess");ShowDiv("ansmanager");
	}
	else
	{
		document.getElementById('stop1').value=0;
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
}
function SendToServer(keyword,table,div)
{
	var req;
	var sss;
	if (window.XMLHttpRequest)
	{
		req=new XMLHttpRequest();
	}
	else if (window.ActiveXObject)
	{
		try	{req=new ActiveXObject('MSXML2.XMLHTTP.3.0');}
		catch(e){}
	}
	if(req)
	{
		req.open("post","/ajax.php",true);
		req.setRequestHeader("Content-Type"," application/x-www-form-urlencoded;");
		req.onreadystatechange=function()
		{
	   	 if (req.readyState==4 && req.status==200)
	    	{
	    		sss=req.responseText;
				if(div!="empty"){
				document.getElementById(div).style.display='block';
				document.getElementById(div).innerHTML=sss;}
	    	}
		}
		req.send('keyword='+table+'|'+encodeURIComponent(keyword));
	}
}
function SendLetter(fio,mail,text,razdel)
{
	var feedback=true;
	var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	
	var fiotext=document.getElementById(fio).value;
	var mailtext=document.getElementById(mail).value;
	var texttext=document.getElementById(text).value;
	if(texttext==="") {feedback=false;pole=text;}
	if(mailtext==="" || !re2.test(mailtext)) {feedback=false;pole=mail;}
	if(fiotext==="") {feedback=false;pole=fio;}
	if(feedback==true)
	{
		document.getElementById(fio).value="";
		document.getElementById(mail).value="";
		document.getElementById(text).value="";
		SendToServer(fiotext+'|'+mailtext+'|'+texttext,razdel,'ifsend');
		//setTimeout('HideLetter()',2500);		
	}
	else
	{
		document.getElementById('stop').value=0;
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
}
function Hilight(pole)
{
	if(document.getElementById('stop').value!=1)
	//alert(document.getElementById('stop').value)
	setTimeout("Light('"+pole+"')",1000);
}
function Light(pole)
{	
	if(document.getElementById('stop').value!=1)
	$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal',complete:Hilight(pole)});
}
function Hilight1(pole)
{
	if(document.getElementById('stop1').value!=1)
	//alert(document.getElementById('stop').value)
	setTimeout("Light1('"+pole+"')",1000);
}
function Light1(pole)
{	
	if(document.getElementById('stop1').value!=1)
	$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal',complete:Hilight1(pole)});
}
function HideLetter()
{
document.getElementById("ifsend").innerHTML="";
HideDiv("ifsend");
}
function ShowFormResume(id,v)
{
		HideFormResume()
		ShowDiv('insresume'+v);
		HideDiv('hrefresume'+v);
		document.getElementById('insresume'+v).innerHTML=
		"<div id=answer><table class=resume cellpadding=0 cellspacing=0>"+
		"<tr><th width=150px>Фамилия Имя</th><th width=150px>Электронная почта</th><th width=185px>Резюме (.doc, до 1 Mb)</th><th width=100px></th></tr>"+
		"<tr height=23px><td><input id=lastname type=text></td><td><input id=txtemail type=text></td>"+
		"<td id=ffff><input type=text id=txtFileName disabled=true style='display:none;'><div class=flash id=fsUploadProgress style='display:none'></div>"+
		"<span id=spanButtonPlaceholder></span></td><td><button class=sendresume type='button' id='btnSubmit'>Отправить</button></td></tr>"+
		"<tr class=ans height=20px><td id=oklastname></td><td id=oktxtemail></td><td id=oktxtFileName style='color:red'></td><td></td></tr>"+		
		"</table>"+
		"<input type=hidden id=hidFileID value=''>"+
		"<input type=hidden id=code_vacancy value=0>"+
		"</div>";
		document.getElementById('code_vacancy').value=id;
		ActivResume();
	//ShowDivCenter1("content");
	//if(window.screen.width>1000)document.body.style.overflowX="hidden";
}
function ShowFormAnketa(id,v)
{
		HideFormResume();
		ShowDiv('insresume'+v);
		HideDiv('hrefresume'+v);
		document.getElementById('insresume'+v).innerHTML=
		"<div id=ans>"+document.getElementById("vacancylist").innerHTML;
		"</div>";
		document.getElementById('code_vacancy').value=id;
}
function HideFormResume()
{
	for(i=1;i<=document.getElementById('maxvacancy').value;i++)
	{
		document.getElementById('insresume'+i).innerHTML="";
		ShowDiv('hrefresume'+i);
		HideDiv('insresume'+i);
		
	}
}

function SendResumeA()
{
var feedback=1;
var re1=/^[0-9]+\/[0-9]+\/[0-9]{2}$/;	
var re3=/^[0-9\-]/;	
var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	
var fio_vacancy=document.getElementById('fio_vacancy').value;
var id_vacancy=document.getElementById('code_vacancy').value;
var date_vacancy=document.getElementById('date_vacancy').value;
var place_vacancy=document.getElementById('place_vacancy').value;
var phone_vacancy=document.getElementById('phone_vacancy').value;
var mail_vacancy=document.getElementById('mail_vacancy').value;
var adr_vacancy=document.getElementById('adr_vacancy').value;
var school_vacancy=document.getElementById('school_vacancy').value;
var opyt_vacancy=document.getElementById('opyt_vacancy').value;
var nav_vacancy=document.getElementById('nav_vacancy').value;
var lic_vacancy=document.getElementById('lic_vacancy').value;
var am,pb,k;
if(document.getElementById("cat1").className=="seldm") am=1;else am=0;
if(document.getElementById("cat2").className=="seldm") pb=1;else pb=0;
if(document.getElementById("camcat1").className=="selcat") k=1;else k=0;
if(lic_vacancy==""){pole="lic_vacancy";feedback=0;}
if(nav_vacancy==""){pole="nav_vacancy";feedback=0;}
if(opyt_vacancy==""){pole="opyt_vacancy";feedback=0;}
if(school_vacancy==""){pole="school_vacancy";feedback=0;}
if(adr_vacancy==""){pole="adr_vacancy";feedback=0;}
if(mail_vacancy=="" || !re2.test(mail_vacancy)){pole="mail_vacancy";feedback=0;}
if(phone_vacancy=="" || !re3.test(phone_vacancy)){pole="phone_vacancy";feedback=0;}
if(place_vacancy=="" ){pole="place_vacancy";feedback=0;}
if(date_vacancy=="" || !re1.test(date_vacancy)){pole="date_vacancy";feedback=0;}
if(fio_vacancy==""){pole="fio_vacancy";feedback=0;}
	if(feedback==0)
	{
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
	else
	{
		SendToServer(id_vacancy+'|'+fio_vacancy+'|'+date_vacancy+'|'+place_vacancy+'|'+phone_vacancy+'|'+mail_vacancy+'|'+adr_vacancy+'|'+school_vacancy+'|'+opyt_vacancy+'|'+nav_vacancy+'|'+lic_vacancy+'|'+am+'|'+pb+'|'+k,"resume",'ans');
			setTimeout('HideFormResume()',3500);
	}

}

function SetClass(div)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).className!="txtfocus")
document.getElementById(div).className='txthover';

}
function Testinput(div)
{
//if(document.getElementById(div)!=null)
if(document.getElementById(div).value=="Адрес электронной почты")
{document.getElementById(div).value='';}

}
function unSetClass(div)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).className!="txtfocus")
document.getElementById(div).className='txt';
}
function testvalue(div)
{
	var re1=/^[0-9]+$/;
	var width=document.getElementById(div).value;
	if(!re1.test(width) || parseInt(width)>2049 || parseInt(width)<400){$("#"+div).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});}
}
function setvalue(idparam,idvalue,valueparam)
{
	document.getElementById('valuecat'+idparam).value=valueparam;
	document.getElementById('nvaluecat'+idparam).value=idvalue;
	var v=document.getElementById('param'+idvalue).innerHTML;
	document.getElementById('cat'+idparam).innerHTML=v.substring(0,33);
	HideDiv("list"+idparam);
	SetNewPrice();HideDiv("bg");
}

function SelDM(div)
{
if(document.getElementById(div)!=null)
if(document.getElementById(div).className!='seldm')
document.getElementById(div).className='seldm';
else
document.getElementById(div).className='noseldm';
SetNewPrice()
}
function SelCam(div)
{
document.getElementById("camcat1").className='noselcat'
document.getElementById("camcat2").className='noselcat'
if(document.getElementById("camcat"+div)!=null)
document.getElementById("camcat"+div).className='selcat'
SetNewPrice()
}
function SetBg()
{
	var arrayPageSize = getPageSize(); 
	var arrayPageScroll = getPageScroll();
	document.getElementById('bg').style.height=arrayPageSize[1]-20+'px';
	document.getElementById('bg').style.width=arrayPageSize[0]-20+'px';
}

function SetNewPrice()
{
	var re1=/^[0-9]+$/;
	var feedback=1;
    var cat1=0;var cat2=0;var cat3=0;var cat8=0;var cat4=0;var cat5=0;var cat6=0;var cat7=0;	
	var typecat=document.getElementById("typecatalog").value;
	var width=document.getElementById("widthcat").value;
	var height=document.getElementById("heightcat").value;
	var countcat=document.getElementById("countcat").value;
	if(!re1.test(width)){feedback=0;pole="widthcat";}
	if(parseInt(width)>2049 || parseInt(width)<400){feedback=2;}
	if(parseInt(height)>2049 || parseInt(height)<400){feedback=2;}
	if(!re1.test(height)){feedback=0;pole="heightcat";}
	if(!re1.test(countcat)){feedback=0;pole="countcat";}
	if(feedback==0)
	{
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
	else if(feedback==2){}
	else
	{
	if(countcat=="")countcat=0;else countcat=parseInt(countcat);	
	if(height=="")height=0;else height=parseInt(height);	
	if(width=="")width=0;else width=parseInt(width);
	if(document.getElementById('camcat1').className=="selcat")
	{cat8=parseInt(document.getElementById("camvalue1").value);ncat8=1;}
	else {cat8=parseInt(document.getElementById("camvalue2").value);ncat8=2;}
	if(document.getElementById("cat1").className=="seldm")
	cat1=parseInt(document.getElementById("cat1value").value);
	else cat1=0;
	if(document.getElementById("cat2").className=="seldm")
	cat2=parseInt(document.getElementById("cat2value").value);
	else cat2=0;
	cat7=parseInt(document.getElementById("valuecat7").value);
	cat6=parseInt(document.getElementById("valuecat6").value);
	cat5=parseInt(document.getElementById("valuecat5").value);
	cat4=parseInt(document.getElementById("valuecat4").value);
	cat3=parseInt(document.getElementById("valuecat3").value);
	ncat7=parseInt(document.getElementById("nvaluecat7").value);
	ncat6=parseInt(document.getElementById("nvaluecat6").value);
	ncat5=parseInt(document.getElementById("nvaluecat5").value);
	ncat4=parseInt(document.getElementById("nvaluecat4").value);
	ncat3=parseInt(document.getElementById("nvaluecat3").value);
	
	var price=(((2*(width+height)*cat7/1000)+(width*height*cat8/1000000))*1.1+cat1+cat2+cat3+cat4+cat5+cat6)*countcat;
	document.getElementById("price").innerHTML=parseInt(price)+" рублей";
	document.getElementById("pricelast").innerHTML=parseInt(price*0.85)+" рублей";
	document.getElementById("print").href="/print.php?id="+typecat+"&w="+width+"&h="+height+"&c="+countcat+"&p="+ncat8+"&p3="+ncat3+"&p4="+ncat4+"&p5="+ncat5+"&p6="+ncat6+"&p7="+ncat7+"&p1="+cat1+"&p2="+cat2;
	}
}

function SendPrice()
{	
	var re1=/^[0-9]+$/;
	var re2=/^[0-9a-zA-Z\-_]+@[0-9a-zA-Z\-_\.]+\.[a-zA-Z]{2,3}$/;	
	var feedback=1;
    var cat1=0;var cat2=0;var cat3=0;var cat8=0;var cat4=0;var cat5=0;var cat6=0;var cat7=0;	
	mailtext=document.getElementById("mailsend").value;
	if(mailtext==="" || !re2.test(mailtext)) {feedback=0;pole="mailsend";}
	if(feedback==0)
	{
		$("#"+pole).highlightFade({color:'#b7162c',speed:1000,iterator:'sinusoidal'});
	}
	else
	{	
	var typecat=document.getElementById("typecatalog").value;
	var width=parseInt(document.getElementById("widthcat").value);
	var height=parseInt(document.getElementById("heightcat").value);
	var countcat=parseInt(document.getElementById("countcat").value);
	if(document.getElementById('camcat1').className=="selcat")
	{ncat8=1;}
	else {ncat8=2;}
	if(document.getElementById("cat1").className=="seldm")
	cat1=parseInt(document.getElementById("cat1value").value);
	else cat1=0;
	if(document.getElementById("cat2").className=="seldm")
	cat2=parseInt(document.getElementById("cat2value").value);
	else cat2=0;
	ncat7=parseInt(document.getElementById("nvaluecat7").value);
	ncat6=parseInt(document.getElementById("nvaluecat6").value);
	ncat5=parseInt(document.getElementById("nvaluecat5").value);
	ncat4=parseInt(document.getElementById("nvaluecat4").value);
	ncat3=parseInt(document.getElementById("nvaluecat3").value);
	SendToServer(mailtext+"|"+typecat+"&"+width+"&"+height+"&"+countcat+"&"+ncat8+"&"+ncat3+"&"+ncat4+"&"+ncat5+"&"+ncat6+"&"+ncat7+"&"+cat1+"&"+cat2,'print',"anssendcalk");
	HideDiv('sendcalk');
	ShowDiv('anssendcalk');
	setTimeout("HideDiv('anssendcalk')",3000)
	}
}
