$(document).ready(function() {
    initBuzzTools();
});

var currentScrollLoc;

function initBuzzTools() {
    killAnchors();
	killForms();
	rigTables();
	rigNavigation();
	rigPlaceHolderText();
	rigDatePicker();
	rigPrintArea();
	rigBuyNowBtn();
}

function killAnchors() {
    $("a[href='#']").click(function() { return false });
}

function killForms(){
	$("form[action='#']").submit(function(){
		return false;
	});
}

function rigTables() {
    $("tr:nth-child(odd)").not(".break").addClass("odd");
}

function rigTable(what) {
    $(what).find("tr:nth-child(odd)").not(".break").addClass("odd");
}

function rigPlaceHolderText() {
    if ($.browser.msie || $.browser.mozilla || $.browser.opera) {
        var objs = $("input[placeholder]");
        $.each(objs, function () {
            if ($(this).val() == "" || $(this).val() == $(this).attr("placeholder")) {
                $(this).css({ color: "#a9abae" });
                $(this).val($(this).attr("placeholder"));
            }
        }).bind("focus", function () {
            $(this).css({ color: "#000" });
            if ($(this).val() == $(this).attr("placeholder")) {
                $(this).val("");
            }
        }).bind("blur", function () {
            if ($(this).val() == "") {
                $(this).css({ color: "#a9abae" });
                $(this).val($(this).attr("placeholder"));
            }
        });
    }
}

function rigNavigation() {
    $(".navigationBar li").hover(function () { showChildren(this) }, function () { hideChildren(this) });
}

function showChildren(what) {

    var timer = 250;
    if ($.browser.msie && $.browser.version.substr(0, 1) < 7) {
        $(" > ul", what).height($(" > ul", what).height());
        $(" > li", what).css({ 'margin-top': -6 });
        $(" > ul", what).show();
        $(" > ul", what).width($(" > ul", what).width());
    }
    else {
        if ($(" > ul", what).parents('ul').size() >= 2) {
            $(" > ul", what).show('slide', { direction: 'left', easing: 'swing' }, timer);
        }
        else {
            //$(" > ul", what).parents('ul > li').addClass('current');
            $(" > ul", what).show('slide', { direction: 'up', easing: 'swing' }, timer);
        }

    }
}

function hideChildren(what) {
    if ($(what).parents('ul').size() == 1) {
        $(".navigationBar li").find('ul').hide();
    }
    else {
        $(what).find('ul:visible').hide();
    }
}

function rigDatePicker() {
    $(".datePicker").datepicker({ dateFormat: 'dd/mm/yy' });
}

function rigPrintArea() {
    $(".printAreaBtn").click(function () { 
        $(".printArea").printElement();
    });
}

function rigBuyNowBtn() {
    $(".buynowBtn").click(function () {
        window.location = "/register";
    });
}

