function PopUp(obj,link){
	var image = document.getElementById('bigimgpopup');
	var popup = document.getElementById(obj);
	var dark = document.getElementById("dark");
	dark.style.display = "block";
	popup.style.display = "block";
	image.src = "/pics/autoshow/" + link;
}

function PopUpChildren(obj,link){
	var image = document.getElementById('bigimgpopup');
	var popup = document.getElementById(obj);
	var dark = document.getElementById("dark");
	dark.style.display = "block";
	popup.style.display = "block";
	image.src = "/pics/" + link;
}

function HidePopUp(obj){
	var image = document.getElementById('bigimgpopup');
	var popup = document.getElementById(obj);
	var dark = document.getElementById("dark");
	dark.style.display = "none";
	popup.style.display = "none";
	image.src = "/pics/i/blank.gif"
}

function Show(obj,link){
	var vis = document.getElementById(obj);
	if (vis.style.display == "none"){
		vis.style.display = "block";
		link.className = "active";
	}
	else{
		vis.style.display = "none";
		link.className = "";
	}
}
function CheckFeedback(obj){
	if (trim(obj.authname.value)=="") {alert("Укажите Ваше имя"); return false;}
	if (!emailCheck(obj.authmail.value)) {alert("Укажите корректный адрес электронной почты"); return false;}
	if (trim(obj.authtext.value)=="") {alert("Укажите текст сообщения"); return false;}
	var ai = new ajaxInit('/inc/sendmail.asp');
	var postVars = new Array();
		postVars['authname'] = obj.authname.value;
		postVars['authmail'] = obj.authmail.value;
		postVars['authtext'] = obj.authtext.value;
		postVars['authphone'] = obj.authphone.value;
	var first = new Boolean(true);
	var postStr = '';
	for (var pkey in postVars) {
		if (!first) postStr += "&";
		postStr += pkey + "=" + encodeURI(postVars[pkey]);
		first = false;
	}
	ai.sendPost(postStr);
	return false;
}
function ajaxInit(url) {
	var timeobj = document.getElementById("feedwait");
	var sendobj = document.getElementById("feedbutton");
	url += '?uniqueID=' + (new Date()).getTime();
	var req = (window.XMLHttpRequest) ? new XMLHttpRequest : new ActiveXObject("Microsoft.XMLHTTP");
	req.onreadystatechange = processRequest;
	function processRequest() {
		sendobj.style.display = "none";
		timeobj.style.display = "";
		if (req.readyState == 4)
			if (req.status == 200) {
				sendobj.style.display = "";
				timeobj.style.display = "none";
				document.forms['feedbackform'].authtext.value = "";
				HidePopUp('feedback');
			}
			else{
				alert('Ошибка, попробуйте позднее');
				sendobj.style.display = "";
				timeobj.style.display = "none";
			}
	}
	this.sendPost = function(postStr) {
		req.open("POST", url, true);
		req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
		//req.setRequestHeader("Content","text/html;charset=windows-1251");
		req.send(postStr);
	}
}
function	trim(s)
{
	return 	s.replace(/^(\s*)/,"$`").replace(/(\s*)$/,"$'");
}
function emailCheck(emailStr) 
{
	var checkTLD=1;
	var knownDomsPat=/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum)$/;
	var emailPat=/^(.+)@(.+)$/;
	var specialChars="\\(\\)><@,;:\\\\\\\"\\.\\[\\]";
	var validChars="\[^\\s" + specialChars + "\]";
	var quotedUser="(\"[^\"]*\")";
	var ipDomainPat=/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/;
	var atom=validChars + '+';
	var word="(" + atom + "|" + quotedUser + ")";
	var userPat=new RegExp("^" + word + "(\\." + word + ")*$");
	var domainPat=new RegExp("^" + atom + "(\\." + atom +")*$");
	var matchArray=emailStr.match(emailPat);
	if (matchArray==null) return false;
	var user=matchArray[1];
	var domain=matchArray[2];
	for (i=0; i<user.length; i++)	if (user.charCodeAt(i)>127) 	return false;
	for (i=0; i<domain.length; i++)	if (domain.charCodeAt(i)>127)	return false;
	if (user.match(userPat)==null) 	return false;
	var IPArray=domain.match(ipDomainPat);
	if (IPArray!=null) {	for (var i=1;i<=4;i++) if (IPArray[i]>255) return false;
		return true;
	}
	var atomPat=new RegExp("^" + atom + "$");
	var domArr=domain.split(".");
	var len=domArr.length;
	for (i=0;i<len;i++) if (domArr[i].search(atomPat)==-1)	return false;
	if (checkTLD && domArr[domArr.length-1].length!=2 &&	domArr[domArr.length-1].search(knownDomsPat)==-1)			return false;
	if (len<2)		return false;
	return true;
}
