$(document).ready(function() {

    /*  Linking to external websites */
    $("a[rel='external']").addClass("external")
       .click(function() { window.open($(this).attr("href")); return false; });

    /*  Making a form element focus */
    $("input.focus").eq(0).focus();

    /* styling for the flag selection */
    $("ul#flag_selection li").each(
        function(){
            if ($(this).hasClass("selected") == false)
            {
                $(this, "a").find("img").css("opacity", 0.4);
            }
        }
    );

    $("ul#flag_selection li").hover(
        function() {
            $(this, "a").find("img").css("opacity", 1);
        },
        function() {
            if ($(this).hasClass("selected") == false)
            {
                $(this, "a").find("img").css("opacity", 0.4);
            }
        }
    );
    
	if ($("span.chkPaymentConditions input").length)
    {
		/* Requires that you accept the conditions when accepting an order */
		if (!$("span.chkPaymentConditions input").is(":checked"))
		{
			$("div.PaymentPage table input[type='submit']").attr("disabled", "true");
		}
		
		$("span.chkPaymentConditions input").click( function () {
			if ($("span.chkPaymentConditions input").is(":checked"))
			{
				$("div.PaymentPage table input[type='submit']").removeAttr("disabled");
			}
			else
			{
				$("div.PaymentPage table input[type='submit']").attr("disabled", "true");
			}
		});
	}
});

