// Main java script

function SwapImage(id,mode) 
{
	var img = document.images[id].src;
  	if(mode==1) document.images[id].src=img.substr(0,img.length-4)+'_a.'+img.substr(img.length-3,img.length);
  	if(mode==0) document.images[id].src=img.substr(0,img.length-6)+'.'+img.substr(img.length-3,img.length);
}

function OpenWin(src, width, height, target)
{
	win=window.open(src,target,'width='+width+',height='+height+',hotkeys=1,resizable=yes,scrollbars=yes');
 	win.focus();
}

function CheckMailForm(lang)
{
	if (lang=="en"){msg1="Please, insert your email there !";msg2="Plese, write message text there !";}
	if (lang=="ru"){msg1="Укажите ваш e-mail !";msg2="Вы не ввели текст письма!";}
	if (document.mailform.mailfrom.value=="") {alert(msg1);document.mailform.mailfrom.focus();return false;}
	if (document.mailform.mailtext.value=="") {alert(msg2);document.mailform.mailtext.focus();return false;}
	return true;
}

function captchaReload()
{
    rand=Math.floor ( Math.random ( ) * 100000 + 1 );
    document.getElementById("captcha").src=document.getElementById("captcha").src+"?"+rand;
	//alert(rand);
}

function checkForm()
{
	//document.write(document.forms[0].elements[3].name);
	
	var required = new Array(
		"pol", 
		"ru_name", 
		"ru_lastname", 
		"birthday", 
		"birthmonth", 
		"country", 
		"cityString", 
		"mobile", 
		"email", 
		"height", 
		"weight", 
		"bust", 
		"waist", 
		"hips", 
		"eyecolor", 
		"haircolor", 
		"foot_size",
		"obrazovanie", 
		"defile", 
		"uchastiekonkurs", 
		"lang1", 
		"tatoo"
	);
	
	var required_show = new Array(
		"выберите пол", 
		"введите имя", 
		"введите фамилию", 
		"выберите дату рождения", 
		"выберите месяц рождения", 
		"введите страну", 
		"введите город", 
		"введите мобильный", 
		"введите Email", 
		"выберите рост", 
		"выберите вес", 
		"введите объем груди", 
		"введите объем талии", 
		"введите объем бедер", 
		"выберите цвет глаз", 
		"выберите цвет волос", 
		"введите размер обуви",
		"введите модельное или актёрское образование", 
		"выберите Ваш уровень подготовки Дефиле", 
		"введите участие в рекламных съёмках, клипах, фильмах, призовые места в конкурсах, фото в журналах", 
		"выберите язык которым владеете", 
		"введите наличие на теле татуировок, пирсинга, шрамов, ожогов"
	);
	
	var i, j;
	
	for(i=0; i<required.length; i++) 
	{
		for (j=0; j<document.forms[0].length; j++) 
		{
			if (document.forms[0].elements[j].id == required[i] && document.getElementById(required[i]).value.length == 0)
			{
				alert('Пожалуйста, ' + required_show[i]);
				document.getElementById(required[i]).focus();
				return false;
			}
		}
	}
	
	if (!document.getElementById('agree').checked)
	{
		alert('Пожалуйста, подтвердите ваше участие и введите код подтверждения');
		document.getElementById('agree').focus();
		return false;
	}
	
	return true;
}

function checkFormEn()
{
	//document.write(document.forms[0].elements[3].name);
	
	var required = new Array(
		"pol", 
		"ru_name", 
		"ru_lastname", 
		"birthday", 
		"birthmonth", 
		"country", 
		"cityString", 
		"mobile", 
		"email", 
		"height", 
		"weight", 
		"bust", 
		"waist", 
		"hips", 
		"eyecolor", 
		"haircolor", 
		"foot_size", 
		"obrazovanie", 
		"uchastiekonkurs", 
		"lang1", 
		"tatoo"
	);
	
	var required_show = new Array(
		"choose gender", 
		"enter name", 
		"enter surname", 
		"choose date birth", 
		"choose month birth", 
		"enter country", 
		"enter city", 
		"enter mob tel", 
		"enter email", 
		"choose height", 
		"choose weight", 
		"enter measurement bust", 
		"enter measurement waist", 
		"enter measurement hips", 
		"choose eyes color", 
		"choose hair color", 
		"enter shoes", 
		"enter have model's or actor's education", 
		"enter participation in advertising photography. music videos, films, prize-winning places in contests, photos in magazines", 
		"choose knowledge of foreign languages", 
		"enter presence of tatooes, piercing, scars, burns"
	);
	
	var i, j;
	
	for(i=0; i<required.length; i++) 
	{
		for (j=0; j<document.forms[0].length; j++) 
		{
			if (document.forms[0].elements[j].id == required[i] && document.getElementById(required[i]).value.length == 0) 
			{
				alert('Please, ' + required_show[i]);
				document.getElementById(required[i]).focus();
				return false;
			}
		}
	}
	
	if (!document.getElementById('agree').checked)
	{
		alert('Please, confirm your participation and enter an confirmation code');
		document.getElementById('agree').focus();
		return false;
	}
	
	return true;
}

