var per_top_color;
var isIE = document.attachEvent != null;
var isGe = !document.attachEvent && document.addEventListener;
var prev_img=new Object();
var pngshechka= new Image();
pngshechka.src='../images/tlinza.png';
var pngshechka2= new Image();
pngshechka2.src='../images/linza.png';
var nowPhoto=0;
var nowBackground=0;
var nowElement=new Object();
var photos=new Array();



//defines for first page;
var ribbons=new Array();
var timers=new Array();
var fds=new Array();
var stoped=true;
var phrase_count=0;
var texts=new Array();
var slots=new Array(0,0,0);



texts[0]='Нам 14 лет. Мы знаем о сувенирах всё и хотим поделиться своим опытом с Вами';
texts[1]='Мы не ищем новинки , мы ищем новые технологии и предлагаем новинки';
texts[2]='Мы создали профессиональный инструмент – сайт с тематическими и технологическими коллекциями, просчитали оптимальные параметры и опубликовали  подробную информацию о сувенирах';
texts[3]='Мы помогаем сувенирам выполнить свою задачу – удивлять и запоминаться, мы говорим: «Нет!» банальности и скуке';
texts[4]='Мы знаем 2 секрета долголетия сувениров, как залога успеха Вашей рекламной кампании – функциональность и  оригинальность. Наши сувениры коллекционируют';
texts[5]='Мы не ограничиваем возможности бюджетом или сроками – мы предлагаем весь спектр сувениров: от отраслевых  промо-сувениров до высокохудожественных авторских изделий';
texts[6]='Мы экономим Ваши деньги – долголетние партнерские отношения с производителями, оптимальные тиражи, консолидация грузов – дешевле лучше быть не может ';
texts[7]='Наш принцип – индивидуальный подход. Вы ставите цели, мы предоставляем эффективные средства их достижения при соблюдении фирменного стиля ';
texts[8]='Высокий сервис, качество и репутация  – это не девиз, это основное правило любимой нами работы';


function setback()
{
		if(isIE)
			{
				document.getElementById('toplinz').style.backgroundColor=color;
			}
		if(isGe)
			{
				document.getElementById('toplinz').style.backgroundColor=color;
			}
}

function setlinz()
{
	var pngshechka= new Image();
	pngshechka.src='../images/tlinza.png';
	
	if(!isIE)
	{
		pngshechka.onload=setback;
		document.getElementById('toplinz').style.backgroundImage='url(../images/tlinza.png)';
		document.getElementById('linztab').style.backgroundImage='url(../images/linza.png)';
		document.getElementById('logo_png').src='../images/oasis.png';
	}
	if(isIE)
	{
		setback();
		document.getElementById('linztab').style.backgroundImage='';
		document.getElementById('linztab').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='../images/linza.png')";	
		document.getElementById('toplinz').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='../images/tlinza.png')";
		document.getElementById('logo_png').src='../images/empty1x1.gif';
		document.getElementById('logo_png').style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true, sizingMethod=scale, src='../images/oasis.png')";
	}
}

function show_div(event, id, et)
{
	
	var odj=new Object();
	obj=document.getElementById(id);
		if(obj.style.visibility!='visible')
			{
				
				per_top_color=et.style.borderBottom;
				if(window.navigator.appName=="Microsoft Internet Explorer")
					
					obj.style.top=window.event.clientY+12+'px';
					
				if(window.navigator.appName!="Microsoft Internet Explorer")
					obj.style.top=event.clientY+12+'px';
					
				obj.style.visibility='visible';
				if(id!='auth')
				et.style.borderBottom='1px dashed #FF00FF';
				if(id!='auth')
				et.innerHTML='Скрыть дополнительную информацию';
				sw(per_top_color);
			}
			else
			{
				obj.style.visibility='hidden';
				if(id!='auth')
				et.style.borderBottom='1px dashed #666666';
				if(id!='auth')
				et.innerHTML='Дополнительная информация';
			}
	
		

}

function close_div(id)
{
	var odj=new Object();
	obj=document.getElementById(id);
	obj.style.visibility='hidden';
}

function mozhide(id, et)
{
	
	var odj2=new Object();
	obj2=document.getElementById(et);
	var odj=new Object();
	obj=document.getElementById(id);
	obj.style.visibility='hidden';
	obj2.style.borderBottom='1px dashed #666666';
	
}

function sw(str)
{
	window.status=str;
}

function repaint(e, color, near)
	{
		var nobj=new Object();
		var aobj=new Object();
		var id_a=new String();
		id_a=near.substring(0, near.length-1);
		id_a+='a';
		nobj=document.getElementById(near);
		aobj=document.getElementById(id_a);
	 	e.style.background=color;
		if(color=='#ffffff')
			{
				e.style.color='#000000';
			}
		else
			{
				e.style.color='#ffffff';
			}
		nobj.style.background=color;
		if(color=='#ffffff')
			{
				nobj.style.color='#000000';
			}
		else
			{
				nobj.style.color='#ffffff';
			}
		if(aobj){
		aobj.style.background=color;
		if(color=='#ffffff')
			{
				aobj.style.color='#000000';
			}
		else
			{
				aobj.style.color='#ffffff';
			}
		}
	}
	
function ow(url, param, w, h)
{
var e; 
var posX = (screen.width - w) / 2;
var posY = (screen.height - h) / 2;
e=window.open(url+param, 'Pic', 'scrollbars=yes,width=' + w + ',height=' + h +",top=" + posY + ",left=" + posX);
if (window.focus) { e.focus(); }
}

