﻿
/*	£TextRotator Start ---------------------------------------------- */

var headline_count;
var headline_interval;
var old_headline = 0;
var current_headline = 0;

jQuery(document).ready(function () {
    headline_count = jQuery(".quotesticker").size();
    jQuery(".quotesticker:eq(" + current_headline + ")").show();
    headline_interval = setInterval(headline_rotate, 5000);
    jQuery('.quotecontainer').hover(function () {
        clearInterval(headline_interval);
    }, function () {
        headline_interval = setInterval(headline_rotate, 5000);
        headline_rotate();
    });
    //pick up enter click and fire default search button
    jQuery('.searchentersubmit').bind('keypress', function (e) {
        if (e.keyCode == 13) {
            // Enter pressed... fire the search function
            jQuery('#aspnetForm').submit(function () { return false; });
            jQuery('.searchbutton').trigger('click');
        }
     });
    setupLabel();
});

function headline_rotate() {
    current_headline = (old_headline + 1) % headline_count;
    jQuery(".quotesticker:eq(" + old_headline + ")").hide();
    jQuery(".quotesticker:eq(" + current_headline + ")").show();
    old_headline = current_headline;
}

/*	$TextRotator End---------------------------------------------- */

function setupLabel() {
    if (jQuery('.label_radio input').length) {
        jQuery('.label_radio').each(function() {
            jQuery(this).removeClass('r_on');
        });
        jQuery('.label_radio input:checked').each(function() {
            jQuery(this).parent('label').addClass('r_on');
        });
    };

    //medium
    if (jQuery('.label_radio medium input').length) {
        jQuery('.label_radio medium').each(function() {
            jQuery(this).removeClass('r_on_medium');
        });
        jQuery('.label_radio medium input:checked').each(function() {
            jQuery(this).parent('label').addClass('r_on_medium');
        });
    };

    //small
    if (jQuery('.label_radio small input').length) {
        jQuery('.label_radio small').each(function() {
            jQuery(this).removeClass('r_on_small');
        });
        jQuery('.label_radio small input:checked').each(function() {
            jQuery(this).parent('label').addClass('r_on_small');
        });
    };


    if (jQuery('.label_check input').length) {
        jQuery('.label_check').each(function() {
            jQuery(this).removeClass('c_on');
        });
        jQuery('.label_check input:checked').each(function() {
            jQuery(this).parent('label').addClass('c_on');
        });
    };

    if (jQuery('.label_check_medium input').length) {
        jQuery('.label_check_medium').each(function() {
            jQuery(this).removeClass('c_on_15');
        });
        jQuery('.label_check_medium input:checked').each(function() {
            jQuery(this).parent('label').addClass('c_on_15');
        });
    };

    if (jQuery('.label_check_small input').length) {
        jQuery('.label_check_small').each(function() {
            jQuery(this).removeClass('c_on_10');
        });
        jQuery('.label_check_small input:checked').each(function() {
            jQuery(this).parent('label').addClass('c_on_10');
        });
    };
};

function isValidEmailAddress(emailAddress) {
    var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i);
    return pattern.test(emailAddress);
}



/*	£Toggle ---------------------------------------------- */

jQuery('.toggleContainer').hide();
jQuery('.simpleTrigger').toggle(function () {
    jQuery(this).next('.toggleContainer').slideDown(500);
    jQuery(this).children('span').text("-").css('top', '-3px').css('left', '2px').css('font-size', '15px');
}, function () {
    jQuery(this).next('.toggleContainer').slideUp(500);
    jQuery(this).children('span').text("+").css('top', '-1px').css('left', '0px').css('font-size', '14px');
});



/*  
modernizr / yepnope - work as in tandom or alone
yepnope conditionally load shim scripts to replace missing functionality in old browsers. example below is loading a script to simulate the new html5 form tags
It uses modernizr to see if the browser has the feature implemented.  
It can load scripts if the feature is either present / not present or both
http yepnopejs.com/
http net.tutsplus.com/tutorials/javascript-ajax/easy-script-loading-with-yepnope-js/
*/


//yepnope([{
    //test: Modernizr.input.placeholder,
    //yep  : ['js/1a.js', 'css/1a.css'],
    //nope: ['/include/jquery.html5support.min.js', '/include/shimInit.js']
//}]);



//jQuery(document).ready(function () {
     //hide the *Sign Up to Axis News* labels - the text is generated within the text field via javascript for browsers that dont support the new html5 form tags.
    //jQuery('.getNewsNameLabel, .getNewsEmailLabel').css('display', 'none');
//});





