may_click=true;
//show arrows
function show_arr(hide)
{
 if (hide)
  {
     if (document.getElementById('arrowr').style.display=='none') return;
  	  $('#arrowr').hide();
  	  $('#arrowl').hide();
// document.getElementById('arrowr').style.display='none';	 
// document.getElementById('arrowl').style.display='none';	 
 return;
  }
  else
 {
 	 // if (document.getElementById('video')=='')
 	      if (document.getElementById('arrowr').style.display!='none') return;
  	  $('#arrowr').show();
  	  $('#arrowl').show();
 }
}

//cursors for image\video OLD
function curs_im(e,id)
{
	return;
  if (parseInt(document.getElementById(id).offsetHeight)+169-parseInt(e.clientY)<40) 
   {
   document.getElementById(id).style.cursor='default';
   return;
   }
if (e.clientX/parseInt(document.getElementById(id).offsetWidth)<0.5)
document.getElementById(id).style.cursor='url(i/left.cur), auto';
else document.getElementById(id).style.cursor='url(i/right.cur), auto';
}
//click on image\video
function im_click(e,id)
{
//	alert(e.clientX+' '+e.clientX/(parseInt(document.getElementById(id).offsetWidth)+parseInt(document.getElementById(id).style.left)));
	//if 40 px down - not do
  if (parseInt(document.getElementById(id).offsetHeight)+169-parseInt(e.clientY)<40) return;
	//if 40 px up - not do
  if (parseInt(e.clientY)<(169+40)) return;
if ((e.clientX-parseInt(document.getElementById(id).style.left))/(parseInt(document.getElementById(id).offsetWidth))<0.5)
show_picture('-1');
else show_picture('+1');
}

function return_index(i)
{
	if (!slide_last) slide_last=0; 
if (i==='-1') i=slide_last-1;
if (i==='+1') i=slide_last+1;
if (i<0) i=slide_arr.length-1;
if (i>slide_arr.length-1) i=0;
return i;
}

