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

/* If images are disabled*/
function checkImages(){
		 if (!IsImageOk(document.getElementById("imagetest"))){
			//underline site links
			$('.header .main_nav a, .header #logo, .index #mid_white a, .index #home_see_products, .index #home_see_products, .index #home_contact_link, .products_page #product-caplets, .products_page #product-tablets, .products_page #product-gelcaps, .products_page #product-liquid-gels, .products_page #product-arthritis, .products_page #coupon, .products_page #caplets, .products_page #tablets, .products_page #liquid-gels, .products_page #gelcaps, .products_page #arthritis, #products_arthritis_cap .popover-link').css("text-decoration","underline");
				//remove underline where necessary
				$('.pain_relief_center #mid_white a, .pain_sub #mid_white a').css("text-decoration","none");
				//add underline
				$('.pain_sub .prepared a, .uline, .overview .container .right .pages .more span, .contactus .main_content .click_here span, .pain_non_overview .container .right_image a, #caregiver_resources_overview #caregiver_links a, #caregiver_resources_overview .container .right a, .header .bayer a').css("text-decoration","underline");
				
				//square buttons line height
				$(".index #mid_white li").css("line-height","normal");
				
				//prevent main nav text from being cut off
				$(".header .main_nav a").css("height","20px");
				
				//remove ie header bolding
				$('.center_header h1').css("font-weight","normal");
				
				//remove indent, remove background images and size all
				$(".header #logo, .header .main_nav a, .header .bayer, .pain_relief_center #mid_white div h2, #mid_lightblue h1, #mid_blue h1, #mid_blue h2, #mid_blue p, #mid_blue a, #mid_blue img, .index #mid_white .content li a, #fourofour #mid_white .square_buttons li a, #easy_open_page #mid_frame h1, #easy_open_page #mid_frame h2, #easy_open_page #mid_frame p, #easy_open_page #mid_frame a, #faqs_page .questions_container .close span, #faqs_page .tabs li a, .products_page .img-text, .products_page .popover-link, #preferred_page #container h3, #preferred_page #container .arthritis_foundation, a#save_dollar, #selectretailer, .products_page .selectretailer, .products_page .selectform, .products_page .dropform, .products_page .dropretailer").css({"text-indent":"0px","background-image":"none","font-size":"13px"});
				
				//adjust #preferred page font
				$("#preferred_page #mid_blue p").css("font-size","12px");
				
				//
				$("#top_menu_area ul").css({"background-color":"#00246d", "border":"1px solid #000"});
				$("#multi_select_retailer ul, #easy_select_retailer ul").css({"background-color":"#ffd30b", "border":"1px solid #000"});
				
				//remove bg image from nav
				$('.header .main_nav li').css("background-image","none");
				
				//adjust product pages
				$('.products_page #flash_container a').css({"color":"#00A2FF", "text-decoration":"underline"});
				$('.products_page #mid_frame').css({"line-height":"normal"});
				$('.products_page #mid_darkblue h1,.products_page #mid_darkblue h2').css({"font-weight":"normal"});
				$('.products_page #prod-land-liquid-box, .products_page #prod-land-easy-box').css({"top":"182px"});
				$('.products_page #prod-land-save, .products_page #prod-land-click, .products_page .multi-save, .products_page .multi-click').css({"color":"#FFDE02","width":"300px"});
				$('.products_page #prod-land-use-as, .products_page .multi-use-as').css({"width":"300px"});
				$('.products_page #prod-land-use-as').css({"left":"800px"});
				$('.products_page .selectretailer, .products_page .selectform').css({'color':'#FFDE02'});
				$('.products_page #multi_select_retailer ul a, .products_page #easy_select_retailer ul a').css({'color':'#003A71'});
				$('.products_page .multi-click-on').css({'width':'400px','left':'200px'});
				$('.products_page .multi-prod-caplets-box').css({'left':'200px'});
				$('.products_page .multi-prod-tablets-box').css({'left':'350px'});
				$('.products_page .multi-prod-gelcaps-box').css({'left':'500px'});
				$('.products_page .multi-prod-liquid-box').css({'left':'600px', 'top':'66px'});
				$('.products_page .multi-prod-easy-box').css({'left':'700px','top':'66px', 'width':'150px'});
				$('#prod_easy_flash_alt .multi-prod-title').css({'top':'160px'});
				$('#prod_easy_flash_alt .sub1').css({'top':'190px'});
				$('#prod_easy_flash_alt .sub2').css({'top':'220px'});
				$('#prod_easy_flash_alt .sub3').css({'width':'400px'});
				$('#prod_easy_flash_alt .click_learn').css({'top':'200px','left':'50px'});
				$('#prod_easy_flash_alt #link_80').css({'left':'385px'});
				$('.products_page #flash_container h1, .products_page #flash_container h2').css("font-weight","normal");
				$('.products_page #flash_container img').remove();
				$('.btn-drug-facts').css({'line-height':'1.2'});
				//products page popover link
				$("#link_100, #link_200, #link_40, #link_80").click(function(){
					$("#cboxClose").css({"text-indent":"0","font-size":"13px","background-image":"none"});
				});	
				
				
				//faqs adjustments
				$("#faqs_page .tabs li, #faqs_page .tabs, #faqs_page .tabs li a").css({"min-height":"24px","font-size":"13px","font-weight":"normal"});
				if (isIE6){
					$("#faqs_page .tabs li, #faqs_page .tabs, #faqs_page .tabs li a").css({"height":"37px"});
				}
				$("#faqs_page .tabs li a").css({"padding-top":"13px"});
				$("#faqs_page .questions_container .close").css("background-image","none");
				$("#faqs_page .instructions a").css("text-decoration","underline");
				$("#faqs_page .tabs li a").addClass("no_image_underline");
				$("#faqs_page #mid_white .container #save_dollar").css("color","#0052AC");
				
				//remove hover for square buttons on homepage and 404
				$('.index #mid_white .content li a, #fourofour #mid_white .square_buttons li a').addClass("no_hover");
				
				$('.header #logo, .header .bayer, .header .main_nav a, .header .bayer a').css("color","#93C7FA");
				
				//easy open arthritis page
				if(window.devicePixelRatio && (navigator.platform.indexOf("Mac") > -1)){
					$('#easy_open_page .bottle').replaceWith('<span class="bottle">Easy Open Arthritis Bottle</span>');
				}
				$('#easy_open_page #mid_frame h1, #easy_open_page #mid_frame h2, #easy_open_page #mid_frame p, .products_page #mid_darkblue, #products_arthritis_cap #mid_frame h1, #products_arthritis_cap #mid_frame h1, #products_arthritis_cap #mid_frame h2, #products_arthritis_cap #mid_frame, #easy_open_page .bottle, .products_page #flash_container').css({"color":"#848484","font-weight":"normal", "font-size":"13px"});
				$('#easy_open_page #mid_frame').css("line-height","normal");
				$('#easy_open_alt_click').css({color: "#93C7FA", position:"static"});
				$('#easy_open_alt_small, #easy_open_alt_minor').css({width:"500px"});
				$('#easy_open_alt_easier').css({top:"350px"});
				
				//difference page
				$('.difference #mid_blue').css("line-height","normal");
				$('.difference #mid_blue h1, .difference #mid_blue h2').css("font-weight","normal");
				$('.difference #mid_blue #container #aleve_cares').css({width:"300px", "text-indent":"40px"});
				if(window.devicePixelRatio && (navigator.platform.indexOf("Mac") > -1)){
					$('.difference #bottle').replaceWith("<span id='bottle'>Aleve Caplets Product</span>");
				}
				$('.difference #save_dollar').css({"text-decoration":"underline",color:"#FFDE02"});
				$('.difference #aleve_cares').css({"text-decoration":"underline"});
				
				//home page
				$('.index #mid_blue').css("line-height","normal");
				$('.index #mid_blue #home_contact_par').css("top","150px");
				$('.index #mid_blue #home_use_as_dir').css("top","250px");
				$('.index #mid_blue h1, .index #mid_blue h4').css("font-weight","normal");
				$('.index #home_see_difference').css({left:"68px", color: "#FFDE02"});
				$('.index #mid_blue #home_contact_link').css("position","static");
				
				//404 page
				$('#fourofour .square_buttons a').css("text-decoration","underline");
				
				//pain relief section
				//$('.pain_relief_center #mid_white .container img').addClass('move_down');
				$('.pain_non_overview #mid_white .right_image a, .pain_non_overview #mid_white .right_image img').addClass('move_down');
				$('.pain_relief_center #mid_white .container .left img').replaceWith('<span class="rightfloat">Aleve Caplets Bottle</span>');
				$('.pain_relief_center #mid_white .container .right img').replaceWith('<span class="rightfloat">Aleve Easy Open Arthritis Cap Bottle</span>');
				$('.pain_relief_center #mid_white .container .left span').css({position:"relative",right:"25px",top:"4px"});
				$('.pain_relief_center #mid_white .container .right span').css({position:"relative",right:"5px",top:"4px"});
				$('.pain_non_overview #mid_white .right_image img').replaceWith('<span class="move_down">Save $2.00 on Aleve</span>');
				$('.pain_relief_center #mid_white .container img, .pain_relief_center #mid_white .container span').css({"font-size":"13px","line-height":"normal",width:"110px"});
				$('.pain_relief_center h1, .pain_relief_center h2, .pain_sub #mid_lightblue h1').css("font-weight","normal");
				
				//sitemap
				$('#sitemap .pain_relief_center h2, #fourofour .pain_relief_center h2').css("font-weight","bold");
				
				//preferred page
				$('#preferred_page #caplets_package, #preferred_page #gelcaps_package, #preferred_page #liquid_package').css("top","200px");
				$('#preferred_page #container h2').css({width:"400px",top:"60px"});
				$('#preferred_page #liquid_package').css("left","700px");
				
				//preferred thank you page
				$('#preferred_page #container h3').css({width:"500px"});
				$('#preferred_page.thankyou #container h1').css({left:"133px"});
				$('#preferred_page.thankyou #how_aleve_different a, #preferred_page.thankyou #more_about_products a').css({position:"static",display:"inline"});
				$('#preferred_page #container img').each(function(){											  
						$(this).remove();
				});
				$('#preferred_page.thankyou #container h2').css({width:"650px"});
				$('#preferred_page.thankyou #container h3').css({top:"100px"});
				$('#preferred_page #container h2, #preferred_page #container h1, #preferred_page #container h3').css("font-weight","normal");
				$('#preferred_page #container h2, #preferred_page .arthritis_foundation, #preferred_page #container h3').css("line-height","normal");
				$('#preferred_page #mid_blue, #preferred_page #right_bg, #preferred_page #mid_blue #container').css("background-image","none");

		 }
}

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;
}

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

