var tt = new Array();

function show(id)
{
	$('#'+id).show();
	return false;
}

function openm(id)
{
	clearTimeout(tt[id]);
	$('#submenu'+id).css({overflow:''}).animate({height:'show',opacity:'show'}, 350);
}

function closem(id)
{
	clearTimeout(tt[id]);
	tt[id] = setTimeout("closemenu("+id+")", 500);
}

function closemenu(id)
{
	$('#submenu'+id+':not(:animated)').css({overflow:'hidden'}).animate({height:'hide', opacity:'hide'}, 350);
}

function isEmailCorrect(formname, fieldname) { 
	var re = /^[a-zA-Z0-9\-_](([a-z0-9\-_\.\+\&]?)+[a-z0-9])?\@((\w([a-zA-Z0-9\-_]+)?\.[a-z]{2,4})|(([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5])\.([01]?\d\d |2[0-4]\d|25[0-5])\.([01]?\d\d|2[0-4]\d|25[0-5]))|(localhost))$/i;
	if(re.test(eval("document.forms['"+formname+"']."+fieldname+".value"))) return true;
	else {
		alert("Неверно указан Email!");
		eval("document.forms['"+formname+"']."+fieldname+".focus()");
		return false; 
	} 
}

function showphoto(id)
{
	document.getElementById('main_photo').src='/img/models/big/'+id+'.jpg';
	return false;
}


function checkform()
{
	var error = '';
	if(document.getElementById('fio').value.length<4) error += 'Укажите ФИО!\n';
	if(document.getElementById('femail').value.length<6) error += 'Укажите свой e-mail адрес!\n';
	if(document.getElementById('model').value==0) error += 'Укажите модель компьютера!\n';
	if(document.getElementById('quest').value==0) error += 'Сформулируйте свой вопрос!';
	if(error != ''){ alert(error); return false; } else return true;
}

function two_selected(all)
{
	var sel = 0, pos = '';
	for(var i = 1; i <= all; i++) if(document.getElementById('comp'+i).checked){ sel += 1; pos += document.getElementById('comp'+i).value+','; }
	if(sel > 1){
		pw=open("/compare.php?ids="+pos, "compare","scrollbars=yes,resizable=no,width=920,height=720,status=no,toolbar=no,menubar=no,location=no");
		pw.focus();
	}
	return (sel > 1) ? true : false;
}

function change_models(id)
{
	var id2 = id == 'active' ? 'archive' : 'active';
	$('#'+id).addClass('models_active').removeClass('models_archive');
	$('#'+id+'_left, #'+id+'_right').hide();

	$('#'+id2).addClass('models_archive').removeClass('models_active');
	$('#'+id2+'_left, #'+id2+'_right').show();
	
	$('#'+id2+'_models').hide();
	$('#'+id+'_models').show();

	return false;
}