$(function(){
	$('a.external_link').attr("target", "_blank");
});
$(function(){
	$('#headerImg').cycle({
		speed:  'slow',
		timeout: 6000
	});
});
$(function(){
	$("#pageflip").hover(function() {
		$("#pageflip img.resized , .msg_block").stop()
			.animate({ 
				width: '362px',
				height: '362px'
			}, 500, function(){
				$('.msg_block').addClass('changeZindex')
			});
		$('.pageFlipNote').stop()
			.animate({
				left: '-175px',
				bottom: '-175px'
			}, 500)
		} , function() {
		$("#pageflip img.resized").stop()
			.animate({
				width: '166px',
				height: '166px'
			}, 220);
		$('.pageFlipNote').stop()
			.animate({
				left: '10px',
				bottom: '10px'
			}, 200)
		$(".msg_block").stop()
			.removeClass('changeZindex')
			.animate({
				width: '150px',
				height: '150px'
			}, 200);
	});
});
$(function(){
	$('#barRZP a').click(function(){
		$('#barRZPCont').slideToggle(400);
		return false;
	})
	$('#env-hide').click(function(){
		$('#barRZPCont').slideUp(400);
		return false;
	})
});

/*replacing tag <hr> with stylable div*/
$(function(){
	$(".weditor").find("hr").wrap('<div class="fakeHr"></div>')
});
/*add alt text under image in weditor*/
var weditorImagesIndex = 1;
function initWeditorImagesAlts(){
	$('.weditor img.fleft, .weditor img.fright').each(function(i){
		if (!$(this).parent().is('.img-border-left') && !$(this).parent().is('.img-border-right') && (parseInt($(this).width()) > 0)) {
			if ($(this).is('.weditor img.fleft')) {
				$(this).wrap('<span class="img-border-left"></span>');
			} else {
				$(this).wrap('<span class="img-border-right"></span>');
			}
			$(this).addClass("imgAlts"+weditorImagesIndex);
			imgAlt = $('.weditor .imgAlts'+weditorImagesIndex).attr("alt");
			imgWidth = parseInt($(this).width()) + parseInt($(this).css('paddingLeft')) + parseInt($(this).css('paddingRight'));
			$(this).parent().css('width', imgWidth + "px");
			if ($(this).attr("alt").length > 0){
				$(".weditor .imgAlts"+weditorImagesIndex).after("<p>" +imgAlt+ "</p>");
			}
			weditorImagesIndex++;
		}
	});
}
$(function(){
	initWeditorImagesAlts();
});
$(window).load(function(){
	initWeditorImagesAlts();
});
