function image( filename, width, height )
{
 left_ = (screen.width - width)/2;
 top_ = (screen.height - height)/2;

 window.open('/image/?file='+filename, '', 'status=yes,menubar=no,toolbar=no,resizable=no,scrollbars=no,width='+
 width+',height='+height+', left='+left_+',top='+top_);

 return false;
}

/*
 Standards Compliant Rollover Script
 Author : Daniel Nolan
 http://www.bleedingego.co.uk/webdev.php
*/

function initRollovers() {
 if (!document.getElementById) return

 var aPreLoad = new Array();
 var sTempSrc;
 var aImages = document.getElementsByTagName('img');

 for (var i = 0; i < aImages.length; i++) {
 if (aImages[i].className == 'imgover') {
 var src = aImages[i].getAttribute('src');
 var ftype = src.substring(src.lastIndexOf('.'), src.length);
 var hsrc = src.replace(ftype, '_o'+ftype);

 aImages[i].setAttribute('hsrc', hsrc);

 aPreLoad[i] = new Image();
 aPreLoad[i].src = hsrc;

 aImages[i].onmouseover = function() {
 sTempSrc = this.getAttribute('src');
 this.setAttribute('src', this.getAttribute('hsrc'));
 }

 aImages[i].onmouseout = function() {
 if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_o'+ftype, ftype);
 this.setAttribute('src', sTempSrc);
 }
 }
 }

  if(document.vote!=null)
  {
	$("input:radio.radio-knopka", document.vote).each(function (i){

	//alert(i);

		$(this).after("<img src='"+this.src+"'  class='"+this.className+"-img' onClick='setvalue("+'"'+this.name+'1"'+","+'"'+this.value+'"'+"); reset_imgs("+'".radio-knopka-img"'+", document.vote, "+'"'+this.src+'"'+"); this.src="+'"'+$(this).attr('ssrc')+'"'+"' value='"+this.value+"'/>");
		if(i==0){$(this).after("<input type='hidden' value='' name='"+this.name+"1' id='"+this.name+"1' >")}
		//$(this).remove;
	});
	$("input:radio.radio-knopka", document.vote).remove();

    $("input:submit", document.vote).each(function (i){    	$(this).after('<div id="submit"><a href="#" onClick="if(checkForm()){document.vote.submit()}; return false;"><img src="/xhtml/images/vote.png" alt="" width="125" height="33" /></a>');
    	this.style.display="none";
    });
  }

  if(document.attach!=null)
  {    $("input:submit", document.attach).each(function (i){
    	$(this).after('<p><input type="hidden" name="subm" value="1"/><a href="javascript: if(CheckFaqForm()){document.attach.submit();} "><strong>Отправить</strong></a> <a href="javascript: if(CheckFaqForm()){document.attach.submit();} "><img src="/xhtml/images/submit_form.jpg" alt="" /></a></p>');
    	this.style.display="none";
    });
  }
}
function reset_imgs(expr, context, src)
{	$(expr, context).each(function (i){		this.src=src;
	});}
function setvalue(id, value)
{	document.getElementById(id).value=value;
}

window.onload = initRollovers;

function gogoRegion(id)
{	if(id>0)		window.location.href="/su/?id="+id;
}

function checkForm()
{	if(document.getElementById('anketa')!=null && document.getElementById('anketa').value>0)
	{		return true;
	}else
	{		if(document.getElementById('anketa1')!=null && document.getElementById('anketa1').value>0)
		{			return true;
		}else
		{			alert('Сначала нужно выбрать вариант ответа');			return false;
		}
	}
}

function isEmail(email_str)
{
 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=email_str.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;
}

function CheckFaqForm()
{
 var formobj = document.attach;
 if(formobj.fio.value.length < 3)
 {
 alert("Не введено ФИО.");
 formobj.fio.focus();
 return false;
 }
 if(!(isEmail(formobj.email.value)))
 {
 alert("Не введен корректный e-mail адрес.");
 formobj.email.focus();
 return false;
 }
 if(formobj.quest.value.length < 12)
 {
 alert("Вопросы короче 12 символов не принимаются.");
 formobj.quest.focus();
 return false;
 }
 if(formobj.abpcode.value.length != 6)
 {
 alert("На картинке 6 цифр. Введите их.");
 formobj.abpcode.focus();
 return false;
 }
 return true;
}

function reloadabpimage()
{	var imgobj=document.getElementById("abpimg");
	imgobj.src=imgobj.src+"new";
}


//  свои радиобаттоны

//$('.radio-knopka').after("<img src='/xhtml/images/radio.gif' />");





