﻿// Common Site Wide Js Functions

$(document).ready(function () {

    // Hide LG Filter go button 
    $('.no-js-go').css('display', 'none');

    // Find print links that are hidden and show and prepare for trigger
    $('#print_func .no_js').removeClass('no_js').addClass('js_print_trigger');
    $('.js_print_trigger a').click(function () {
        window.print();
        return false;
    });

    $('#print_func .sharethis').removeClass('no_js');

    // Find .generic_input_btn and add hover class to make it appear as generic_btn with ie support
    // :hover doesn't ahve x-browser support for div and inputs in all browsers
    $('.generic_input_btn').hover(function () {
        $(this).addClass('generic_input_btn_hover');
    }, function () {
        $(this).removeClass('generic_input_btn_hover');
    });

    // Find .go_input_btn and add hover class to make it appear as generic_btn with ie support
    // :hover doesn't have x-browser support for div and inputs in all browsers
    $('.go_input_btn').hover(function () {
        $(this).addClass('go_input_btn_hover');
    }, function () {
        $(this).removeClass('go_input_btn_hover');
    });

    // Clear out the example text on clickeroo!! woop!!
    $('.clear_my_input').click(function () {
        $(this).val("");
    })

    // Removes no_js when js is on!!!
    $('.no_js').removeClass('no_js');

    // Checkbox initialised show/hide
    function jsShowHide(thisLoc, checkStatus) {
        if (checkStatus == true) {
            rel = thisLoc.parent().attr('rel');
            $('#' + rel).css('display', 'block');
        } else {
            rel = thisLoc.parent().attr('rel');
            $('#' + rel).css('display', 'none');
        }
    }
    // onLoad
    // only works for 1 on a page so if multiple onload probably needs to refactor that.
    rel = $('.jsShowHide input').parent().attr('rel');
    $('#' + rel).css('display', 'none');
    if ($('.jsShowHide input').attr('checked') == true) {
        $('#' + rel).css('display', 'block');
    }
    // onClick
    $('.jsShowHide input').click(function () {
        thisLoc = $(this);
        checkStatus = $(this).attr('checked');
        jsShowHide(thisLoc, checkStatus);
    })

    $('a.info-roll').hover(function () {
        $(this).siblings('.info-box').show();
    }, function () {
        $(this).siblings('.info-box').hide();
    });

    // Clear value on focus of the email input box
    $('div.left_large #rightBox .text').click(function () {
        if ($(this).val() == "Enter your email...") {
            $(this).val("");
        }
    });
    $('div.left_large #rightBox .text').blur(function () {
        if ($(this).val() == "") {
            $(this).val("Enter your email...");
        }
    });
});
