/* 
	(c) 2007, Mediaweb Studio 
*/


function get_browser()
{
var bver=null;
if(document.layers)
{bver='nn4';
}
else if(document.all)
{
if(window.opera)
  {bver='opera';
  }
else
  {bver='ie4';
  }
}
else if(document.getElementById)
{
if(navigator.userAgent.indexOf('gecko')>-1)
  {bver='mozilla';
  }
else
  {bver='nn6';
  }
}
if((window.opera)&&((navigator.appVersion.indexOf('MSIE 5.0')>-1)||(parseInt(navigator.appVersion)==6)))
{
bver='opera6';
}
return bver;
}


function replace_tags(STR,STR1,STR2)
{
var rexp,S;
S=STR;
rexp=new RegExp(STR1,"gi");
S=S.replace(rexp,STR2);
return S;
}


function preloadImg(file) {
  img = new Image();
  img.src = file;
}


function change_image(elname, srcname) {
if (srcname=='1') {
  elname.src=replace_tags(elname.src,'\.gif','_over.gif');
}
else {
  elname.src=replace_tags(elname.src,'_over.gif','\.gif');
}
}


function change_image(elname, srcname) {
if (srcname=='1') {
  elname.src=replace_tags(elname.src,'\.gif','_over.gif');
}
else {
  elname.src=replace_tags(elname.src,'_over.gif','\.gif');
}
}

function NewWindow(w,v,s,d)
{
var w_top=screen.height/2;
var w_left=screen.width/2;
if(s>0)
{
w_top=w_top-s/2;
}
if(d>0)
{
w_left=w_left-d/2;
}
eval("window.open('"+v+"','"+w+"','height="+s+",width="+d+",top="+w_top+",left="+w_left+"status=no,location=no,toolbar=no,directories=no,menubar=no,scrollbars=0');");
} 


function SWFobj(file,width,height,wmode){
  var swf = '<object type="application/x-shockwave-flash" data="'+file+'" height="'+height+'" width="'+width+'">'
  +'  <param name="movie" value="'+file+'">'
  +'  <param name="wmode" value="'+wmode+'">'
  +'  Установите <a href="http://get.adobe.com/flashplayer/" target="_blank">Flash-плеер</a>'
  +'</object>';
  document.write(swf);
}



$.fn.animMenu = function(option){
  var settings = $.extend({out:'slide'}, option);
  var level1 = $(this).find('li');
  $('a',level1).each(function(){
    var thisParent = $(this).parent('li');
    if(thisParent.is('.active')==false){
      $(this).mouseover(function(){
        thisParent
        .stop(true)
        .animate({
          'backgroundPosition' : 'left top'
        },300)
        .addClass('hover');
      });
      $(this).mouseout(function(){
        if(settings.out!='slide'){
          thisParent
          .stop()
          .css({'background-position' : 'left -35px'})
          .removeClass('hover');
        }else{
          thisParent
          .animate({
            'backgroundPosition' : 'left -35px'
          },300,'linear',function(){
            thisParent.removeClass('hover');
          });
        }
      });
    }
  });
}



$.fn.blockHover = function(options){
  var settings = $.fn.extend({delay:0},options);
  $(this).each(function(i){
    var t;
    $(this).hover(function(){
      $(this).addClass('hover');
      clearTimeout(t);
    },function(){
      var elem = $(this); 
      t = setTimeout(function(){
        elem.removeClass('hover');
      },settings.delay);
    });
  });
};




$(document).bind('ready',function(){

  $('#mpMenu').animMenu({out:false});
  $('#topMenu').animMenu({out:'slide'});
  
  
  if($.browser.msie && $.browser.version == "6.0"){
    $('li','#leftMenu').blockHover();
  }
  
  $('img','#gallery').captify({
		speedOver: 'normal',
		speedOut: 'normal',
		hideDelay: 500,	
		animation: 'slide',		
		prefix: '',		
		opacity: '1',					
		className: 'caption-bottom',	
		position: 'bottom',
		spanWidth: '100%'
	});
  
  
});


if($.browser.msie && $.browser.version == "6.0"){
  document.execCommand("BackgroundImageCache",false,true);
}