function img_preview(id)
{
	var img=new Image();
	img=document.getElementById(id);
	var g;
	g='?src='+img.src;
	ow('./preview/',g, 450, 350);
}
var last_fild_id='im_1';

function to_img(id)
{
nowPhoto=id;
place=document.getElementById('photo_place');
place.src=photos[id];
markTumb();
}

function sver(id)
{
//var t=new Object();
//if(isIE)
//var height = (document.body.scrollHeight > document.body.offsetHeight)?document.body.scrollHeight:document.body.offsetHeight;


t=document.getElementById(id);


if(t.style.display=='none')
	{
	t.style.display='block';
	document.getElementById(id+'_s').innerHTML='(свернуть)';

	}
	else
	{
	t.style.display='none';
	document.getElementById(id+'_s').innerHTML='(развернуть)';
	
	}

if(isIE)
set_person();

if(isGe)
hide_persons();


}


function hide_persons()
{

for(var i=0; i<document.images.length; i++)
	{
		if(document.images[i].style.position=='absolute')
			{
				document.images[i].style.visibility='hidden';
			}
	}
}

function collapsMenuTable(id)
{
	try
	{
		var tab=document.getElementById('menuof_'+id);
	}
	catch(err)
	{
		return true;
	}
		
	if(tab.style.display=='block')
	{
		tab.style.display='none';
	}
	else
	{
		tab.style.display='block';
	}
	return false;
}


function nextPhoto(where)
{
nowElement=document.getElementById('photo_place');
if(photos.length<2) return false;
switch(where)
	{
	case 'left':
	moveBackgroundLeft();
	break;
	
	case 'right':
	moveBackgroundRight();
	break;
	}
}

function moveBackgroundLeft()
{
	if(nowBackground>-400)
		{
		if(nowBackground==20)
			{
			nowBackground=0;
			window.setTimeout("nowElement.style.left='0px';", 10);
			markTumb();
			return;
			}
		nowBackground-=20;
		nowElement.style.left=nowBackground+'px';
		window.setTimeout(moveBackgroundLeft, 10);
		}
		else
		{
		nowPhoto++;
		if(nowPhoto>=photos.length)nowPhoto=0;
		nowElement.style.left='500px';
		nowElement.src=photos[nowPhoto];
		nowBackground=500;
		window.setTimeout(moveBackgroundLeft, 10);
		}
}

function moveBackgroundRight()
{
	if(nowBackground<500)
		{
		if(nowBackground==-20)
			{
			nowBackground=0;
			window.setTimeout("nowElement.style.left='0px';", 10);
			markTumb();
			return;
			}		
		nowBackground+=20;
		nowElement.style.left=nowBackground+'px';
		window.setTimeout(moveBackgroundRight, 10);
		}
		else
		{
		nowPhoto--;
		if(nowPhoto<0)nowPhoto=photos.length-1;
		nowElement.style.left='-400px';
		nowElement.src=photos[nowPhoto];
		nowBackground=-400;
		window.setTimeout(moveBackgroundRight, 10);
		}
}

function markTumb()
{
	for(var i=0; i<photos.length; i++)
	{
		document.getElementById('im_'+i).style.border='1px solid #cccccc';
	}
	document.getElementById('im_'+nowPhoto).style.border='1px solid #000000';
}

//functions for first page
function register()
{
	ribbons[0]=document.getElementById('rib1');
	timers[0]=false;
	fds[0]=Math.ceil(Math.random()*10)+10;
	
	ribbons[1]=document.getElementById('rib2');
	timers[1]=false;
	fds[1]=Math.ceil(Math.random()*10)+10;
	
	ribbons[2]=document.getElementById('rib3');
	timers[2]=false;
	fds[2]=Math.ceil(Math.random()*10)+10;
}

function move(num)
{
	var cord=ribbons[num].style.top;
	var t=parseInt(cord);
	t-=15;
	if(t<=-2700) t=0;
	ribbons[num].style.top=t+'px';
	
	if(timers[num])
	{
		fds[num]++;
	}
	
	
	if((fds[num]>40)&&((t%300)/300==0))
	{
		
		var cur=parseInt(ribbons[num].style.top);
		slots[num]=-(cur/300);
		timers[num]=false;
		fds[num]=Math.ceil(Math.random()*10)+10;
	}
	else
	{	
		setTimeout("move("+num+");", fds[num]);
	}
	
}

function start()
{
	if(stoped)
	{
	document.getElementById('phrase').innerHTML=texts[phrase_count];
	phrase_count++;
	if(phrase_count==9) phrase_count=0;
	stoped=false;
	setTimeout('move(0);', Math.ceil(Math.random()*200));
	setTimeout('move(1);', Math.ceil(Math.random()*200));
	setTimeout('move(2);', Math.ceil(Math.random()*200));
	setTimeout('stop();', Math.ceil((Math.random()*200)+4000));
	//timers[0]=setInterval("move(0);", 10);
	document.getElementById('rich').src='images/rich2.jpg';
	document.getElementById('rich').style.cursor='default';
	}
}

function stop()
{
	stoped=true;
	setTimeout('timers[0]=true;', Math.ceil(Math.random()*400));
	setTimeout('timers[1]=true;', Math.ceil(Math.random()*400));
	setTimeout('timers[2]=true;', Math.ceil(Math.random()*400));
	document.getElementById('rich').src='images/rich1.jpg';
	document.getElementById('rich').style.cursor='pointer';
	
}

function goToTov(num)
{
	if((stoped)&&(slots[num]))
	{
		document.location.href='catalog/?id='+arts[num][slots[num]];	
	}
}

