function getNewURI(str) {
  x=str.lastIndexOf('.');
  str=str.substr(0,x-1)+str.substr(x,255);
  return str;
}

var locked=false;
var locked2=false;
var ie=(navigator.appName=='Microsoft Internet Explorer');
var LFlag;
try {
  LFlag=Flag;
}
catch (err) {
  LFlag=0;
};

function domove(obj) {
  if (!obj) { img=event.srcElement; } else { img=obj.target; };
  str=img.src;           
  x=str.lastIndexOf('.');
  str=str.substr(0,x)+'.html';
  document.location=str;
}

function doclick(obj) {
  if (!locked) {
    if (!obj) { img=event.srcElement; } else { img=obj.target; };
    obj=document.getElementById("large");
    if (LFlag==1) {
      obj.title=img.a+' - щелкните для перехода к разделу';
      obj.style.cursor="pointer";
      obj.onclick=domove;
    } else {
      obj.title=img.a+' - щелкните для просмотра в HQ';
      obj.onclick=showbig;
    }  
    locked=true;
    document.getElementById("bp").src=getNewURI(img.src);
    if (document.getElementById("ee") != null) document.getElementById("ee").innerHTML = "Продажа образца: "+img.a;    
    blur(100);
  }
}

function showbig() {
  if (!locked2) {
  obj=document.getElementById("large");
  obj2=document.getElementById("bp");
  obj2.src="http://www.papa-karlo.net/img/kitchens/loading.png";
  str=obj.src;
  x=str.lastIndexOf('.');
  str=str.substr(0,x)+'b'+str.substr(x,255);
  obj2=document.getElementById("bp");
  obj2.src=str;
  obj2.onclick=closebig;
  obj2.title=obj.title.replace('для просмотра в HQ','чтобы закрыть');
  obj2.onmousedown=noclick;
  obj2.onmouseup=nomenu;
  obj3=document.getElementById("ct");
  obj3.innerHTML = obj.title.replace('- щелкните для просмотра в HQ',''); 
  obj=document.getElementById("fw");
  obj.style.width = '98%';
  obj.style.left = '1%';
  obj.style.height='98%';
  obj.style.top='1%';
  obj.style.visibility="visible";
  obj.style.overflow='hidden';
  locked2=true;
  slide(10);
  }
}
 
/* hide 
if (window.Event) document.captureEvents(Event.MOUSEUP); 
function nocontextmenu(){ 
event.cancelBubble = true; 
event.returnValue = false; 
return false; 
} 
function norightclick(e){ 
if (window.Event){ 
if (e.which == 2 || e.which == 3); 
return false; 
} 
else if (event.button == 2 || event.button == 3){ 
event.cancelBubble = true; 
event.returnValue = false; 
return false; 
} 
} 
document.oncontextmenu = nocontextmenu; 
document.onmousedown = norightclick; 
*/ 

function nomenu(e) {
  if (!e) { 
    if (event.button==2) { 
      event.cancelBubble = true; 
      event.returnValue = false;
    } 
  } else {
    if (e.button==2) {
      e.preventDefault();
      e.stopPropagation();
    }
  }
  return false;
}

function noclick(e) { 
  s = "Изображения юридически защищены!\nИспользование изображений с papa-karlo.net в коммерческих целях будет преследоваться по закону. В соответствии с ЗоАП предусмотрен штраф до 5000 МРОТ!";
  if (!e) { 
    if (event.button==2) { 
      event.cancelBubble = true; 
      event.returnValue = false;
      alert(s);
    } 
  } else {
    if (e.button==2) {
      e.preventDefault();
      e.stopPropagation();
      alert(s);
    }
  }
} 

function noclick2(e) { 
  s = "Щелкните левой клавишей мышки для просмотра в более высоком разрешении";
  if (!e) { 
    if (event.button==2) { 
      event.cancelBubble = true; 
      event.returnValue = false;
      alert(s);
    } 
  } else {
    if (e.button==2) {
      e.preventDefault();
      e.stopPropagation();
      alert(s);
    }
  }
} 

//document.getElementById("bp").onmousedown=noclick;

function slide(x) {
  obj=document.getElementById("fw");
/*  obj.style.width=x+'%';
  obj.style.left=(50-x/2)+'%';
  obj.style.height=x+'%';
  obj.style.top=(50-x/2)+'%'; */
  if (x<98) {
    obj.style.overflow='hidden';
    x=x+2;
    setTimeout('slide('+x+')',10);
  } else {
    locked2=false;
    obj.style.overflow='visible';
  }
}

function unslide(x,y) {
  obj=document.getElementById("fw");
  obj.style.width=x+'%';
  obj.style.left=(50-x/2)+'%';
  obj.style.height=(y)+'%';
  obj.style.top=(50-y/2)+'%';
  if (x>70) {
    x=x-2;
    y=y-1;
    setTimeout('unslide('+x+','+y+')',20);
  } else locked2=false;
  if (x<72) {
//  obj=document.getElementById("fw");
    obj.style.visibility="hidden";
//    document.getElementById("banner").style.visibility="visible";
  }
}

function closebig() {
  locked2=true;
  unslide(98,98);
}

function blur(z) {
  if (ie) document.getElementById("large").style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+z+");";
    else document.getElementById("large").style.opacity=(z/100);
  z--;
  if (z>10) z--;
  if (z>0) setTimeout('blur('+z+')',10); else {
    document.getElementById("large").src=getNewURI(img.src);
    show(0);
  }
}

function show(z) {
  if (ie) document.getElementById("large").style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+z+");";
    else document.getElementById("large").style.opacity=(z/100);
  z++;
  if (z<50) z++;
  if (z<100) setTimeout('show('+z+')',10); else locked=false; 
}

function mouseon(obj) {
  if (!obj) { 
    event.srcElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=100);"; 
  } else { 
    obj.target.style.opacity=1;
  };  
}
function mouseoff(obj) {
  if (!obj) { 
    event.srcElement.style.filter="progid:DXImageTransform.Microsoft.Alpha(opacity=60);"; 
  } else { 
    obj.target.style.opacity=0.6;
  };  
}
function gomain() {
  document.location='http://www.papa-karlo.net';
}
function fillprops() {
  if (LFlag==0) try { 
    document.getElementById('large').onclick=showbig; 
  } catch (err) {
    LFlag=1;
  };
  var imgarr=document.getElementsByTagName('img');
  var i=0; x=0;
  while (imgarr[i]) {
    obj=imgarr[i];
    if (obj.alt=='Папа Карло') {
      obj.onclick=gomain;
    }
    if (obj.className=='simg') {
      obj.onclick=doclick;
      obj.onmouseover=mouseon;
      obj.onmouseout=mouseoff;
      obj.a=obj.title;
      obj.title=obj.a+" - щелкните для просмотра";
      x++;
    }
    i++;
  }
  document.getElementById('large').onmousedown=noclick2;
  document.getElementById('large').onmouseup=nomenu;
//  cssdropdown.startchrome("chromemenu");
//  document.getElementById("inscroll").style.width=x*168+"px";
}


