
/*
Copyright © Lead eCommerce www.leadecom.com, 2009
*/

jQuery.noConflict();

jQuery(document).ready(function($){
	

	$('div#item object embed').each(function(){$(this).attr({'width':365})})
	
	$('._opanel').mouseenter(function(){
		var _this = $(this);
		var idName = _this.attr('id');
		var opened = false;
		
		var forId = idName.split('a_')[1];

		if ((navigator.userAgent.indexOf("MSIE 7"))!=-1)
		{
			var offSet = getOffset( this );
			var _x = offSet.left;
			var _y = offSet.top;
			var _width = $('#'+forId).width()-8;
			var i = $('.bsh',$('#'+forId)).css({'width':_width,'left':'4','position':'absolute'});

			$('.cl, .cr',$('#'+forId)).css({'top': $('#'+forId).height() });
		}
		else
		{
			var _x = this.offsetLeft+this.scrollLeft;
			var _y = this.offsetTop+this.scrollTop;
		}
		
		$('.opanel').css({'display':'none'});
		$('._opanel').removeClass( 'selected' );
		
		$('#'+forId).css({'display': 'block','top':_y+25,'left':_x-4});
		
		_this.addClass( 'selected' );
		$('#'+forId).mouseleave(function(){
			$(this).css({'display':'none'});
			_this.removeClass( 'selected' );
		})
		$('#'+forId).mouseenter(function(){
			opened = true;
		})
		
		_this.mouseout(function(){

			var __this = $(this);
			var idName = __this.attr('id');
			var forId = idName.split('a_')[1];
					
			var t = setTimeout( function(){
				if(!opened)
				{
					if($('#'+forId).css('display') != 'none')
					{
						$('#'+forId).css({'display':'none'});
						__this.removeClass( 'selected' );
					}
			}
				clearTimeout(t);
			}, 400);

		})
		
	});

	$('#search_top, #search_footer').submit(function(){
		
		return checkSearchForm( $('input.inp', $(this)) );

	});
	
	$('#clearancesale .content').click(function(){
		window.open( 'http://' + document.location.hostname + '/liquidacion/index.html','new');									
	});
	
	$('#getemail .content').click(function(){
		if( $('#getemail .subcont').css('display') == 'none' ){
		
			$('#getemail .content').addClass( 'content_open' );
			$('#getemail .subcont').animate({height: 'show'}, 'fast', function()
			{
					$('form', $(this)).css( {display: 'block'} );
			});
		
		}
		else
		{
			$('form',$('#getemail .subcont')).css( {display: 'none'} );
			$('#getemail .subcont').animate({height: 'hide'}, 'fast', function(){
					$('#getemail .content').removeClass( 'content_open' );
			});
		}
	});
	
	$('#ckitchen_design .content').click(function(){
		if( $('#ckitchen_design .subcont').css('display') == 'none' ){
		
			$('#ckitchen_design .content').addClass( 'content_open' );
			$('#ckitchen_design .subcont').animate({height: 'show'}, 'fast', function()
			{
					//$('form', $(this)).css( {display: 'block'} );
			});
		
		}
		else
		{
			$('#ckitchen_design .subcont').animate({height: 'hide'}, 'fast', function(){
					$('#ckitchen_design .content').removeClass( 'content_open' );
			});
		}
	});
	
	$('#verisign').click(function(){
		window.open( 'https://seal.verisign.com/splash?form_file=fdf/splash.fdf&dn=' + document.location.hostname + '&lang=en','new','width=515,height=450');
	});
	
	$('#livehelp').click(function(){window.open('http://server.iad.liveperson.net/hc/47786206/?cmd=file&file=visitorWantsToChat&site=91070226&referrer='+document.location,'chat91070226','width=472,height=320')});
	
	$('#oform_signin').click(function(){
		
		var e = $(this);
		
		if( $('#subbar').css('display') == 'none' ){
		
			e.addClass( 'selected' );
			$('#topbar').addClass( 'topbar_on' );
			$('#subbar').animate({height: 'show'}, 'fast', function()
			{
					$('form', $(this)).css( {display: 'block'} );
			});
		
		}
		else
		{
			$('form',$('#subbar')).css( {display: 'none'} );
			$('#subbar').animate({height: 'hide'}, 'fast', function(){
					$('#topbar').removeClass( 'topbar_on' );
					e.removeClass( 'selected' );
			});
		}
		
		return false;
	});

}); 


//	Ïðîâåðêà ôîðìû ïîèñêà

function checkSearchForm( e )
{
	var searchString = e.val();

	e.val( searchString == null ? "" : searchString.replace(/[\xA0-\xBF]|#|`|™/g,'').replace(/“|”|„/g,'"').replace(/‘|’|‚/g,"'") );
		
	if( e.val().length < 2 )
	{
		alert("Please enter keyword 2 letters or more!");
		return false;
	}
	
	return true;
}

function getOffset( el ) {
    var _x = 0;
    var _y = 0;
    while( el && !isNaN( el.offsetLeft ) && !isNaN( el.offsetTop ) ) {
        _x += el.offsetLeft - el.scrollLeft;
        _y += el.offsetTop - el.scrollTop;
        el = el.parentNode;
    }
    return { top: _y, left: _x };
}

