$(document).ready( function () {

	$("#buy-now-flyout-bg").css("opacity", 0.80);
	
	// all carousels
	/* $("#public-home-carousel .scrollable").scrollable({
		circular: true
	}).autoscroll( 4000 ); */
	
	$("#home-carousel .scrollable").scrollable({
		circular: true,
		'size': 1,
		'clickable': false
	}).autoscroll( 6000 );

	$("#previous-deals .scrollable").scrollable({
		'size': 1,
		'clickable': false
	});

   $("#video-call").click(function(){
        $.fancybox({
            'padding': 0,
			'overlayColor' : '#333',
            'autoScale': false,
            'transitionIn': 'none',
            'transitionOut': 'none',
            'title': this.title,
            'width': 680,
            'height': 495,
            'href': this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type': 'swf',
            'swf': {
                'wmode': 'transparent',
                'allowfullscreen': 'true'
            }
        });
        return false;
    });


	// check-out form validation
	$('#CreditCardType').change( function () {
		if ($('#CreditCardType').val() == 1000007) {
			$('#card-check').hide();
		}

		if ($('#CreditCardType').val() != 1000007) {
			$('#card-check').show();
		}
	})
	$("form#CheckOut").validate({
		// debug: true,
		/*submitHandler: function () {

		 },*/
		/*success: function (label) {
		 //  label.removeClass("error");
		 // label.addClass("valid");
		 },
		 success: function(label) {
		 // set &nbsp; as text for IE
		 label.html("&nbsp;").addClass("checked");
		 },*/
		rules: {
			NameOnCard: {
				minlength: 2
			},
			//  CardNumber: { creditcard: true },
			CardExpMonth: {
				required: function (element) {
					return $("#CreditCardType").val() != 1000007;
				}
			},
			CardExpYear: {
				required: function (element) {
					return $("#CreditCardType").val() != 1000007;
				}
			},
			CVC: {
				required: function (element) {
					return $("#CreditCardType").val() != 1000007;
				}
			},
			ConfEmail: {
				equalTo: "#EMail"
			}
			//   FirstName: { required: true }
		},
		messages: {
			NameOnCard: "Enter the name on your card",
			CreditCardType: "Select a credit card type",
			CardNumber: {
				creditcard: "Enter valid card number"
			}
		}
	})

	$("#nav-main ul li.dropdown-trigger:last-child").css('border-right', '1px solid #ccc');


	setDefaultInputText();

	// create tabs
	var $tabs = $('#product-tabs').tabs()
	$('a.gotoreviews').click( function () {
		$tabs.tabs('select', 2);
		return false;
	});
	// lightbox dialogs
	$("a#zoom").fancybox({
		'titleShow': false,
		'transitionIn': 'fade',
		'transitionOut': 'fade'
	});

	// lightbox dialogs
	$("a.zoom").fancybox({
		'titleShow': false,
		'transitionIn': 'fade',
		'transitionOut': 'fade'
	});

	$("a.dialog").fancybox({
		'width': 750,
		'height': 550
	});

	$("a#dialog").fancybox({
		'width': 750,
		'height': 550
	});

	$("a#dialog-med").fancybox({
		'width': 550,
		'height': 450
	});

	$("a#dialog-small").fancybox({
		'width': 400,
		'height': 325
	});

	// alternating colored rows
	$('.zebra-rows tr:even').addClass('alt');

});
