/*
* Логинов Андрей Вячеславович
* "SaT" (Site a template) version 0.1
* Создан 3 апреля 2011 г.
* Последнее обновление 4 апреля
* 1. LCR - Резиновые блоки по высоте. true и false
* 2. PIEcorner - гибрид 2 гиниальных вещей, которые делают скругления абсолютно кросбраузерно.
* 3. topMenu - Верхнее горизонтальное меню, подгружемое Ajax.
* 4. bgSize - css3 свойство background-size, добавлена работа с hover
*/

(function($){
/* 1 */
    $.fn.heightLCR = function(opts1) {
		var options1 = {
			LCR: false
		};
		options1 = $.extend(options1,opts1);
		if(options1.LCR){
			var lcr_height = 0;
			$(document).ready(function(){
				if ($("#right").height() >= $("#left").height()){
					if ($("#center").height() >= $("#right").height()){
						lcr_height = $("#center").height();
					} else {
						lcr_height = $("#right").height();
					}
				} else {
					lcr_height = $("#left").height();
				}
				$("#left").height(lcr_height);
				$("#right").height(lcr_height);
				$("#center").height(lcr_height);
			});
		}
	}
	
/* 2 */
	$.fn.PIEcorner = function(opts2) {
		var options2 = {
			corn_rad: 10,
			corn_tl: 10,
			corn_tr: 10,
			corn_bl: 10,
			corn_br: 10
		};
		options2 = $.extend(options2,opts2);
		$(this).corner(options2.corn_rad + "px");
		$(this).css({"behavior": "url(./PIE.htc)", "-webkit-border-radius": options2.corn_rad+"px", "-moz-border-radius": options2.corn_rad + "px", "border-radius": options2.corn_rad + "px"});
	}
	

/* 4 */
	$.fn.bgsize = function(opts4) {
		var options4 = {
			imgsrc: './img/bgsize.png',
			hoversrc: '0'
		};
		options4 = $.extend(options4,opts4);
		var img = $("<img src='" + options4.imgsrc + "' alt='' style='width: 100%; height: 100%; position: absolute; top: 0; left: 0; z-index: 750' />");
			imghov = $("<img class='imghov' src='" + options4.hoversrc + "' alt='' style='width: 94%; height: 33px; position: absolute; top: 0; left: 4%; z-index: 750' />");
		$(document).ready(function(){
			$(".bgsize").ready(function(){
				$(".bgsize").css({'position': 'relative', 'background': 'none'});
				//img.prependTo($(".bgsize"));
				if(options4.hoversrc != '0') {
					$(".bgsize").hover(function(){
						$(this).parent(function(){
							imghov.prependTo($(this));
						});
					}, function(){
						$('img.imghov',this).remove();
					});
					$(".bgsize").hover(function(){
						imghov.prependTo($(this));
					}, function(){
						$('img.imghov',this).remove();
					});
				}
			});
		});
	}
})(jQuery);
