

 var opacity = 0;
 var im;
 var to;
 var to2;
 var interval;
 var cur_menu ;

function getrandom(min_random,max_random) {
 max_random++;
 var range = max_random - min_random;
 var n=Math.floor(Math.random()*range) + min_random;
return n;
}
function show(){
  document.getElementById(im).filters.alpha.opacity=opacity++;
  io2 = setTimeout( "show()", 50 );
  if( opacity == 100 ) {
      clearTimeout( to );
      clearTimeout( io2 );
      opacity=0;
      interval=setInterval("startshow()",3100);
  }
}
function show2(){
  document.getElementById("arrow").filters.alpha.opacity=opacity++;
  io2 = setTimeout( "show2()", 50 );
  if( opacity == 100 ) {
      clearTimeout( to );
      clearTimeout( io2 );
      opacity=0;
      interval=setInterval("showArrow()",1000);
  }
 }
function startshow(){
 var random = getrandom(4,10);
  im="im"+random;
  to = setTimeout( "show(3100)", 70 );
  clearInterval(interval);
}
function showArrow(){
  to = setTimeout( "show2()", 30 );
  clearInterval(interval);
}
function showPreview(id,idold){
  var topPos = getImageY(prv_spacer)+100;
  var leftPos = getImageX(prv_spacer)+20;
 hideLayer(idold);
 showLayer(id);
   if (document.all)
     eval ('document.all.' + id + '.style.top=topPos;document.all.' + id + '.style.left=leftPos;');
   else
     eval ('document.getElementById("'  + id + '").style.top=topPos;document.getElementById("'  + id + '").style.left=leftPos;');
 }

function mailformSubmit(){
 if (document.all){
txt=document.all.email;
form=document.all.mailform;
 }
 else{
txt=document.getElementById('email');
form=document.getElementById('mailform');

 }
if (txt.value ==  "Пишем письмо!"){
alert('Введите текст письма!');}
 else {
 if (txt.value ==  "") {
alert('Form doesn`t be empty!');}
 else {
 form.submit(); }
 }
 }

function changeFontColor(id){
 if (document.all) eval('document.all.' + id + '.style.color = "#ffffff"');
  else eval('document.getElementById("' + id + '").style.color = "#ffffff"');
}
function backFontColor(id){
 if (document.all) eval('document.all.' + id + '.style.color = "#333333"');
  else eval('document.getElementById("' + id + '").style.color = "#333333"');
}
function changeColor(id){
 if (document.all) eval('document.all.' + id + '.style.background = "#E77817"');
  else eval('document.getElementById("' + id + '").style.background = "#E77817"');
}
function backColor(id) {
 if (document.all) eval('document.all.' + id + '.style.background = "#FFFFFF"');
  else eval('document.getElementById("' + id + '").style.background = "#FFFFFF"');
}
function writeText(text,id){
 if (document.all) eval('document.all.' + id + '.innerHTML ="' + text + '"');
  else eval('document.getElementById("' + id + '").innerHTML ="' + text + '"');
}


function tableMouseOver(id){
if (id!=cur_menu){backColor('m' + cur_menu);
                  backFontColor('f' + cur_menu);
                  }
changeColor('m' + id);
writeText(names[id],'pagename');
changeFontColor('f' + id);

}
function tableMouseOut(id){
backColor('m' + id);
backFontColor('f' + id);
tableMouseOver(cur_menu)
}

function hideLayer(layerName){
 if (document.all) eval('document.all.' + layerName + '.style.visibility="hidden"');
 else eval('document.getElementById("' + layerName + '").style.visibility="hidden"');
}
function showLayer(layerName){
if (document.all) eval('document.all.' + layerName + '.style.visibility="visible"');
  else eval('document.getElementById("' + layerName + '").style.visibility="visible"');
}
function gotoTextarea (id){
   if (document.all) eval('document.all.' + id + '.value="Пишем письмо";document.all.' + id + '.focus');
  else eval('document.getElementById("' + id + '").value="Пишем письмо"');
}
function getImageX(imgElem) {
  xPos = eval(imgElem).offsetLeft;
  tempEl = eval(imgElem).offsetParent;
    while (tempEl != null) {
     xPos += tempEl.offsetLeft;
     tempEl = tempEl.offsetParent;
    }
  return xPos;
}
function getImageY(imgElem) {
   xPos = eval(imgElem).offsetTop;
   tempEl = eval(imgElem).offsetParent;
     while (tempEl != null) {
      xPos += tempEl.offsetTop;
      tempEl = tempEl.offsetParent;
     }
   return xPos;
}
function replaceLayer(id,id2){
var topPos = getImageY(id2);
var leftPos = getImageX(id2);
 if (document.all) eval ('document.all.' + id + '.style.top=topPos;document.all.' + id + '.style.left=leftPos;');
  else eval ('document.getElementById("'  + id + '").style.top=topPos;document.getElementById("'  + id + '").style.left=leftPos;');
 showLayer(id);
 hideLayer(id2)
   }
function podsvetka(pageid){
 for (i=0;i<menu_ids.length;i++){
  if (menu_ids[i]==pageid){cur_menu=i;tableMouseOver(cur_menu);}
      }
    }
function convertikClick(){
 replaceLayer('sendingform','comment');
 replaceLayer('send_button','gray_button');
 showArrow();
 if (document.all.pic1.style.visibility=="visible"){hideLayer("pic1");}
 }

function navboxMouseOver(id){
var place='comment';
 if (id==1){
  showLayer('nav1'); }
  else { hideLayer('nav1'); }

if ( typeof(idold)=="undefined" ){
  idold=0;
  }
else {
idold=id;
}
writeText("<img src="+image_dir+"/templates/kaspiko/images/previews/image" +id +".gif width=145 height=145  >",'place');
writeText(names[id+1],'pagename_text_place');
writeText(pages_text[id],'preview_text_place');
changeColor('c' + id);
if (document.all.gray_button.style.visibility=="hidden"){showLayer("gray_button");}
if (document.all.seeto.style.visibility=="visible"){replaceLayer("gray_button","seeto");}
if (document.all.sendingform.style.visibility=="visible"){
  replaceLayer('comment','sendingform');
   hideLayer('send_button');
   }
if (document.all.pic1.style.visibility=="hidden"){showLayer("pic1");}
}
function navboxMouseOut(id){
backColor('c'+id);
hideLayer('pic1');
hideLayer('gray_button');
hideLayer('seeto');
writeText('','place');
writeText('','preview_text_place');
writeText('','pagename_text_place');
}
function navboxClick(text,num){
document.all.info_table.style.border='solid 1px #E77817';
 writeText(text,'short_info');
if (see_text[num]!==''){
 if (document.all.gray_button.style.visibility=="visible"){
   replaceLayer("seeto","gray_button");
   writeText(see_text[num],'seeto_text_place');
   }
 }
}