var d=document;

anim_enabled=1;
ClassOpacity.addRule('oR1', 0.2, 1, 100);
ClassOpacity.addRule('oR2', 1, 0.2, 100);


//idtd_menu="";
sizex=8;//8;
sizey=4;//4;
count_show=0;
arraysize = sizex*sizey;
aaa = new Array(arraysize);


list_img = new Array("/img/mini/1/","/img/mini/2/","/img/mini/3/");
list_ind=0;

function select_menu_id(new_id)
{
elem1 = (document.all)?eval('document.all.'+new_id):eval('document.getElementById("'+new_id+'")');
if(elem1.className != "hide")	 elem1.className='hide';
else							 elem1.className='show';
setCookie( new_id, elem1.className, 1);
	 
}

function on_timer_set_new_img(elem_id)
{
ClassOpacity(elem_id, 'oR2');
d.getElementById(elem_id).style.backgroundImage ="url(" + list_img[list_ind] + elem_id + ".jpg)"
setTimeout("ClassOpacity('"+elem_id+"', 'oR1')",800); 
}

function ontime()
{
	for(i=0;i< 3 && count_show>-1;i++)
	{
		ind = Math.floor(Math.random()*count_show);
		setTimeout("on_timer_set_new_img('" + aaa[ind] + "')", 1);
		aaa[ind] = aaa[count_show];
		count_show--;
	}

	
	
	if(count_show<0)
		setTimeout("f()", 10000); 
	else
		setTimeout("ontime()", 100);
}


function f()
{	 


count_show = arraysize-1;
str ="";
for (x=0;x< sizex;x++)    
    for (y=0;y< sizex;y++)
		 aaa[y*sizex + x]="c_" + y + "_" + x;
		 
if(++list_ind > list_img.length-1) list_ind = 0;
if(anim_enabled)
	setTimeout("ontime()", 10);

}

function function_onload()
{
	f();
	var ind=0;
	d.FP_imgs=new Array();
	for(var k=0; k<list_img.length; k++) 
	for(var i=0; i<arraysize; i++) 
		{ d.FP_imgs[ind]=new Image; 
		  d.FP_imgs[ind].src=""+ list_img[k] + aaa[k] + ".jpg"; 
		  ind++;
		}

}

function menumouseover(elem_id)
{
document.getElementById(elem_id).src = "/img/ramka/point2.gif";
}

function menumouseout(elem_id)
{
document.getElementById(elem_id).src = "/img/ramka/point.gif";
}


function isValidEmail(email)
{
    re = /^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i;
    return re.test(email);
}


function Submit_Form_User()
{
var mess="";

var f=d.F_user;
var login=f.login.value;
var phone=f.phone.value;
var password=f.password.value;
var confirm=f.confirm.value;
var mail=f.mail.value;
var scode=f.scode.value;
var agree=f.agree.checked;
if(login=="")mess = mess + "Вы не ввели Логин;\n";

if(password=="" || password!=confirm)mess = mess + "Проверьте пароль;\n";

if(phone.substring(0,4)=='1234')mess = mess + "Вы уверены что ввели свой телефонный номер?;\n";
if(!isValidEmail(mail))mess = mess + "Не правильный Email;\n";
if(scode.length!=f.scode.size)mess = mess + "Проверьте правильность введенного кода;\n";

if(!agree)mess = mess + "Вы не приняли условия регистрации;\n";

if(mess=="")  f.submit();
else alert(mess);
}

function Submit_Form_change_Userdata()
{
var mess="";

var f=d.F_user;
var password=f.password.value;
var confirm=f.confirm.value;

if(f.oldpassword.value=="")mess = mess + "Вы не ввели старый пароль;\n";
if(password=="" || password!=confirm)mess = mess + "Проверьте новый пароль;\n";

if(mess=="")  f.submit();
else alert(mess);
}


function Submit_Form_forgot_password()
{
var mess="";

var f=document.F_forgot_password;
var login=f.login.value;
var scode=f.scode.value;
if(login=="")mess = mess + "Вы не ввели Логин;\n";
if(scode.length!=f.scode.size)mess = mess + "Проверьте правильность введенного кода;\n";

if(mess=="")  f.submit();
else alert(mess);
}


var td1, td2, td3, line_addRV=1;

function addRV(textname, textsize, textcost)
{
line_addRV=(line_addRV==1)?2:1;

    var tbody = d.getElementById('tabledescription').getElementsByTagName('TBODY')[0];
	if(tbody == undefined)
		{
		tbody = d.createElement("TBODY");
		d.getElementById('tabledescription').appendChild(tbody);
		}
    var row = d.createElement("TR");
	row.className = 'l'+line_addRV;
    tbody.appendChild(row);
	for(i=1;i<4;i++)
		{
			eval("td"+i+"=d.createElement('TD')");
			eval("row.appendChild(td"+i+");");
		}
	td1.innerHTML = textname;
    td2.innerHTML = textsize;
    td3.innerHTML = textcost;
}



function setCookie (name, value, expires, path, domain, secure) {
  
   var dtExpires = new Date();
   var dtExpiryDate = "";

   dtExpires.setTime(dtExpires.getTime() +
     expires * 24 * 60 * 60 * 1000);

   expires = dtExpires.toGMTString();


      document.cookie = name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}

function searchonfocus(elem){
 if(elem.value == 'искать...') elem.value ='';
}

function searchonblur(elem){
   if(elem.value == '') elem.value ='искать...';
}

function ltrim( source ){
    var index = 0;
    while( source.charAt(index) == " " ) index++;
    return source.substr(index);
}

function rtrim( source ){
    var index = source.length - 1;
    while( source.charAt(index) == " " ) index--;
    return source.substring(0, index + 1);
}

function trim( source ){
    return ltrim(rtrim(source));
}

function set99()
{
alert(d.getElementById('div99'));
d.getElementById('div99').style.visibility = 'visible';
}
function unset99()
{
d.getElementById('div99').style.visibility = 'hidden';
}
function printmail(name, domain, text, style){
d.write('<a href=\"mailto:'+name);
d.write('@'+domain+'\"');
if(style.length>0)
	d.write(' style="'+style+'"');
d.write('>'+text+'</a>');
}
