/*
CSS Browser Selector v0.3.5 (Feb 05, 2010)
Rafael Lima (http://rafael.adm.br)
http://rafael.adm.br/css_browser_selector
License: http://creativecommons.org/licenses/by/2.5/
Contributors: http://rafael.adm.br/css_browser_selector#contributors
*/


function RequiredValidator(Selector) {
    if ($(Selector).val() == "") {
        $(Selector).removeClass('Valid');
        $(Selector).addClass('Invalid');
    }
    else {
        $(Selector).removeClass('Invalid');
        $(Selector).addClass('Valid');
    }
}

function EmailValidator(Selector) {
    var EmailRegex = new RegExp("\\w+([-+.']\\w+)*@\\w+([-.]\\w+)*\\.\\w+([-.]\\w+)*");
    var RegexResult = EmailRegex.test($(Selector).val());
    if (RegexResult == true) {
        $(Selector).removeClass('Invalid');
        $(Selector).addClass('Valid');
    }
    else {
        $(Selector).removeClass('Valid');
        $(Selector).addClass('Invalid');
    }
}

function ValidateAll() {
    $('.Required').each(function () {
        RequiredValidator($(this));
    });

    $('.EmailValidator').each(function () {
        EmailValidator($(this));
    });
}

function css_browser_selector(u){var ua = u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1;},g='gecko',w='webkit',s='safari',o='opera',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?'mobile':is('iphone')?'iphone':is('ipod')?'ipod':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win':is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);
function PostBackOnReturn(event, postbackMethod) {
    if (event) {
        if (event.keyCode == 13) {
            __doPostBack(postbackMethod, '');
        }
    }
}
function isValidEmail(email) {
    var regex = /([\w\d\-_]+)(\.[\w\d\-_]+)*@([\w\d\-_]+\.)([\w\d\-_]+\.)*([\w]{2,3})/;
    if (regex.test(email))
        return true;
    else
        return false;
}
function goToByScrollId(id) {
    $('html,body').animate({ scrollTop: $("#" + id).offset().top }, 'slow');
}
function goToByScrollTop(top) {
    $('html,body').animate({ scrollTop: top }, 'slow');
}
String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g, ''); }
$(document).ready(function() {
    $('#aAllBrands, #aAllTypes, #aAllPrices').click(function() {
        $(this).parent().find('.filterList').fadeIn();
        return false;
    });
    $('.filterList').mouseleave(function() {
        $(this).fadeOut();
        return false;
    });
    $('.filterList a').click(function() {
        $(this).parent().parent().find('a').first().html($(this).html());
        $(this).parent().parent().find('a').first().removeClass();
        $(this).parent().parent().find('a').first().addClass($(this).attr('id'));
        $(this).parent().hide();
        return false;
    });

    // send form spans on click checks blank span and displays label
    $('.newsletterObj fieldset label span, .shareObj fieldset label span').click(function() {
        if ($(this).parent().parent().find('label input').attr('value') == "") {
            $(this).parent().find('span').fadeIn('fast');
        }
        $(this).fadeOut('fast',function(){
					$(this).parent().find('input').focus();
			});
    });
    $('.newsletterObj fieldset label input, .shareObj fieldset label input').focusin(function() {
        $(this).parent().find('span').fadeOut('fast');
    });
    $('.newsletterObj fieldset label input, .shareObj fieldset label input').focusout(function() {
        if ($(this).attr('value') == "") {
            $(this).parent().find('span').fadeIn('fast');
        }
    });

    // faqs
    $('.linkQuestion').click(function() {
        if (!$(this).parent().parent().hasClass('questionActive')) {
            resetFAQ();
            $(this).parent().parent().removeClass('question').addClass('questionActive');
            $(this).parent().parent().find('.close').fadeIn();
            $(this).parent().nextAll('div.answer').eq(0).show();
        } else {
            resetFAQ();
        }
        return false;
    });

    $('.close').click(function() {
        resetFAQ();
        return false;
    });
    function resetFAQ() {
        $('div.questionActive').removeClass('questionActive').addClass('question');
        $('.answer').slideUp();
        $('.close').fadeOut();
    }
    if ($.browser.msie) {
        // superslight
        $('ul.globalNav li, ul.subNav li, ul.subNavGen li, .visiqueLogo img, .headerMotif, img').supersleight();
    }

    /*$('.test-content').css('height', $('.test-content-inner').height);
    $('.bg-Col').css('height', $('.bg-Col').parent().find('div.newsletterObj').height() + 20);
    $('.bg-Col1').css('height', $('.bg-Col1').parent().find('div.shareObj').height() + 20);
    $('.bg-Col2').css('height', $('.bg-Col2').parent().find('div.shareObj2').height() + 0);*/
});
