function openImage(image,title) {
	window.open("/popup/"+image+"?title="+title, "popupimage", "scrollbars=0, resizable=1, width=520, height=450").focus();
}
 
function Preload() {
	b=Preload.arguments; 
	preload_images = new Array();
	for(i=0; i<b.length; i++) {
		if (!b[i]) continue;
		preload_image = new Image;
		preload_image.src=b[i];
		preload_images[i]=preload_image;
	}
}

function changeProduct(id) {
	if (curId==id) return;
	image=document.getElementById('product_image');
	title=document.getElementById('product_title');
	text=document.getElementById('product_text');
	bfObj=document.getElementById('blendfield');
	if (isIE4) { 
		bfObj.filters[0].apply();
	}
	image.src=products[id]['src'];
	title.innerHTML=products[id]['title'];
	text.innerHTML=products[id]['text'];
	if (isIE4) {
		bfObj.filters[0].play();
	}
	curId=id;
}

function question_open(id) {
	q_div = document.getElementById('box_question'+id);
	a_div = document.getElementById('box_answer'+id);
	a_div.style.display = 'block';
	q_div.style.display = 'none';
}

function question_close(id) {
	q_div = document.getElementById('box_question'+id);
	a_div = document.getElementById('box_answer'+id);
	a_div.style.display = 'none';
	q_div.style.display = 'block';
}

function LoadFolderText(id) {
	for (i=1;i<=7 ;i++ ){
		document.getElementById('folder_'+i).src='/i/production/but'+i+'_.gif';
	}
	document.getElementById('folder_'+id).src='/i/production/but'+id+'_1.gif';
	document.getElementById('foldertext').innerHTML=foldertexts[id];
}


function ClosePopup() {
	document.getElementById('popup').style.display='none';	
}

function SendFriend() {
	html ='Ваше имя: <input type=text name=name><br>';
	html+='Email друга: <input type=text name=email><br><br>';
	html+='<input type=image src="gif/but_send.gif">';
	document.getElementById('popup').style.width='200px';
	document.getElementById('popup').style.height='101px';
	document.getElementById('popup').style.left='130px';
	document.getElementById('popup').style.top='510px';

	document.getElementById('popupcontent').innerHTML=html;
	document.getElementById('popup').style.display='block';	
}


function PostBlog() {
	html  = '<b>Разместите этот код в вашем блоге:</b><br><br>';
	html += '<textarea cols=36 rows=12>'+flashcode+'</textarea>';
	document.getElementById('popup').style.width='200px';
	document.getElementById('popup').style.height='280px';
	document.getElementById('popup').style.left='51px';
	document.getElementById('popup').style.top='440px';

	document.getElementById('popupcontent').innerHTML=html;
	document.getElementById('popup').style.display='block';	
}

function LoadPaginator() {
	if (document.getElementById('paginator3')) {
		pag3 = new Paginator("paginator3", paginator_all, paginator_view, paginator_num, paginator_dir);
	}
}

function contestmenu(o,act,cur) {
	if (cur==1) return;
	o.className='contestmenu'+act;
} 