function show_picture(i,povt,reali)
{
	if (may_click==false) return;
	if (document.getElementById('show_images').style.display=='none') { window.clearTimeout(my_t); return; }
   document.getElementById('border2').style.display='none';
   document.getElementById('photo').style.display='block';
   if (!slide_arr[i] || last_video!=slide_arr[i].pic)
      document.getElementById('video').innerHTML='';
 if (reali) reali=reali+'';
 else reali=i+'';
i=return_index(i);
 if (last_video!='') reali=i;
 	if (!slide_last) slide_last=0; 
var slide_temp=slide_last;
slide_last=i;
  //is video?
   if (slide_arr[i].pic.indexOf('.mp4')>=0)
   {
    document.getElementById('photo').style.display='none';
    document.getElementById('photo_effects').style.display='none';
   	window.clearTimeout(my_t);
   	img_load=new Image();
   	show_picture2(i);
   	return;   
   }
   
  if (povt && img_load.complete)
  {
var client_width=parseInt(document.body.clientWidth);
//if (document.body.offsetWidth) var client_width=parseInt($(window).width());
var client_height=parseInt(document.body.clientHeight);
//if (document.body.offsetHeight) var client_height=parseInt($(window).height());
   window.clearTimeout(my_t);
  // alert('');
document.getElementById('photo_effects').style.border='none';
document.getElementById('photo_effects').style.width=document.getElementById('photo').style.width;
document.getElementById('photo_effects').style.height=document.getElementById('photo').style.height;
document.getElementById('photo_effects').style.left=document.getElementById('photo').style.left;
document.getElementById('photo_effects').style.top=document.getElementById('photo').style.top;
document.getElementById('photo_effects').src=document.getElementById('photo').src;
document.getElementById('photo_effects').style.display='';
document.getElementById('photo').style.display='';
document.getElementById('photo').src=img_load.src;
//19.02.2012 add alt
document.getElementById('photo').alt=slide_arr[slide_last].c;
document.getElementById('border2').style.display='none';
//document.getElementById('border2').style.left=parseInt(document.getElementById('photo').style.width)+71+'px';
document.getElementById('border2').style.height=client_height-169+'px';

if (reali==='-1')
{ 
//document.getElementById('border2').style.left=(parseInt(document.getElementById('photo').offsetWidht)+71)+'px';
//document.getElementById('border2').style.width=client_width-parseInt(document.getElementById('border2').style.left)-71+'px';
document.getElementById('border2').style.display='block'; document.getElementById('border1').style.display='block';
/*  var temp=parseInt(document.getElementById('photo').style.width);
  if (parseInt(document.getElementById('photo_effects').style.width)>temp) temp=parseInt(document.getElementById('photo_effects').style.width);
temp=temp+71;
 $('#photo_effects').show();
   $('#photo_effects').animate({left:temp},750, function()
   {
   $('#photo_effects').hide();
   });*/
 }
if (reali==='+1')
{
//document.getElementById('border2').style.left=parseInt(img_load.width)+71+'px';
//document.getElementById('border2').style.width=client_width-parseInt(document.getElementById('border2').style.left)-71+'px';
document.getElementById('border2').style.display='block'; document.getElementById('border1').style.display='block';
/* if (parseInt(document.getElementById('photo').style.width)>parseInt(document.getElementById('photo_effects').style.width))
        var lefting=parseInt(document.getElementById('photo').style.width)+72;
  else  var lefting=parseInt(document.getElementById('photo_effects').style.width)+72;
//alert(lefting);
 $('#photo_effects').show();
   $('#photo_effects').animate({left: -lefting+72*2},750, function()
   {
   $('#photo_effects').hide();
   });*/
 }
 //alert(reali);
 window.clearTimeout(my_t);
   show_picture2(i,reali);   
   return;
  }
  else
  {
//   if (document.getElementById('photo').src.indexOf('loader.gif')==-1)
   if (!povt)
    {
//alert(i);
/*var client_width=parseInt(document.body.clientWidth);
var client_height=parseInt(document.body.clientHeight);
document.getElementById('photo').style.border='none';
document.getElementById('photo').style.width='16px';
document.getElementById('photo').style.height='16px';
document.getElementById('photo').style.left='50%';
document.getElementById('photo').style.top='50%';
document.getElementById('photo').src='./i/loader.gif';*/
img_load=new Image();
img_load.src=path_photos+slide_arr[i].pic;
   }
    if (!povt) show_picture(i,true,reali+'');
    else my_t=window.setTimeout('show_picture('+i+',true,"'+reali+''+'")',30);
  }
}

