ie9 = (navigator.userAgent.indexOf( 'MSIE 9' ) !== -1);
jQuery(document).ready(function(){
	if (!ie9) 
		jQuery("#imagetest").attr("src","img/1x1.gif?"+Math.random());
	if (ie9){
		//checkImages();
	}
});

/* If images are disabled*/
function checkImages(){
		 if (!IsImageOk(document.getElementById("imagetest"))){
			 imagesDisabled = true;
			$('.EXP_slideshow_container span, #viewer_container .holder span, #header .nav a, #rsd_logo, .main_content .nav a, .textindent, #main_subnav a, #viewer_wrapper, .service_offers .holder div h3, .about .partners_header, .about .team_header, #projects_container li, .rsd_team h2, .contact .submit, .why_rsd .rsd_mid ul').addClass("imagesDisabled");
			$('#header .nav a, #main_subnav a, #bottom_content .first h3, #bottom_content .second h3').height("auto");
			$('#header .nav a, #main_subnav a').css("width","auto");
			if (ie_old){
				$('.EXP_slideshow_container').addClass("imagesDisabled");
			}
			$('.textindent').removeClass("textindent");
			$('.EXP_slideshow_container span, #viewer_container .holder span').each(function(){
				$(this).html($(this).find("img").attr("alt"));
			});
			$('#rsd_logo').replaceWith("<span id='rsd_logo' class='imagesDisabled'>"+ $('#rsd_logo').attr("alt") +"</span>");
			$('.contact .submit').val("Submit");
			
			if (window.devicePixelRatio){
				$('#rsd_logo').parent().css("text-decoration","none");
				$('.clients .logos img, .work_landing .print_container img, .work_landing .interactive_container img, .why_rsd .comparison img, .why_rsd .subpage_intro_image_container img').each(function(){
					$(this).replaceWith("<span>"+ $(this).attr("alt") +"</span>");
				});
			}
			
		 }
}

function IsImageOk(img) {
    if (!img.complete) {
        return false;
    }


    //These give the true size of the image. If it failed
    // to load, either of these should be zero.
    if (typeof img.naturalWidth != "undefined" && img.naturalWidth == 0) {
        return false;
    }

    // No other way of checking: assume it's ok.
    return true;
}

jQuery(window).load(function(){
	if (!ie9) checkImages();
});

