 $(window).load(function() {  
	$('.basket-input').focus(function(){
		if($(this).attr('value') == '0'){
			$(this).css({color:'#000000'}).attr({value:''});
		}
	});

	$('.basket-input').blur(function(){
		if($(this).attr('value') == null){
			$(this).css({color:'#999999'}).attr({value:'0'});
		}
	});



	
	
	
	var config = {    
     over: 	function(){	$('.submenu',this).slideDown();	},
     timeout: 150,   
     out: 	function(){ $('.submenu',this).slideUp();	}
	};

	$("#panel li").hoverIntent(config);

	
	
/*
	$('.city-toggle').click(function(){
		$('.city-toggle.active').removeClass('active');
			$(this).addClass('active');
			$('input[name=city]').attr({value:$(this).attr("rel")});
			return false;
	});
*/
	var defaultFontSize = parseFloat($('#content .content').css('fontSize').replace('px',''));
	var contentFontSize = $.cookie('contentFontSize');
	if(contentFontSize){
		$('#content .content').css({'fontSize':contentFontSize+'px'});
	}
	
	$('a[rel=zoom-in]').click(function(){
		var fs = parseFloat($('#content .content').css('fontSize').replace('px',''));
		if(fs < 15){
			$('#content .content').css({'fontSize':(fs+1)+'px'});
			equalizeFieldsets();
			$.cookie('contentFontSize',(fs+1),{path: '/'});
		}
	});
	
	$('a[rel=zoom-reset]').click(function(){
		$('#content .content').css({'fontSize':defaultFontSize+'px'});
		equalizeFieldsets();
		$.cookie('contentFontSize',defaultFontSize,{path: '/'});
	});	
	
	$('a[rel=zoom-out]').click(function(){
		var fs = parseFloat($('#content .content').css('fontSize').replace('px',''));
		if(fs > 9){
			$('#content .content').css({'fontSize':(fs-1)+'px'});
			equalizeFieldsets();
			$.cookie('contentFontSize',(fs-1),{path: '/'});
		}
	});
	
	
	$('.tab').hide();	
	$('.tab:first').show();
	
	$('a[rel]').click(function(){
		$('.active-tab').removeClass('active-tab');
		$(this).addClass('active-tab');
		
		$('.tab').removeClass('active').hide();
		$('#'+$(this).attr("rel")).addClass('active').show();
			return false;
	});
	
	/* IE min height */
		if($.browser.msie && ($('.content').height() < $('.content').css("min-height").replace('px',''))){
			$('.content').css("height",$('.content').css("min-height"));
		}
	/* min-resize */
	$(window).resize(function(){
		if(document.body.clientWidth < 1000){
			$('#conteiner').css({width:"1000px"});
		}else{
			$('#conteiner').css({width:"auto"});
		}
		equalizeFieldsets();
		$(".leftside, .content ").equalizeCols();
	});
	
	equalizeFieldsets();	
	$(".leftside, .content ").equalizeCols();

$('a[rel=city_list]').click(function(){
	$('.city_list').toggle();
});	

$(document).one('click', function(e) {
	$('.city_list').hide();
});
		
$('img').load(function(){
	equalizeFieldsets();
	$(".leftside, .content ").equalizeCols();
});
	
/**
 * useful script to detect near standing elements and equalizing them
 */

function  equalizeFieldsets(){
	var currentId = 1;
	$('fieldset').each(function(){
		if($(this).next().hasClass('a_left') || $(this).next().hasClass('a_right')){
			$(this).addClass('fieldset-'+currentId);
			$(this).next().addClass('fieldset-'+currentId);
		}else{
			$(".fieldset-"+currentId).equalizeCols();
			++currentId;
		}
	});
}

});



$(document).ready(function(){

	var skip = false;
	if(($.browser.msie && $.browser.version < 7)){
		var skip = true;
	}

	if($('#comment_form').text() != '' && skip == false ){
		var comment_form = $('#comment_form').clone();
		$('body').append('<div id="comment_form_2"><div class="bookmark"><img src="/images/comment-tab.png" /></div><div class="form"></div></div>');
		
		$('#comment_form_2 .form').html(comment_form);
		
		$('#comment_form_2 .bookmark').toggle(
		function(){
			$('#comment_form_2').css('right',-32);
		},
		function(){
			var bookmarkWidth = $('#comment_form_2 .bookmark').css('width').replace(/px/,'');
			var form = $('#comment_form_2').css('width').replace(/px/,'');

			$('#comment_form_2').css('right','-'+(form-bookmarkWidth)+'px');
		});
	}

});



/**
 *
 * Copyright (c) 2007 Tom Deater (http://www.tomdeater.com)
 * Licensed under the MIT License:
 * http://www.opensource.org/licenses/mit-license.php
 * 
 */
 