function show_picture2(i,reali)
{
	if (document.getElementById('show_images').style.display=='none') { window.clearTimeout(my_t); return; }
	$('#photo').stop(true,false);
	$('#photo_effects').stop(true,false);
//	show_arr(true); //hide arrows
var client_width=parseInt(document.body.clientWidth);
//if (document.body.offsetWidth) var client_width=parseInt($(window).width());
var client_height=parseInt(document.body.clientHeight);
//if (document.body.offsetHeight) var client_height=parseInt($(window).height());
var pic_h=parseInt(slide_arr[i].h);
var pic_w=parseInt(slide_arr[i].w);
//if (parseInt(pic_h)==0)
if (slide_arr[i].pic.indexOf('.mp4')==-1 
	)
{
document.getElementById('photo').style.display='block';
var pic_h=img_load.height;	
var pic_w=img_load.width;
var pic_h=parseInt(slide_arr[i].h);
var pic_w=parseInt(slide_arr[i].w);
}
if (slide_arr[i].pic.indexOf('.mp4')==-1) document.getElementById('photo').src=path_photos+slide_arr[i].pic;
$('#photo').css({opacity:0})


//var top_s=169;
//var bottom_s=71;
//var bottom_s=6;
var top_s=187;
var bottom_s=25;
var left_s=0;
var right_s=0;

var my_w=client_width-left_s-right_s;//width of area
var my_h=client_height-top_s-bottom_s;//height of area

var coef=1; //default scale
  //if (parseInt(slide_arr[i].w)>my_w) 
  var coef1=my_w/parseInt(pic_w);
  var coef2=my_h/parseInt(pic_h);
 // if (parseInt(pic_w)>my_w || parseInt(pic_h)>my_h)
  	 if (coef1<1 || coef2<1)
      {
   	 if (coef1<coef2) coef=coef1;
     else             coef=coef2;
      }
//alert(pic_w+' '+my_w);
/*
//scale to fill height
if (parseInt(pic_h)>parseInt(pic_w))
{
  var coef1=my_h/parseInt(pic_h);
  if (parseInt(pic_h)<my_h)
coef=coef1; 
}*/
//scale picture, if it necessary
document.getElementById('photo').style.width=parseInt(pic_w)*coef+'px';
document.getElementById('photo').style.height=parseInt(pic_h)*coef+'px';
//next center
var left_s=(client_width+left_s-right_s)/2-(parseInt(pic_w)*coef)/2;
var top_s=(client_height+top_s-bottom_s)/2-(parseInt(pic_h)*coef)/2;
//now position image at cen0ter

document.getElementById('photo').style.left=parseInt(left_s)+'px';



document.getElementById('photo').style.top=top_s+'px';
//arrows
 document.getElementById('arrowl').style.left=((client_width)/2-16)+'px';	 
 document.getElementById('arrowl').style.top=(top_s+parseInt(pic_h)*coef+7)+'px';	 
 // document.getElementById('arrowl').style.height=9+'px';
 // document.getElementById('arrowl').style.width=11+'px';	
 document.getElementById('arrowr').style.left=(((client_width)/2+5))+'px';	 
 document.getElementById('arrowr').style.top=(top_s+parseInt(pic_h)*coef+7)+'px';	 
 // document.getElementById('arrowr').style.height=9+'px';
//  document.getElementById('arrowr').style.width=11+'px';	
 show_arr(); //show arrows

//show border
 if (slide_arr[i].brd) 
  {
   document.getElementById('photo').style.border='1px solid #e6e6e6';
   document.getElementById('photo').style.width=parseInt(document.getElementById('photo').style.width)-1+'px';
   document.getElementById('photo').style.height=parseInt(document.getElementById('photo').style.height)-1+'px';
  // alert('');
  }
  else
  {
   document.getElementById('photo').style.border='none';
	  
  }
                   if (slide_arr[i].pic.indexOf('.mp4')<=0)
                   {
  last_video='';
  if (reali && reali==='+1')
  {
  	  	may_click=false;
  var temp=parseInt(document.getElementById('photo').style.width);
  if (parseInt(document.getElementById('photo_effects').style.width)>temp) temp=parseInt(document.getElementById('photo_effects').style.width);
  

document.getElementById('border2').style.display='block';
document.getElementById('border1').style.display='block';
 /* if (parseInt(document.getElementById('photo').style.width)>parseInt(document.getElementById('photo_effects').style.width))
        var lefting=parseInt(document.getElementById('photo').style.width)+72;
  else  var lefting=parseInt(document.getElementById('photo_effects').style.width)+72;*/
//alert(lefting);
 $('#photo_effects').show();
 /*  $('#photo_effects').animate({left: -lefting+72*2},750, function()
   {
   $('#photo_effects').hide();
   });
 */
    $('#photo_effects').animate({left: left_s-(parseInt(document.getElementById('photo_effects').style.width))},750, function()
   {
   $('#photo_effects').hide();  $('#border1').hide(); $('#border2').hide(); may_click=true;
   });
 
  
  document.getElementById('border2').style.left=temp+parseInt(document.getElementById('photo_effects').style.left)+'px';
  document.getElementById('border2').style.width=2000+'px';
  document.getElementById('border1').style.left=0+'px';
  document.getElementById('border1').style.width=left_s+'px';
 // document.getElementById('border2').style.width=client_width-parseInt(document.getElementById('border2').style.left)-71+'px';
  document.getElementById('photo').style.left=parseInt(document.getElementById('photo_effects').style.left)+parseInt(document.getElementById('photo_effects').style.width)+'px';;
  $('#photo').css({opacity:1});
  $('#photo').animate({left:left_s},750);
  return;
  }
 if (reali && reali==='-1')
  {
  	  	may_click=false;
 //   var temp=parseInt(document.getElementById('photo_effects').style.width);
 // if (parseInt(document.getElementById('photo').style.width)>temp) 
  var temp=parseInt(document.getElementById('photo').style.width);
temp=temp+left_s;
 $('#photo_effects').show();
   $('#photo_effects').animate({left:temp},750, function()
   {
   $('#photo_effects').hide();  $('#border1').hide(); $('#border2').hide(); may_click=true;
   });
  document.getElementById('border1').style.left=0+'px';
  document.getElementById('border1').style.width=left_s+'px';
  document.getElementById('border2').style.left=(parseInt(document.getElementById('photo').offsetWidth)+parseInt(document.getElementById('photo').style.left))+'px';
  document.getElementById('border2').style.width=2000+'px';
 // document.getElementById('border2').style.width=client_width-parseInt(document.getElementById('border2').style.left)-parseInt(document.getElementById('photo').style.left)+'px';
//  document.getElementById('photo').style.left=parseInt(document.getElementById('photo_effects').style.left)-parseInt(document.getElementById('photo_effects').style.width);
  document.getElementById('photo').style.left=-parseInt(document.getElementById('photo').style.width)+(my_w-parseInt(parseInt(document.getElementById('photo_effects').style.width))*coef)/2+'px';
  $('#photo').css({opacity:1});
  $('#photo').animate({left:left_s},750);
  return;
  }
//left_s=(client_width-parseInt(document.getElementById('photo').style.width)*coef)/2;
//left_s=(client_width-parseInt(slide_arr[i].w)*coef)/2;
//now position image at cen0ter
//document.getElementById('photo').style.left=(parseInt(document.body.clientWidth)-parseInt(slide_arr[i].w)*coef)/2+'px';
//if (document.body.offsetWidth) document.getElementById('photo').style.left=(parseInt($(window).width())-parseInt(slide_arr[i].w)*coef)/2+'px';
//window.setTimeout('posit_photo()',500);
$('#border1').hide();
$('#border2').hide();
$('#photo').css({opacity:0});
$('#photo').animate({opacity:1},500);

                   }
                   else //if video
                   { $('#border1').hide(); $('#border2').hide(); may_click=true;
                   	   var myl=left_s+'px';
                       var myt=top_s+'px';
                       var ua = navigator.userAgent.toLowerCase();
                       var msie = (/msie/.test(ua));
                       var macos=(/mac os/.test(ua));
                       var ff=(/firefox/.test(ua));
                       var oper=(/opera/.test(ua));
                       pic_w=parseInt(pic_w)*coef;   
                       pic_h=parseInt(pic_h)*coef;      
	document.getElementById('arrowl').style.top=(parseInt(top_s)+parseInt(pic_h)+7/*+16*/)+'px';	 
	document.getElementById('arrowr').style.top=(parseInt(top_s)+parseInt(pic_h)+7/*+16*/)+'px';	             
      if (last_video!=slide_arr[i].pic) 
      {
      	  if (msie)
          document.getElementById('video').innerHTML='<EMBED id="emb" style="position:absolute;left:'+myl+'top:'+myt+';" height='+(pic_h+16)+' type=video/mp4 pluginspage=http://www.apple.com/quicktime/download/ width='+pic_w+' src="'+path_photos+slide_arr[i].pic+'" cache="true" autoplay="true" controller="true"></EMBED>';
          else 
          	  if (/*macos &&*/ !ff && !oper)
          document.getElementById("video").innerHTML='<video onended=\'show_picture("+1")\' id="emb" autoplay="true" src="'+path_photos+slide_arr[i].pic+'" style="position:absolute;left:'+myl+'top:'+myt+';" onended=\'show_picture("+1")\' controls="" width="'+pic_w+'" height="'+(pic_h+16)+'">'
+'<source width="'+pic_w+'" height="'+(pic_h+16)+'" src="'+path_photos+slide_arr[i].pic+'"  />'
+'</video>';
          	  else
          document.getElementById("video").innerHTML='<video onended=\'show_picture("+1")\' id="emb" autoplay="true" style="position:absolute;left:'+myl+'top:'+myt+';" onended=\'show_picture("+1")\' controls="" width="'+pic_w+'" height="'+(pic_h)+'">'
+'<source width="'+pic_w+'" height="'+(pic_h)+'" src="'+path_photos+slide_arr[i].pic.replace('.mp4','.ogv')+'"  />'
+'<source  width="'+pic_w+'" height="'+(pic_h)+'" src="'+path_photos+slide_arr[i].pic+'"  />'
+'</video>';
//checkMovie(); //autochange video
      }
      else
      {
    document.getElementById('video').style.width=pic_w;
	document.getElementById('video').style.height=pic_h;
	if (document.getElementById('emb'))
	 {
	document.getElementById('emb').style.width=pic_w;
	document.getElementById('emb').style.height=pic_h;
	 }
      }
document.getElementById('video').style.left=myl;
document.getElementById('video').style.top=myt;  
last_video=slide_arr[i].pic;          	   
                   }
//preload next\prev pict
img_loadf.src=path_photos+slide_arr[return_index('+1')].pic;
img_loadb.src=path_photos+slide_arr[return_index('-1')].pic;
}


