$(document).ready(function(){
    $('.topmenu ul li').hover(
        function() {
            $(this).addClass("active");
            $(this).find('ul').show('fast');
        },
        function() {
            $(this).removeClass("active");        
            $(this).find('ul').slideUp('fast');
        }
    );
});


var fuckingie=0;
var stop=0;

var prevurl='/?ajax=1';
var prevurl0='';
var rurl='';
var rcount=0;

var curmenuurl="";
var curmenuitem=0;
var clickedmi=0;
var nn6=0;

function hide(id)
{
 var sb = document.getElementById(id);
 sb.style.display="none";
 if (id=="popup")
 {
   document.getElementById("popuppic").innerHTML="";
 }

  if (id=="shopinfo")
  document.getElementById("butn").innerHTML="<a href=\"javascript:show(\'shopinfo\')\" class=\"close\">Показать информацию о бутике</a>";

}


function show(id)
{
 var sb = document.getElementById(id);
 sb.style.display="block";
 
  if (id=="shopinfo")
  document.getElementById("butn").innerHTML="<a href=\"javascript:hide(\'shopinfo\')\" class=\"close\">Скрыть информацию о бутике</a>";
 
}


function popup(url)
{
   var x=document.getElementById("popuppic");
   x.innerHTML="<img src="+url+">";
   show("popup");
   return;
}


function movemouse(e)
{
  if (isdrag)
  {
    s=dobj.id;
    snum=s.charAt(s.length-1);
    yy  = nn6 ? ty + e.clientY - y : ty + event.clientY - y;
    
    if (snum=="1" || snum=="2" || snum=="3")
     {
      if (yy<0) { yy=0; }
      if (yy>maxscrollpos[snum]) {  yy=maxscrollpos[snum];  }
      dobj.style.top=yy+"px";
      scrollPercent(yy/maxscrollpos[snum],snum);
     }
    else
     {
      xx  = nn6 ? tx + e.clientX - x : tx + event.clientX - x;
      
     fW = document.body.clientWidth;
     fH = document.body.clientHeight;
      

     
     if (yy>=fH-dobj.offsetHeight-50) yy=fH-dobj.offsetHeight-50;
     if (xx>=fW-dobj.offsetWidth-200) xx=fW-dobj.offsetWidth-200;     
     if (xx<-100) xx=-200;
     if (yy<-50) yy=-50;

      dobj.style.top=yy+"px";    
      dobj.style.left=xx+"px";
     }  
      
    return false;
  }
}

function selectmouse(e) 
{
  var fobj       = nn6 ? e.target : event.srcElement;
  var topelement = nn6 ? "HTML" : "BODY";
  
if(fobj=="NULL")

if ( fobj.tagName != topelement && fobj.className != "dragme4" )
  {    fobj = nn6 ? fobj.parentNode : fobj.parentElement;  }

//else return false;
//while ( fobj.tagName != topelement && fobj.className != "dragme4" )
// { fobj = nn6 ? fobj.parentNode : fobj.parentElement; }

  if (fobj.className=="dragme4")
  {
    isdrag = true;
    dobj = fobj;

    tx=-10000;
    x=-10000;

    if (fobj.className=="dragme4")
    {
     tx = parseInt(dobj.style.left+0);
     x = nn6 ? e.clientX : event.clientX;
    }
  
    ty = parseInt(dobj.style.top+0);
    y = nn6 ? e.clientY : event.clientY;

    document.onmousemove=movemouse;
    return false;
  }
}

 document.onmousedown=selectmouse;
 document.onmouseup=new Function("isdrag=false");
 
 
 
 
 
 
 
 
 
 
 
 
 /* Greybox Redux
 * Required: http://jquery.com/
 * Written by: John Resig
 * Based on code by: 4mir Salihefendic (http://amix.dk)
 * License: LGPL (read more in LGPL.txt)
 */

var GB_DONE = false;
var GB_HEIGHT = 400;
var GB_WIDTH = 400;

function GB_show(caption, url, height, width) {
  GB_HEIGHT = height || 400;
  GB_WIDTH = width || 400;
  if(!GB_DONE) {
    $(document.body)
      .append("<div id='GB_overlay'></div><div id='GB_window'><div id='GB_caption'></div>"
        + "<img src='/images/litebox/close2.png' alt='Close window'/></div>");
    $("#GB_window img").click(GB_hide);
    $("#GB_overlay").click(GB_hide);
    $(window).resize(GB_position);
    GB_DONE = true;
  }

  $("#GB_frame").remove();
  $("#GB_window").append("<iframe id='GB_frame' src='"+url+"'></iframe>");

  $("#GB_caption").html(caption);
  $("#GB_overlay").show();
  GB_position();

  if(GB_ANIMATION)
    $("#GB_window").fadeIn("fast");
  else
    $("#GB_window").show();
}

function GB_hide() {
  $("#GB_window,#GB_overlay").hide();
}

function GB_position() {
  var de = document.documentElement;
  var w = self.innerWidth || (de&&de.clientWidth) || document.body.clientWidth;
  $("#GB_window").css({width:GB_WIDTH+"px",height:GB_HEIGHT+"px",
    left: ((w - GB_WIDTH)/2)+"px" });
   
     yScroll = self.pageYOffset;
    if(!yScroll) yScroll=document.documentElement.scrollTop;
   
     
     var h = $("body").height();
    // alert(document.documentElement.scrollTop);
  $("#GB_frame").css("height",GB_HEIGHT - 32 +"px");
   $("#GB_window").css("top",yScroll + 32 +"px");

}

