function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

/*CSS Browser Selector v0.3.4 (Sep 29, 2009)Rafael Lima (http://rafael.adm.br)http://rafael.adm.br/css_browser_selectorLicense: 
http://creativecommons.org/licenses/by/2.5/Contributors: http://rafael.adm.br/css_browser_selector#contributors*/
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.getElementsByTagName('html')[0], 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); 

var abortSlides = false;
$(document).ready(function(){
		$('.question a.question').mousedown(function(){
			if(!$(this).hasClass('open')){
	
				if(!abortSlides ){
					abortSlides = true;
					$(this).parent().parent().parent().parent().find('span a.question').removeClass('open');																
					$(this).parent().parent().parent().parent().find('div.answer').slideUp('fast');	
					$(this).parent().parent().parent().parent().find('span a.close').fadeOut();	
					$(this).parent().parent().parent().parent().find('.bar').css('background','#ffffff');				
					$(this).parent().parent().parent().find('div.answer').slideDown('fast', function() {
						abortSlides = false;
					  	});
					$(this).addClass('question open');	
					$(this).parent().parent().parent().find('.bar').css('background','#e6e6e6');	
					$(this).parent().parent().parent().find('.close').fadeIn();
					Cufon.replace('a.question', { fontFamily: 'HelveticaNeue', hover: true }); // helvetica light
				}
			} else if($(this).hasClass('question open')) {
				$(this).parent().parent().parent().find('.close').fadeOut();
				$(this).parent().parent().parent().find('.bar').css('background','#ffffff');
				$(this).parent().parent().parent().find('div.answer').slideUp();
				$(this).parent().parent().parent().find('a.question').removeClass('open');
				Cufon.replace('a.question', { fontFamily: 'HelveticaNeue', hover: true }); // helvetica light		
			}
		});
		$('.close').mousedown(function(){
			$(this).fadeOut();
			$(this).parent().parent().parent().find('.bar').css('background','#ffffff');
			$(this).parent().parent().parent().find('div.answer').slideUp();
			$(this).parent().parent().parent().find('a.question').removeClass('open');
			Cufon.replace('a.question', { fontFamily: 'HelveticaNeue', hover: true }); // helvetica light			
		});
		// default input text
		var default_values = new Array();
		$("#tbUpdates").focus(function() {
		    if (!default_values[this.id]) {
		        default_values[this.id] = this.value;
		    }
		    if (this.value == default_values[this.id]) {
		        this.value = '';
		    }
		    $(this).blur(function() {
		        if (this.value == '') {
		            this.value = default_values[this.id];
		        }
		    });
		});	
		
	});

	


$(document).ready(function() {
  //subscribe functions
    $('#fsSubscribe').mouseover(function() {
        $('#fsSubscribe>label').fadeOut(100);
    });
    $('#fsSubscribe>a.buttonSignup').click(function() {
        subscribe();
        return false;
    });
  //  $('input:text').focus(function(event) {
  //      $(this).addClass('focus');
   // });
   // $('input:text').blur(function(event) {
  //      $(this).removeClass('focus');
  //  });
    $('#fsSubscribe input#tbUpdates').keyup(function(event) {
        if (event.keyCode == '13') {
            subscribe();
        }
    });
    setupDefaultTextReset($('#fsSubscribe input#tbUpdates'), 'WANT TO BE KEPT UP TO DATE? Enter your email here');
});

function subscribe() {
    var email = $('#fsSubscribe input#tbUpdates').val();
    $('#fsSubscribe span.error').html('');
    $('#fsSubscribe input#tbUpdates').removeClass('error');

    if (trim(email) == '' ||
        trim(email) == 'type your email address here') {
        $('#fsSubscribe span.error').html('Please enter your email address!');
    }
    else if (!isValidEmail(email)) {
        $('#fsSubscribe span.error').html('Please enter a valid email address!');
    }
    if ($('#fsSubscribe span.error').html() != '') {
        $('#fsSubscribe span.error').fadeIn(500);
        $('#fsSubscribe input#tbUpdates').addClass('error');
        setTimeout(function() { $('#fsSubscribe span.error').fadeOut(500); }, 3000);
    }
    else {
        //send
        $('#fsSubscribe span.wait').show();
        $.post("/handlers/SubscribeHandler.ashx", { email: email }, function(data) {
            $('#fsSubscribe span.wait').hide();

            if (data.indexOf('Error:') != -1) {
                $('#fsSubscribe span.error').fadeIn(500);
                $('#fsSubscribe span.error').html('An error had occured. Please try again later.');
            }
            else if (data.indexOf('Success') != -1) {
                $('#fsSubscribe span.success').fadeIn(500);
            }
        });
    }
}
function setupDefaultTextReset(obj, message) {
    obj.click(function() {
        if (obj.val() == message)
            obj.val('');
    });
    obj.blur(function() {
        if (obj.val() == '')
            obj.val(message);
    });
}
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 trim(str, chars) {
    return ltrim(rtrim(str, chars), chars);
}
function ltrim(str, chars) {
    chars = chars || '\\s';
    return str.replace(new RegExp('^[" + chars + "]+', 'g'), '');
}
function rtrim(str, chars) {
    chars = chars || '\\s';
    return str.replace(new RegExp('[" + chars + "]+$', 'g'), '');
}
function PostBackOnReturn(event, postbackMethod) {
    if (event) {
        if (event.keyCode == 13) {
         //   __doPostBack(postbackMethod, '');
        }
    }
}
String.prototype.startsWith = function(str) { return (this.match("^" + str) == str); }