function posit_photo() //not used, may be truncared
{
var client_width=parseInt(document.body.clientWidth);
var client_height=parseInt(document.body.clientHeight);
var pic_h=parseInt(slide_arr[slide_last].h);
var pic_w=parseInt(slide_arr[slide_last].w);
var coef=1; 
var coef1=client_width/parseInt(pic_w);
var coef2=client_height/parseInt(pic_h);
  	 if (coef1<1 || coef2<1)
      {
   	 if (coef1<coef2) coef=coef1;
     else             coef=coef2;
      }
var left_s=(client_width-parseInt(pic_w)*coef)/2;
var top_s=169;
document.getElementById('photo').style.left=parseInt(left_s)+'0px';
document.getElementById('photo').style.top=top_s+'px';
}

function images_to_panel(myimages,path_thumb)
{
var s='';
  for (var i=0; i<myimages.length;i++)
   {
   if (i==myimages.length-1) break; //IE 7-8
var img_show=myimages[i].pic;
if (img_show.indexOf('.mp4')>=0) img_show=img_show.replace('.mp4','.jpg');
   s+='<img class="panel_image" style="height:54px;" onclick="show_images('+i+')"  src="'+path_thumb+img_show+'"  />';
   }
return s;
}
function generate_info()
{
document.getElementById('fade_word_1').innerHTML='JOE COMICK';
$('#intro').css({backgroundColor:'#fff'});
$('#fade_word_1').css({backgroundColor:'#fff'});
$('#fade_word_2').css({backgroundColor:'#fff'});
$('#fade_word_1').css({opacity:0});
 $('#intro').show(); 
$('#fade_word_1').animate({opacity:1},650,function() 
  {
   $('#fade_word_1').animate({opacity:0},650,function() { 
                                          document.getElementById('fade_word_1').innerHTML=''; 
                                          document.getElementById('fade_word_2').innerHTML=''; 
                                          $('#fade_word_1').css({opacity:1});
                                          $('#fade_word_2').css({opacity:1});
                                          animate_words(); });
  });
}
//animate words (for intro)
function animate_words()
{
//all hided?
  if (!document.getElementById('fade_word_2') || !document.getElementById('fade_word_1'))
   {
window.clearTimeout(timer);
return;
   }
var hided=true;
  for (var i=0; i<words.length; i++)
  { 
   if (i==words.length-1) break; //IE 7-8
   if (words[i].faded==false) 
     { 
     hide_m=i;
     hided=false;
     break;
     }
  }
  if (hided==true || hide_m==words.length) 
   { 
   $('#fade_word_1').animate({opacity:0},650);
   $('#fade_word_2').animate({opacity:0},650);
  window.setTimeout("generate_menu()",650);
     return;
   } 
   if (Math.round(hide_m/2)==hide_m/2) 
         document.getElementById('fade_word_1').innerHTML=words[hide_m].w.toUpperCase()+'&nbsp;';
   else  document.getElementById('fade_word_2').innerHTML=words[hide_m].w.toUpperCase();
   $('.fade_word_1').css({backgroundColor:'#fff'});
$('.fade_word_2').css({backgroundColor:'#fff'});
words[hide_m].faded=true;
/*
$('.fade_word'+hide_m).css({opacity:0.2,color:'#bdbec0'});
$('.fade_word'+hide_m).fadeTo(375,1,  function() { words[hide_m].faded=true;  hide_m2=hide_m;
                                             $(this).fadeTo(375,0.001,  
                                                function() {  
                                                             $('.fade_word'+hide_m2).css({backgroundColor:'#fff'}); 
   })
});*/

window.clearTimeout(timer);
timer=window.setTimeout("animate_words()",225);
}
//generate words for intro
function generate_info_last()
{
var s='';
//words for intro (cannot be hided)
/*
1-å âî 2-ì
2-å â  1-ì
3-å  â 3-ì
4-å â 4-ì


n=20
21
2
63
84
*/
var rows=1;
  for (var i=0; i<words.length; i++)
  {
 /* var y=i;
  while (y>10) y=y-10;/*
  êðàòíûå 3: 3 6 9
  4:         4 8
  2          2 10 0
  1          1 5 7
0 1 2 3
4 5 6 7
8 9 10*/
 /* var y=i+1;
  while (y>4) y=y-1;
  if (y==1) var temp=words.length*2+i-1;
  if (y==2 ||y==0) var temp=words.length+(i-1)/2;
  if (y==4) var temp=words.length*4+(i-1)/4;
  if (y==3) var temp=words.length*3+(i-1)/3;*/
  /*if (y==1 || y==5 || y==7 || y==3) var temp=words.length*2+i;
  if (y==2 || y==10 || y==0) var temp=words.length+i/2;
  if (y==4 || y==8) var temp=words.length*4+i/4;
  if ( y==6 || y==9) var temp=words.length*3+i/3;*/
  //alert(y+' '+temp);
/*
   if ((i+1)/4==Math.round((i+1)/4))
    var temp=words.length*3+(i+1)/4;
   else    
      if ((i+1)/3==Math.round((i+1)/3))
        var temp=words.length*2+(i+1)/3;
        else    
         if ((i+1)/2==Math.round((i+1)/2))
          var temp=(i+1)/2;
          else var temp=words.length+(i+1);*/
var temp= i+(rows-1)*words.length;
  //if (ost_words=='') ost_words=temp;
  //else
  if (i/2!=Math.round(i/2))
  {
   ost_words+=','+temp;
rows++;
if (rows>4) rows=1;
  }

/*
1-å âî 2-ì
2-å â  1-ì
3-å  â 3-ì
4-å â 4-ì*/
  }
 // alert(ost_words);
  //write words
var i3=0;
  for (var i2=0; i2<20; i2++)
    {
  for (var i=0; i<words.length; i++)
  {
  i3++;
  s+='<nobr><span style=\'font-size:27px;color:#bcbdc0;margin-left:4px;margin-right:4px;font-family: "Gotham_book_bold" !important;\' class="fade_word'+i+'" id="fade_word'+i3+'">'+words[i].w.toUpperCase()+'</span></nobr> ';
  all_words[i3]=false;
  }
    }
  //show_words
document.getElementById('intro').innerHTML+=s;
$('#intro').css({backgroundColor:'#fff'});
$('.fade_word').css({backgroundColor:'#fff'});
  //set opacity
  for (var i=0; i<words.length; i++)
  {
  //$('.fade_word'+i).css({opacity:0.2});
  $('.fade_word'+i).css({color:'#E7E8E9'});
  }
$('#intro').show();
}
function change_opac(id,opac)
{
$('#'+id).css({opacity:opac});	
}
//animate words (for intro)
function animate_words_last()
{
//all hided?
var hided=true;
  for (var i=0; i<words.length; i++)
  {
   if (words[i].faded==false) 
     { 
     hide_m=i;
     hided=false;
     break;
     }
  }
  if (hided==true || hide_m==words.length) 
   { window.setTimeout("generate_menu()",600);

     return;
   } 
//alert(hide_m+' '+words.length);
   //fist words not hide
$('.fade_word'+hide_m).css({backgroundColor:'#fff'});
$('.fade_word'+hide_m).css({opacity:0.2,color:'#bdbec0'});
$('.fade_word'+hide_m).fadeTo(375,1,  function() { words[hide_m].faded=true;  hide_m2=hide_m;
                                             $(this).fadeTo(375,0.001,  
                                                function() {  
                                                             $('.fade_word'+hide_m2).css({backgroundColor:'#fff'}); 
   })
});

window.clearTimeout(timer);
timer=window.setTimeout("animate_words()",375);
//all hided?
/*
var hided=true;
  for (var i=0; i<words.length; i++)
  {
   if (words[i].faded==false) 
     { 
     hided=false;
     break;
     }
  }
  if (hided)
   {
   	window.clearTimeout(timer);
    window.setTimeout("generate_menu()",600);
   }
   */
}
//show menu item
function show_item(itm)
{
$('#menuit_'+itm).animate({opacity:1},375);	
}
//generate menu items
function generate_menu()
{
var s='';
$('#menu').css({opacity:0});
$('#menu').css({display:'none'})
  for (var i=0; i<words.length-1; i++)
  {
  //menu item
  s+='<div style="width:200px" class="menu_item" id="menuit_'+i+'" onmouseover="change_m(\''+words[i+1].w.toUpperCase()+'\',\'menuit_'+i+'\',true)" onmouseout="change_m(\''+words[i].w.toUpperCase()+'\',\'menuit_'+i+'\')">'+words[i].w.toUpperCase()+'</div>';
  //images to item
  s+='<div class="menu_images">'+images_to_panel(words[i].g,words[i].p+'thumbnails/')+'</div>';
  i++;
  }
//contact
  s+='<div class="menu_item" id="menuit_cont" onclick="show_contact()" onmouseover="change_m(\'CONTACT \',\'menuit_cont\',true)" onmouseout="change_m(\'CONTACT\',\'menuit_cont\')" style="margin-top:65px;">CONTACT</div>';
document.getElementById('menu').innerHTML+=s;
$('.fade_word').css({backgroundColor:'#fff'});
$('#intro').css({backgroundColor:'#fff'});
$('#intro').animate({opacity:0},700,function() {  
$('#menu').css({display:'block'})
$('#menu').css({opacity:1});
$('.menu_item').css({opacity:0});
  for (var i=0; i<words.length-1; i++)
  {
    if (i==0) show_item('0');
    else window.setTimeout("show_item('"+i+"')",375*i/2);
  i++;
  }
  window.setTimeout("show_item('cont')",375*i/2);
//$('#menu').animate({opacity:1},700);

$('#intro').remove();
//mouse over images
$('.panel_image').css({opacity:0.3});
$('.panel_image').bind('mouseover',function(){
  $('.panel_image').css({opacity:0.3});
  $(this).css({opacity:1});
  });
//click on menu item
$(".menu_item").click(function() {
  if (!$(this).hasClass('item_act'))
  {
//set path and prepare
var i=$(this).attr('id');
if (i!='menuit_cont')
{
var re = /\d+/;  
//path_photos='./cms/data/'+words[i.match(re)].w+'/images/';
path_photos=words[i.match(re)].p+'images/';
document.getElementById('category_title').innerHTML=words[i.match(re)].w.toUpperCase()+' '+words[parseInt(i.match(re))+1].w.toUpperCase();
slide_arr=words[i.match(re)].g;
}

$('.menu_images').hide(300);
var ihave=$(this).next().hasClass("menu_images");
if (ihave) $(this).next().slideToggle(300);
   }
$('.menu_item').removeClass('item_act');
$(this).addClass('item_act');
//$('.menu_item').fadeIn(500); 
//fade out all
  for (var i=0; i<words.length-1; i++)
  {
  var temp_item='menuit_'+i;
  if (!$('#'+temp_item).hasClass('item_act'))
  {
  document.getElementById(temp_item).innerHTML=words[i].w.toUpperCase();
  document.getElementById(temp_item).style.color='#e7e8e9';
  }
    i++;
  }

                                 });
$('.menu_item').css({backgroundColor:'#fff'});
});
}
//change menu_item
function change_m(text,item,anim)
{
  if (document.getElementById(item).innerHTML==text) return;
  if (anim)
  {
$('#'+item).stop();
$('#'+item).animate({opacity:0},10,function() {
$('#'+item).animate({opacity:1},300)
document.getElementById(item).style.color='#bdbec0';
});
   }
   else
   { 
   $('#'+item).stop();
   $('#'+item).css({opacity:1})
   //fade out all
  for (var i=0; i<words.length-1; i++)
  {
  var temp_item='menuit_'+i;
  if (!$('#'+temp_item).hasClass('item_act'))
  {
  document.getElementById(temp_item).innerHTML=words[i].w.toUpperCase();
  document.getElementById(temp_item).style.color='#e7e8e9';
  }
 // s+='<div class="menu_item" id="menuit_'+i+'" onmouseover="change_m(\''+words[i+1].w.toUpperCase()+'\',\'menuit_'+i+'\',true)" onmouseout="change_m(\''+words[i].w.toUpperCase()+'\',\'menuit_'+i+'\')">'+words[i].w.toUpperCase()+'</div>';
  i++;
  }
  //and contact
  document.getElementById('menuit_cont').style.color='#e7e8e9';
  document.getElementById('menuit_cont').innerHTML='CONTACT';
  return;
//document.getElementById(item).style.color='#e7e8e9';
   }
document.getElementById(item).innerHTML=text;
}
function i_load()
{
slide_last=0;
//first generate words and initialization
generate_info();
init();
//animate_words();
/*
generate_menu();*/

}

