var imgstatus = false;
var Hover = new Array;

var idea_hover_status = false;
var idea_hover = new Array();

$(function() {
    if ($('#content').width() < 1008) {
		$('.adwer_item img').height(70);
		$('.adwer_item img').width(70);
		$('#adwer_block, #adwer_block .adwer_item').css("font-size", "12px");

		$('.adwer_laws_min img').height(70);
		$('.adwer_laws_min img').width(221);
		$('.adwer_laws_min div').css({'top' : '26px', 'left' : '96px'});
	}else {
		$('.adwer_item img').height(100);
		$('.adwer_item img').width(100);

		$('.adwer_laws_min img').height(91);
		$('.adwer_laws_min img').width(249);
	}
    
    if($('#Textpic').width() < 992) // 1120 
    $("#Textpic .items:last").hide();
    $("#Textpic .imgs").hover(
        function () {
        var marleft = '0px';
        var $wid = $('#Textpic').width();
        var $tekpo = $(this).offset();
        if(($tekpo.left + 110) > $wid) marleft = '-150px';
        
        //alert($wid + ' ' + $tekpo.left + ' ' + marleft );
            if (imgstatus) return;
            imgstatus = true;
            var this_id = $(this).attr('rel');
            if($.inArray(this_id, Hover) < 0){
                Hover.push(this_id);
                if(this_id > 0) $.post("/ajax/textpic/", {url_id : this_id } );
            }
            $(this).css("z-index", 1100).animate({
                top: "-16px",
                marginLeft: marleft,
                width: "300px"
                }, 150, function(){ imgstatus=false; }
            )
        },
        function () {
            $(this).animate({
                marginLeft: 0,
                top: 0,
                width: "150px"
            }, 150, function(){ }
            ).css("z-index", 1000)
        }  
    );

    $(".posts-adwerts .prewimgs").hover(
        function () {
            if (idea_hover_status) {
                return;
            }

            idea_hover_status = true;
            var item = $(this).attr('rel').split('-');

            if ($.inArray(item[1], idea_hover) < 0) {
                idea_hover.push(item[1]);
                if(item[1] > 0) {
                    $.getJSON("http://ideas.vdolevke.ru/_ajax/textpic/?callback=?", {url_id : item[1], url_area : item[0]});
                }
            }

            $(this).css("z-index", 1100).animate({
                top:-35,
                marginLeft:0,
                width:200
            }, 100, function(){
                idea_hover_status = false; 
            });
        },
        function () {
            $(this).animate({
                marginLeft:0,
                top:13,
                width:90,
                left:10
            }, 100, function(){}).css("z-index", 1000);
        } 
    );
})

