// html5shiv MIT @rem remysharp.com/html5-enabling-script
// iepp v1.6.2 MIT @jon_neal iecss.com/print-protector
/*@cc_on(function(m,c){var z="abbr|article|aside|audio|canvas|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video";function n(d){for(var a=-1;++a<o;)d.createElement(i[a])}function p(d,a){for(var e=-1,b=d.length,j,q=[];++e<b;){j=d[e];if((a=j.media||a)!="screen")q.push(p(j.imports,a),j.cssText)}return q.join("")}var g=c.createElement("div");g.innerHTML="<z>i</z>";if(g.childNodes.length!==1){var i=z.split("|"),o=i.length,s=RegExp("(^|\\s)("+z+")",
"gi"),t=RegExp("<(/*)("+z+")","gi"),u=RegExp("(^|[^\\n]*?\\s)("+z+")([^\\n]*)({[\\n\\w\\W]*?})","gi"),r=c.createDocumentFragment(),k=c.documentElement;g=k.firstChild;var h=c.createElement("body"),l=c.createElement("style"),f;n(c);n(r);g.insertBefore(l,
g.firstChild);l.media="print";m.attachEvent("onbeforeprint",function(){var d=-1,a=p(c.styleSheets,"all"),e=[],b;for(f=f||c.body;(b=u.exec(a))!=null;)e.push((b[1]+b[2]+b[3]).replace(s,"$1.iepp_$2")+b[4]);for(l.styleSheet.cssText=e.join("\n");++d<o;){a=c.getElementsByTagName(i[d]);e=a.length;for(b=-1;++b<e;)if(a[b].className.indexOf("iepp_")<0)a[b].className+=" iepp_"+i[d]}r.appendChild(f);k.appendChild(h);h.className=f.className;h.innerHTML=f.innerHTML.replace(t,"<$1font")});m.attachEvent("onafterprint",
function(){h.innerHTML="";k.removeChild(h);k.appendChild(f);l.styleSheet.cssText=""})}})(this,document);@*/

(function($) {

	$(function() {
	
		$('#main').css({'min-height': $('#sidebar').height()+100+'px', 'padding-bottom': $('#footer').height()+54+'px'});
		if ($('.catalog_det')) {
			(block = $('.catalog_det .h')).width() < 500 ? block.css('clear', 'both') : '';
			$(window).resize(function() {
				(block = $('.catalog_det .h')).width() < 500 ? block.css('clear', 'both') : block.css('clear', 'none');
			});
		}
		if ($('.sphere_list')) {
			(block = $('.sphere_list .h')).width() < 500 ? block.css('clear', 'both') : '';
			$(window).resize(function() {
				(block = $('.sphere_list .h')).width() < 500 ? block.css('clear', 'both') : block.css('clear', 'none');
			});
		}
// old version, ie doesn't like it, he's not stretchy
/*		if (joe = $('.catalog_det .chr')) {
			cat_w = $(window);
			cat_ws = $('#content');
			(cat_w.width() > 1000) ? joe.css('width', cat_ws.width() - $('.catalog_det .det').width() - 10 + 'px') : '';
			$(window).resize(function() {
				//alert(cat_w);
				(cat_w.width() > 1000) ? joe.css('width', cat_ws.width() - $('.catalog_det .det').width() - 10 + 'px') : '';
			});
		}
*/
		if (joe = $('.catalog_det .chr')) {
			cat_w = $(window);
			cat_ws = $('#content');
			det_w = $('.catalog_det .det');
			page_w = $('#page');
			//alert(det_w.width());
			//joe.css('width', cat_ws.width() - det_w.width() + 'px');
			joe.css('width', page_w.width() - det_w.width() - 520 + 'px');
			$(window).resize(function() {
				joe.css('width', page_w.width() - det_w.width() - 520 + 'px');
			});
		}
		
		
		var IE6 = false /*@cc_on || @_jscript_version < 5.7 @*/;
		var IE7 = false /*@cc_on || @_jscript_version == 5.7 @*/;
		if (IE6) {
			wd = $('#page');
			if ($(window).width() > 1240) {
				wd.css('width', '1200px');
			} else if ($(window).width() < 1000) {
				wd.css('width', '960');
			}
			$(window).resize(function() {
				if ($(window).width() > 1240) {
					wd.css('width', '1200px');
				} else if ($(window).width() < 1000) {
					wd.css('width', '960px');
				} else {
					wd.css('width', 'auto');
				}
			});

			(hght = $('#sidebar').height()) > $('#content').height() ? $('#main').css('height', hght+100+'px') : '';
			DD_belatedPNG.fix('.png, .ul_2 li, .dl_0, #necktie dt, .necktie_knots a, .necktie .nav a, #necktie .txt a img, time, .back, .subscribe, .subscribe_bl form, .advant_list .img img, .q_n_a dl, .catalog_list .img, .catalog_det .det, .catalog_det .lo img, .catalog_det .chr, .cat_img, .cat_img .lo img');
		}
		if (IE6 || IE7) {
			if (vv = $('.cat_img')) {
				vv.css('width', vv.find('.img').width());
			}
		}
		
//		search_def_val = $('#search').val();
//		$('#search').focus(function() {
//			this.value == search_def_val ? this.value = '' : 0;
//		});
//		$('#search').blur(function() {
//			this.value == '' ? this.value = search_def_val : 0;
//		});

		$(".has_default").each(function(){
			var self=$(this);
			var search_def_val = self.val();
			self.focus(function() {
				this.value == search_def_val ? this.value = '' : 0;
			});
			self.blur(function() {
				this.value == '' ? this.value = search_def_val : 0;
			});
		});

		$('.searchText').autocomplete('/scripts/search_autocomplete_backend.php', {minChars:3, maxItemsToShow: 10});

	});

})(jQuery);