function init()
{
	return;
var client_height=parseInt(document.body.clientHeight);
if (document.getElementById('intro'))
{
document.getElementById('intro').style.height=client_height-97-71+'px';
var temp=(parseInt(document.getElementById('intro').style.height)/32).toFixed(2)+'';
var temp2=temp.split('.');
temp=temp2;
  if (temp2[1]<15) temp=16;
   else if (temp2[1]>15 && temp2[1]<84) temp=80;
document.getElementById('intro').style.height=parseFloat(temp2[0]+'.'+temp)*32;
}
}
function show_main(hide)
{
document.getElementById('menu').style.display='block';
document.getElementById('show_images').style.display='none';
document.getElementById('icontact').style.display='none';
document.getElementById('ishow').style.display='none';
//document.getElementById('photo').style.display='none';
//document.getElementById('photo_effects').style.display='none';
$('#photo').stop();
$('#photo_effects').stop();
$('#photo').hide();
$('#photo_effects').hide();
show_arr(true);
document.getElementById('border1').style.display='none';
document.getElementById('border2').style.display='none';
document.getElementById('video').innerHTML='';
if (document.getElementById('emb')) document.getElementById('emb').innerHTML='';
	if (hide)
	{
	$('.menu_images').hide();
	  //fade out all
  for (var i=0; i<words.length-1; i++)
  {
  var temp_item='menuit_'+i;
    document.getElementById(temp_item).innerHTML=words[i].w.toUpperCase();
    document.getElementById(temp_item).style.color='#e7e8e9';
    $('#'+temp_item).removeClass('item_act');
  i++;
  }
	}
}
function show_contact()
{
document.getElementById('menu').style.display='none';
document.getElementById('show_images').style.display='block';
document.getElementById('icontact').style.display='block';
document.getElementById('category_title').innerHTML='CONTACT';
document.getElementById('ishow').style.display='none';
}
function show_images(i)
{
document.getElementById('menu').style.display='none';
document.getElementById('show_images').style.display='block';
document.getElementById('border1').style.display='block';
document.getElementById('border2').style.display='block';
document.getElementById('icontact').style.display='none';
$('#photo').css({opacity:0});
slide_last=0; 
show_picture(i);
var my_t=window.setTimeout('show_picture('+i+')');
}