(function($) {
	/**
	 * equalizes the heights of all elements in a jQuery collection
	 * thanks to John Resig for optimizing this!
	 * usage: $("#col1, #col2, #col3").equalizeCols();
	 */
	 
	$.fn.equalizeCols = function(){
		var height = 0,
			reset = $.browser.msie ? "1%" : "auto";
  if ($.browser.msie && $.browser.version == 7) reset = "auto";
		return this
			.css("height", reset)
			.each(function() {
				height = Math.max(height, this.offsetHeight);
			})
			.css("height", height)
			.each(function() {
				var h = this.offsetHeight;
				if (h > height) {
					$(this).css("height", height - (h - height));
				};
			});
			
	};

})(jQuery);

/**
* hoverIntent is similar to jQuery's built-in "hover" function except that
* instead of firing the onMouseOver event immediately, hoverIntent checks
* to see if the user's mouse has slowed down (beneath the sensitivity
* threshold) before firing the onMouseOver event.
* 
* hoverIntent r5 // 2007.03.27 // jQuery 1.1.2+
* <http://cherne.net/brian/resources/jquery.hoverIntent.html>
* 
* hoverIntent is currently available for use in all personal or commercial 
* projects under both MIT and GPL licenses. This means that you can choose 
* the license that best suits your project, and use it accordingly.
* 
* // basic usage (just like .hover) receives onMouseOver and onMouseOut functions
* $("ul li").hoverIntent( showNav , hideNav );
* 
* // advanced usage receives configuration object only
* $("ul li").hoverIntent({
*	sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)
*	interval: 100,   // number = milliseconds of polling interval
*	over: showNav,  // function = onMouseOver callback (required)
*	timeout: 0,   // number = milliseconds delay before onMouseOut function call
*	out: hideNav    // function = onMouseOut callback (required)
* });
* 
* @param  f  onMouseOver function || An object with configuration options
* @param  g  onMouseOut function  || Nothing (use configuration options object)
* @author    Brian Cherne <brian@cherne.net>
*/
(function($) {
	$.fn.hoverIntent = function(f,g) {
		// default configuration options
		var cfg = {
			sensitivity: 7,
			interval: 100,
			timeout: 0
		};
		// override configuration options with user supplied object
		cfg = $.extend(cfg, g ? { over: f, out: g } : f );

		// instantiate variables
		// cX, cY = current X and Y position of mouse, updated by mousemove event
		// pX, pY = previous X and Y position of mouse, set by mouseover and polling interval
		var cX, cY, pX, pY;

		// A private function for getting mouse position
		var track = function(ev) {
			cX = ev.pageX;
			cY = ev.pageY;
		};

		// A private function for comparing current and previous mouse position
		var compare = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			// compare mouse positions to see if they've crossed the threshold
			if ( ( Math.abs(pX-cX) + Math.abs(pY-cY) ) < cfg.sensitivity ) {
				$(ob).unbind("mousemove",track);
				// set hoverIntent state to true (so mouseOut can be called)
				ob.hoverIntent_s = 1;
				return cfg.over.apply(ob,[ev]);
			} else {
				// set previous coordinates for next time
				pX = cX; pY = cY;
				// use self-calling timeout, guarantees intervals are spaced out properly (avoids JavaScript timer bugs)
				ob.hoverIntent_t = setTimeout( function(){compare(ev, ob);} , cfg.interval );
			}
		};

		// A private function for delaying the mouseOut function
		var delay = function(ev,ob) {
			ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t);
			ob.hoverIntent_s = 0;
			return cfg.out.apply(ob,[ev]);
		};

		// A private function for handling mouse 'hovering'
		var handleHover = function(e) {
			// next three lines copied from jQuery.hover, ignore children onMouseOver/onMouseOut
			var p = (e.type == "mouseover" ? e.fromElement : e.toElement) || e.relatedTarget;
			while ( p && p != this ) { try { p = p.parentNode; } catch(e) { p = this; } }
			if ( p == this ) { return false; }

			// copy objects to be passed into t (required for event object to be passed in IE)
			var ev = jQuery.extend({},e);
			var ob = this;

			// cancel hoverIntent timer if it exists
			if (ob.hoverIntent_t) { ob.hoverIntent_t = clearTimeout(ob.hoverIntent_t); }

			// else e.type == "onmouseover"
			if (e.type == "mouseover") {
				// set "previous" X and Y position based on initial entry point
				pX = ev.pageX; pY = ev.pageY;
				// update "current" X and Y position based on mousemove
				$(ob).bind("mousemove",track);
				// start polling interval (self-calling timeout) to compare mouse coordinates over time
				if (ob.hoverIntent_s != 1) { ob.hoverIntent_t = setTimeout( function(){compare(ev,ob);} , cfg.interval );}

			// else e.type == "onmouseout"
			} else {
				// unbind expensive mousemove event
				$(ob).unbind("mousemove",track);
				// if hoverIntent state is true, then call the mouseOut function after the specified delay
				if (ob.hoverIntent_s == 1) { ob.hoverIntent_t = setTimeout( function(){delay(ev,ob);} , cfg.timeout );}
			}
		};

		// bind the function to the two event listeners
		return this.mouseover(handleHover).mouseout(handleHover);
	};
})(jQuery);
