// JScript File

function bellsWhistles() {
   var offramp = '/system_pages/SiteExit.aspx?url=';
    $('a[rel="external"]').attr('href', function(concat) {
        return offramp + this.href;
        });  
        
    
    $('a[rel="external"]').wrap('<span class="nobr">');
    $('a[rel="external"]').after('&nbsp;<img src="/images/icons/external-link.png" alt="external link" class="linkimg" width="10" height="10" />'); 
    $('a[type="application/pdf"]').attr("target","_blank");
    $('a[type="application/pdf"]').after('<img src="/images/icons/pdf.png" alt="pdf link" class="linkimg" width="15" height="15" />');
	
    $('a[type="application/word"]').after('<img src="/images/icons/word-icon.png" alt="MS Word document" class="linkimg" />'); 
    //$('a.top').after('<img src="/images/widgets/to-top.png" alt="Back to top" class="linkimg" />');
    $('dl dt').append(':');
    $('fieldset label.req').prepend('<b>*</b>');
    $('fieldset p.req').prepend('<b>*</b>'); 
    $('table tbody tr:nth-child(odd)').addClass("zebra");
    
    $("#azandme img").hover(
             function()
             {
              this.src = this.src.replace("_off","_over");
             },
             function()
             {
              this.src = this.src.replace("_over","_off");
             }
            );
    $("a.popup").click(function(){
				    var popID = $(this).attr("href");
				    var offset = $(this).offset();
				    
				    var posx = offset.left + $(this).width() - 50;
				    if(posx > 600){posx = "600px";}
				    else {posx = posx + "px";}
				    
				    var posy = offset.top - 170 + "px";
				    showPop(popID,posx,posy);
				    return false;
				});
}



function ie6Fix() {
	
	$('#text table tr.zebra.last').addClass('zebralast');
	
	// add class to adjacent items
	var arrAdjacent = new Array(
		'#text h2 + .diagram'
	)
	jQuery.each(arrAdjacent, function(i) { $(arrAdjacent[i]).addClass('adjacent'); });
	
	/* add class to first items */
	var arrFirst = new Array(
		'#text table th:first-child',
		'#text table td:first-child'
	)
	jQuery.each(arrFirst, function(i) { $(arrFirst[i]).each(function(i) { $(this).addClass('first'); }); });
	
	/* add class to last items */
	var arrFirst = new Array(
		'#text table tr:last-child',
		'#text table th:last-child',
		'#text table td:last-child'
	)
	jQuery.each(arrFirst, function(i) { $(arrFirst[i]).each(function(i) { $(this).addClass('last'); }); });
	
}

// Disable form if user doesn't have commercial insurance
$(document).ready(function() {
// Check if user is a prospectives user.  If so they will get a new media code.
var source = $.query.get('utm_source');
    
    $("input#reg_survey_30_VIM005_Y").click(function(){
        $("div#reg_survey_30_VIM008_ctr, div#reg_survey_3_ctr, div#reg_user, span#eighteen, div#reg_optin, div#reg_optin label span.sxr").css("color", "#CCCCCC");
        $("div#reg_survey_30_VIM008_ctr input[type=text], div#reg_survey_3_ctr input[type=text], div#reg_user input[type=text], div#content div.form div#reg_user select").css("border-color", "#CCCCCC");
        $("div#reg_survey_30_VIM008_ctr :input, div#reg_survey_3_ctr :input, div#reg_user :input, p#submit :input, div#reg_optin :input").attr("disabled", true);
        $("div#reg_survey_30_VIM008_ctr span.req, div#reg_survey_3_ctr span.req, div#reg_user span.req").css("color", "#FFCCCC");
        $("p#submit").css("opacity", 0.66);
        if (source == 'Prospectiv')
        {
           $("#reg_survey_30_VIM005_err").html("We're sorry, but you must have commercial/private insurance in order to be eligible for this offer.<br/><br/>To register for updates for VIMOVO, please <a href=/sign-up.aspx?source=VIMBC4110>click here</a>.").addClass("medError");
        }
        else
        {
        $("#reg_survey_30_VIM005_err").html("We're sorry, but you must have commercial/private insurance in order to be eligible for this offer.<br/><br/>To register for updates for VIMOVO, please <a href=/sign-up.aspx?source=VIMBC4089>click here</a>.").addClass("medError");
        }
    });
    
    $("input#reg_survey_30_VIM005_N").click(function(){
        $("div#reg_survey_30_VIM008_ctr, div#reg_survey_3_ctr, div#reg_user, p#submit, span#eighteen, div#reg_optin, div#reg_optin label span.sxr").css("color", "");
        $("div#reg_survey_30_VIM008_ctr input[type=text], div#reg_survey_3_ctr input[type=text], div#reg_user input[type=text], div#content div.form div#reg_user select").css("border-color", "");
        $("div#reg_survey_30_VIM008_ctr :input, div#reg_survey_3_ctr :input, div#reg_user :input, p#submit :input, div#reg_optin :input").removeAttr("disabled");
        $("div#reg_survey_30_VIM008_ctr span.req, div#reg_survey_3_ctr span.req, div#reg_user span.req").css("color", "");
        $("p#submit").css("opacity", "");
        $("#reg_survey_30_VIM005_err").html("").removeClass("medError");
    });
    
});
