function p_turnoff(images,selected) {
	if(!images) return true;
	var imageElements = images.split(',');
	var i=0, countElements = imageElements.length;
	for(i=0;i<countElements;i++) {
		document.getElementById(imageElements[i]).style.backgroundImage='url(/images/des.number.bg.off.png)';
		document.getElementById(imageElements[i]).style.color='#ffd2dd';
	}
	document.getElementById(selected).style.backgroundImage='url(/images/des.number.bg.on.png)';
	document.getElementById(selected).style.color='#ffabc1';
}

function p_changeimage(id,image) {
 var elementName='picture'+id;
 document.getElementById(elementName).style.backgroundImage='url('+image+')';
}

function p_setstore(id,image) {
 var elementName='pstore'+id;
 document.getElementById(elementName).value=image;
}

function p_setcurlink(id,image)	{
	var elementName='photoselected'+id;
	document.getElementById(elementName).href=image;
}

function confirmSubmit() {
	var agree=confirm("Вы уверены?");
	if (agree) return true ; else return false;
}

function checkEmail(form) {
	var notcorrect='Не указан верный email';
	var notagreed='Вы обязаны принять наше соглашение';
	if(!form.elements["profile[terms]"].checked) { alert(notagreed); form.elements["profile[terms]"].focus(); return false; }
	if(form.elements["profile[email]"].value=="") { alert(notcorrect); form.elements["profile[email]"].focus(); return false; }
	txt=form.elements["profile[email]"].value;
	if (txt.indexOf(".") == -1) { alert(notcorrect); return(false) }
	if (txt.indexOf("@") == -1) { alert(notcorrect); return(false) }
	dog = txt.indexOf("@");
	if ((dog < 1) || (dog > txt.length - 5)) { alert(notcorrect); return(false) }
	if ((txt.charAt(dog - 1) == '.') || (txt.charAt(dog + 1) == '.')) { alert(notcorrect); return (false) }
	return true;
}

