
var imgs = null;


$('.press_img img').mouseover(function() {
    $(this).attr('src', $(this).attr('src').replace('/gray_th_', '/th_'))
});

$('.press_img img').mouseout(function() {
    $(this).attr('src', $(this).attr('src').replace('/th_', '/gray_th_'))
});

/*
$('.press_img img').click(function(){												
$('#dialog_content').html('<img src="'+$(this).attr('src').replace('/th_','/lg_')+'" alt="" style="display:none" />');
$('#dialog').jqm().jqmShow();
ShowImg();
});	*/

$('.press_img').click(function() {
    var id = $(this).parent().attr('id');
    id = id.substr(id.lastIndexOf('_') + 1);
    if ($.trim($('#press_li_' + id + ' .press_more').html()).length == 0) {
        SetDialogImg($('#press_li_' + id + ' .press_img img').eq(0).attr('src').replace('/th_', '/lg_'), -1);
    } else {
        $('#dialog_content').html($('#press_li_' + id + ' .press_more').html());
    }
    SetDialog();
    $('#dialog').jqm().jqmShow();
    ShowImg();
})

function SetDialogImg(src, next) {
    if (next > -1) {
        $('#dialog_content').html('<img src="' + src + '" alt="" style="display:none; cursor:pointer" onclick="Label_Click(' + next + ')" />');
    } else {
        $('#dialog_content').html('<img src="' + src + '" alt="" style="display:none" />');
    }
}

function Label_Click(i) {
    SetDialogImg(imgs[i], (i + 1) % $('.jqlabels span').length);
    ShowImg();
    $('.jqlabels span').css('font-weight', 'normal');
    $('.jqlabels span').eq(i).css('font-weight', 'bold');
}



function SetDialog() {
    if ($('#dialog_content img').length > 1) {
        imgs = new Array($('#dialog_content img').length);

        var lhtml = '';
        $('#dialog_content img').each(function(i) {
            imgs[i] = $('#dialog_content img').eq(i).attr('src');
            var l = imgs[i].substr(imgs[i].lastIndexOf('/') + 1).substr(3);
            l = l.substring(0, l.length - 4);

            if (l.length < 3) l = "Img#" + l;
            lhtml += '<span style="cursor:pointer" onclick="Label_Click(' + i + ')">' + l + '</span> ';
            if (i < $('#dialog_content img').length - 1) {
                lhtml += ' | ';
            }

        });
        $('#dialog_content').html('');
        $('.jqlabels').html(lhtml);
        Label_Click(0);
    } else {
        $('.jqlabels').html('');
    }
}

/*
$('#press_picbox img').each(function(i){	
									 
$('#press_picbox img').eq(i).mouseover(function(){  	
//$('#press_picbox img').eq(i).css({ opacity: "1", filter: "alpha(opacity=100)" });	
$('#press_picbox img').eq(i).attr('src', $('#press_picbox img').eq(i).attr('src').replace('/gray_th_','/th_')  )
});	   
	
$('#press_picbox img').eq(i).mouseout(function(){  	
//$('#press_picbox img').eq(i).css({ opacity: "0.50", filter: "alpha(opacity=50)  gray" });	
//$('#press_picbox img').eq(i).attr('src', '/pimg/press/gray_th_'+(i+1)+'.jpg');	 
$('#press_picbox img').eq(i).attr('src', $('#press_picbox img').eq(i).attr('src').replace('/th_','/gray_th_')  )
});	   
	
$('#press_picbox img').eq(i).click(function(){												
$('#dialog_content').html('<img src="/pimg/press/lg_'+(i+1)+'.jpg" alt="" style="display:none" />');
$('#dialog').jqm().jqmShow();
ShowImg();
});		
});*/



function ShowImg() {
    $("#dialog_content img").animate({ opacity: 'show' }, 1200);
}


