// JavaScript Document

$(document).ready(function () {
    
    $("a[rel=external]").click(function() {
          window.open(this.href);  
          return false;
    });
    
    // policy pop-ups
    var privacy_pop_up = $("#privacy-pop-up");
	if (privacy_pop_up.length) {
		privacy_pop_up.dialog({
			height: 400,
			maxHeight: 600,
			width: 600,
			maxWidth: 800,
			autoOpen: false,
			position: ["center", "center"],
			modal: true
		});
		$("a#privacy-policy").click(function() {
			privacy_pop_up.dialog("open");
			return false;
		});
	}
	var shipping_refund_pop_up = $("#shipping-refund-pop-up");
	if (shipping_refund_pop_up.length) {
		shipping_refund_pop_up.dialog({
			height: 200,
			maxHeight: 600,
			width: 340,
			maxWidth: 800,
			autoOpen: false,
			position: ["center", "center"],
			modal: true
		});
		$("a#shipping-refund-policy").click(function() {
			shipping_refund_pop_up.dialog("open");
			return false;
		});
	}
	var terms_of_use_pop_up = $("#terms-of-use-pop-up");
	if (terms_of_use_pop_up.length) {
		terms_of_use_pop_up.dialog({
			height: 400,
			maxHeight: 600,
			width: 800,
			maxWidth: 800,
			autoOpen: false,
			position: ["center", "center"],
			modal: true
		});
		$("a#terms-of-use").click(function() {
			terms_of_use_pop_up.dialog("open");
			return false;
		});
	}
	
	var placeAnOrderSubmit = $("#place-order");
	placeAnOrderSubmit.attr("disabled", "disabled");
	$("input[name=tou-agreement]").click(function() {
		if ($(this).is(":checked")) {
			placeAnOrderSubmit.attr("disabled", "");
		} else {
			placeAnOrderSubmit.attr("disabled", "disabled");
		}
	});
});