function addBookmark(title,url) {
  if (window.sidebar)
  {
    window.sidebar.addPanel(title, url,"");
  }
  else if( document.all )
  {
    window.external.AddFavorite( url, title);
  }
  else
  {
    return true;
  }
}
/*$(document).ready(function(){
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
&& location.hostname == this.hostname) {
var $target = $(this.hash);
$target = $target.length && $target
|| $('[name=' + this.hash.slice(1) +']');
if ($target.length) {
var targetOffset = $target.offset().top;
$('html,body')
.animate({scrollTop: targetOffset}, 1000);
return false;
}
}
});
});*/
function checkForm(frm, arr, mes)
{
  if (!frm || !frm.elements)
  {
    alert('Форма не определена');
    return false;
  }
  el = null;
  err = '';
  for(i in arr)
  {
    if (frm.elements[i])
    switch(frm.elements[i].type)
    {
      case 'text':
      case 'textarea':
      case 'password':
      case 'hidden':
      case 'file':
        if (frm.elements[i].value == '' || frm.elements[i].value == '0')
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
        else if ((i == 'email') && (!/^[^@]+@[^@]+$/.test(frm.elements[i].value)))
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + ' | Формат: email@somethere.org' + "\n";
        }       
    	break;
      case 'select-one':
        if (frm.elements[i].value == '' || frm.elements[i].value == '0')
        {
          if (!el) el = frm.elements[i];
          err += arr[i] + "\n";
        }
    	break;
    }
  }
  if (err == '')
  { 
    frm.onsubmit = function() {return false;}
    return true;
  }
  else
  {
    try { el.focus(); } catch(e) {}
    if (!mes) mes = 'Будь-ласка заповніть обов\'язкові поля'
    if (!mes) mes = 'Пожалуйста заполните обязательные поля'
    alert(mes + ":\n-----------------------------------\n" + err + "-----------------------------------");
    return false;
  }
}
function fserialize(frm)
{
  var str = '';
  for( var i=0; i<frm.elements.length; i++)
  {
    if (!frm.elements[i].name) continue;
    switch(frm.elements[i].type)
    {
      case 'text':
      case 'password':
      case 'textarea':
      case 'hidden':
      case 'select-one':
        if (frm.elements[i].value != '')
        {
          str += '&'+frm.elements[i].name+'='+encodeURIComponent(frm.elements[i].value);
        }
    	break;
      case 'checkbox':
      case 'radio':
        if (frm.elements[i].checked)
        {
          str += '&' + frm.elements[i].name+'='+encodeURIComponent(frm.elements[i].value);
        }
    	break;
    }
  }
  return str;
}
$(document).ready(function() {
	$(".news ul li:first-child").css('margin-left','-1px');
    $('.popup2-fog').width( Math.max($('.layout').width(), $(document.body).width()) ). height( $(document.body).height() );
    //$('#slideshow').slideshow({prev:'.slideshow_left', next:'.slideshow_right'});
    $('.scrolled').jScrollPane({scrollbarWidth:7,showArrows:true});  
    /*$('div.news-one').carousel({
        nextBtn: '.news-next',
        prevBtn: '.news-prev'
    });
    */
    $('div.news').carousel({
        nextBtn: '.news-next',
        prevBtn: '.news-prev'
    });
    $('.map-points li').mouseover(function() {
        if ( !$(this).hasClass('showed') )
            $(this).find('span').show()
    }).mouseout(function() {
        if ( !$(this).hasClass('showed') )
            $(this).find('span').hide()
    });
    if(typeof sIFR == "function"){
        sIFR.replaceElement(named({
            sSelector:"h2.title", 
            sFlashSrc:"/template/sifr/helvetica.swf", 
            sColor:"#FFFFFF", 
            sLinkColor:null, 
            sBgColor:"#000000", 
            sHoverColor:null, 
            nPaddingTop:0, 
            nPaddingBottom:0, 
            sFlashVars:null,
            sWmode:"transparent"}
		    ));
        sIFR.replaceElement(named({
            sSelector:"h3.title", 
            sFlashSrc:"/template/sifr/helvetica.swf", 
            sColor:"#FFFFFF", 
            sLinkColor:null, 
            sBgColor:"#000000", 
            sHoverColor:null, 
            nPaddingTop:0, 
            nPaddingBottom:0, 
            sFlashVars:null,
            sWmode:"transparent"}
		    ));
    };

    $('.catalog-item').each(function() {
        $(this).find('.cat-images-switcher a').click(function() {
            p = getClassParent($(this), 'catalog-item');
            p.html();
            if ( $(this).attr('rel') ) {
                $('.catalog-image img.x', p).hide();
                $('.catalog-image img.x[@rel='+$(this).attr('rel')+']', p).each(function() {
                  if (!$(this).hasClass('loaded')) $(this).parent().find('img.y').show();
                  $(this).show();
                });
                $('.cat-images-switcher a', p).removeClass();
                $(this).addClass('act');
                $('.item-warp td.child').hide().filter('[@rel='+$(this).attr('id')+']').show();
            }
            /*
            if ( $(this).attr('rel') ) {
                $('.catalog-image img:first', p).attr('src', $(this).attr('rel') )
                $('.cat-images-switcher a', p).removeClass();
                $(this).addClass('act');
                $('.item-warp td.child').hide().filter('[@rel='+$(this).attr('id')+']').show();
            }*/
            return false;
        });
    });
    
/*    $('.cmenu a').attr('href','javascript:;').click(function() {
        if ( $(this).attr('rel') ){
            obj = $( '#' + $(this).attr('rel') );
            if ( obj.size() ) { 
				$(".catalog-items-list td[@id^='it']").hide();
				obj.show();
                //$('html,body').animate({scrollLeft: obj.offset().left + 'px'}, 2000);
                //$(window).scrollLeft(obj.offset().left)
            }
        }
    });
*/
    $('.item-view a').hover( function() {
        $('.desc',this).show();
    }, function() {
        $('.desc',this).hide();
    });
    /*
    $('.btn_3dconf').click(function() {
        $('.popup').show();
    });
    */
    
    $('.btn-close').click(function() {
        $('.popup').hide();
    });
    
    $('.popup-fog').width( Math.max($('.layout').width(), $(document.body).width()) ). height( $(document.body).height() );
    
});
function carousel1()
{
    $('.upholstery-list').each(function(){$(this).carousel({
        dispItems: 5,
        nextBtn: '.btn-model-right[@rel=' + $(this).attr('rel') + ']',
        prevBtn: '.btn-model-left[@rel=' + $(this).attr('rel') + ']'
    });});
    /*
    $('.upholstery-list_').carousel({
        dispItems: 5,
        nextBtn: '.btn-model-right_',
        prevBtn: '.btn-model-left_'
    });
    */
}
function getClassParent(obj, c) {
    while ( (!obj.hasClass(c)) && ( obj.size() != 0 ) ) {
        obj = obj.parent();
    }
    return obj;
}
// ======================== Template settings ==============================
var tntSizeX = 620;
var tntSizeY = 361; 
var tntSource = 'http://test5.iw380.com.ua/files/narni.tnt';
var tntCtrlColor = '#B7B7B7';
var tntTransparentOption = 0;
var tntTitle = 'TurnTool - Interactive Realtime Web 3D';
var tntDescription = 'Visit <a href="http://www.turntool.com">www.turntool.com</a>';
var tntMaxFrameCount = 100;
var max_x = 11;
var min_x_ = -194.8818;
var max_y_ = 155.90551;
var max_y = 10;
var min_y_ = -194.8818;
var max_x_ = 194.88189;
var cur_x = -1;
var cur_y = -1;