function GetQuestion() {
	var html;
	html='<table border=0 cellpadding=0 cellspacing=0 style="margin-top:5px;">';
	html+='<tr>';
	html+='<td><img src="i/form/inp_left.gif" width="6" height="17" border="0"></td>';
	html+='<td style="background: url(i/form/inp_bg.gif)"><input class=small_blue type="text"  style="width: 153px;" name="fld[answer]"  value=""  style="border:0px; height:15px "></td>';
	html+='<td><img src="i/form/inp_right.gif" width="6" height="17" border="0"></td>';		
	html+='</tr>';
	html+='</table>';
	html2='<table border=0 cellpadding=0 cellspacing=0 style="margin-top:5px;">';
	html2+='<tr>';
	html2+='<td><img src="i/form/inp_left.gif" width="6" height="17" border="0"></td>';
	html2+='<td style="background: url(i/form/inp_bg.gif)"><input class=small_blue type="text"  style="width: 153px;" name="fld[answer2]"  value=""  style="border:0px; height:15px "></td>';
	html2+='<td><img src="i/form/inp_right.gif" width="6" height="17" border="0"></td>';		
	html2+='</tr>';
	html2+='</table>';
	html2+='<br><div style="background-color: #add3ff;"><img src="i/s.gif" width="1" height="1" border="0"></div><br>';
	cbo=document.getElementById('code_box').value;
	cbr=document.getElementById('code_brush').value;
	cbo_a=new Array('5476','5506','5698','5184','5728','3555','0346','1380');
	cbr_a=new Array('9632','9663');
	cbo_a_f=false;
	cbr_a_f=false;
	questions = Array();
	questions2 = Array();
	questions[0]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первое (1) слово во второй (2) строке первого (1) столбца.";
	questions[1]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите второе (2) слово во второй (2) строке второго (2) столбца."; 
	questions[2]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите третье (3) слово во второй (2) строчке второго (2) столбца."; 
	questions[3]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первое (1) слово в шестой (6) строчке первого (1) столбца."; 	
	questions[4]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первое (1) слово в восьмой (8) строчке первого (1) столбца.";
	questions[5]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первое (1) слово в пятой (5) строчке первого (1) столбца."; 
	questions[6]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первое (1) слово во второй (2) строчке второго (2) столбца."; 
	questions[7]="Пожалуйста, найдите на упаковке пасты штрих-код. Напишите первую (1) и пятую (5) цифру штрих - кода."; 
	questions2[0]="Пожалуйста, найдите на упаковке щетки штрих-код. Назовите четвертую (4) и пятую(5) цифру штрих-кода.";
	questions2[1]="Пожалуйста, найдите на упаковке щетки штрих-код. Напишите пятую (5) и шестую (6) цифру штрих-кода."; 
	for (key in cbo_a) {
		if (cbo.substr(0,4)==cbo_a[key]) {
			cbo_a_f=key;
			break
		}
	}
	for (key in cbr_a) {
		if (cbr.substr(0,4)==cbr_a[key]) {
			cbr_a_f=key;
			break
		}
	}
	if (cbr_a_f!==false&&cbo_a_f!==false) {
		document.getElementById('question').innerHTML='<b>Дополнительные вопросы:</b><br>'+questions[cbo_a_f]+html+questions2[cbr_a_f]+html2;
	} else {
		document.getElementById('question').innerHTML='';
	}
}

function checkAgeUser()
{
    var day, month, year;
    var date = new Date();
    
    date.setFullYear(date.getFullYear()-13);
    var str_13 = date.getFullYear()+'-'+((date.getMonth()+1)<10 ? '0'+(date.getMonth()+1) : (date.getMonth()+1))+'-'+(date.getUTCDate()<10 ? '0'+date.getUTCDate() : date.getUTCDate());
    date.setFullYear(date.getFullYear()-5);
    var str_18 = date.getFullYear()+'-'+((date.getMonth()+1)<10 ? '0'+(date.getMonth()+1) : (date.getMonth()+1))+'-'+(date.getUTCDate()<10 ? '0'+date.getUTCDate() : date.getUTCDate());

	day = document.getElementById('birth_day').value;

	month = document.getElementById('birth_month').value;

	year = document.getElementById('birth_year').value;

	if (day==''||month==''||year=='') return;
	
    var str_birth = year+'-'+(month<10 ? '0'+month : month)+'-'+(day<10 ? '0'+day : day);
    if(str_birth>str_13) {
        document.getElementById('show_age_12').style.display = 'block';
        document.getElementById('show_age_18').style.display = 'none';
    }else if(str_birth<=str_13 && str_birth>str_18) {
        document.getElementById('show_age_12').style.display = 'none';
        document.getElementById('show_age_18').style.display = 'block';
    }else if(str_birth<=str_18) {
        document.getElementById('show_age_12').style.display = 'none';
        document.getElementById('show_age_18').style.display = 'none';
    }
} 

function t_insert(t,str) {
	if (t.value=='') t.value=str;
}

function t_clear(t,str) {
	if (t.value==str) t.value='';
}

function SearchSubmit(obj,str,welcome) {
	if (obj.query.value==str) {
		alert(welcome); 
		return false;
	}
}

