$(document).ready(function() {
	var root = $('#root a').attr('href');
	
	$('form label.hide').hide();
	
	if ($.browser.msie) {
		if (parseFloat($.browser.version) != 6) {
			$('*:first-child').addClass('first-child');
			$('*:last-child').addClass('last-child');
			$('*:nth-child(odd)').addClass('nth-child-odd');
			$('*:nth-child(even)').addClass('nth-child-even');
		}
		
		/*Fix IE hover:*/
		$('ul.thumbs li a').hover(
			function() {
				$(this).addClass('hover');
			},
			function() {
				$(this).removeClass('hover');
			}
		);		
	}

/*----------------------------------------------------------------------------
	Make page anchor at form if invalid
----------------------------------------------------------------------------*/
	if($("#aside-subscribe .information p").length > 0) {
		window.location.href = '#aside-subscribe';
	}
	if($("#contact .information p").length > 0) {
		window.location.href = '#contact';
	}
	
/*----------------------------------------------------------------------------
	Open external links in a new tab/window
----------------------------------------------------------------------------*/
	$('a.external, a[rel=external]').live("click", function() {
		window.open($(this).attr('href'));
		return false;
	});
	
/*----------------------------------------------------------------------------
	Hero Slide
----------------------------------------------------------------------------*/
	$('.feature-container').cycle({
		fx:     'fade',
	    speed:  'slow',
	    timeout: 7500,
	    next:   '#next',
	    prev:   '#prev'
	});

/*----------------------------------------------------------------------------
	Subscribe box
----------------------------------------------------------------------------*/
	$(".field-checkbox").show();
	
	$('input[type=checkbox]').click(function() {
        if ($(this).attr("checked") == true) {
			$(".field-buttons").prepend('<div class="cm"><input name="campaignmonitor[list]" value="652ac978aac194056cf872b74fe5da7f" type="hidden" /><input name="campaignmonitor[field][Name]" value="$field-name" type="hidden" /><input name="campaignmonitor[field][Email]" value="$field-email" type="hidden" /><input name="fields[cm]" type="hidden" class="cm" value="yes"  /></div>');
        } else {
            $("div.cm").remove();
        }
	});
	

/*----------------------------------------------------------------------------
	Validation
----------------------------------------------------------------------------*/
	$('form').SymphonyInlineValidation({
		canofspam: true,
		url: root + "/validation/",
		validate: "input, textarea"
	});

/*----------------------------------------------------------------------------
	Colorbox
----------------------------------------------------------------------------*/
	$("a.priv").colorbox({opacity: "0.6", width:"35%", href: root+"/privacy-policy/"});		
/*----------------------------------------------------------------------------
	Placeholder
----------------------------------------------------------------------------*/
	$('input, textarea').placeholder();
});

/*!
 * HTML5 Placeholder jQuery Plugin v1.8.2
 * @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
 * @author Mathias Bynens <http://mathiasbynens.be/>
 */
(function(f){var e='placeholder' in document.createElement('input'),a='placeholder' in document.createElement('textarea');if(e&&a){f.fn.placeholder=function(){return this};f.fn.placeholder.input=f.fn.placeholder.textarea=true}else{f.fn.placeholder=function(){return this.filter((e?'textarea':':input')+'[placeholder]').bind('focus.placeholder',b).bind('blur.placeholder',d).trigger('blur.placeholder').end()};f.fn.placeholder.input=e;f.fn.placeholder.textarea=a}function c(h){var g={},i=/^jQuery\d+$/;f.each(h.attributes,function(k,j){if(j.specified&&!i.test(j.name)){g[j.name]=j.value}});return g}function b(){var g=f(this);if(g.val()===g.attr('placeholder')&&g.hasClass('placeholder')){if(g.data('placeholder-password')){g.hide().next().attr('id',g.removeAttr('id').data('placeholder-id')).show().focus()}else{g.val('').removeClass('placeholder')}}}function d(h){var l,k=f(this),g=k,j=this.id;if(k.val()===''){if(k.is(':password')){if(!k.data('placeholder-textinput')){try{l=k.clone().attr({type:'text'})}catch(i){l=f('<input>').attr(f.extend(c(this),{type:'text'}))}l.removeAttr('name').data('placeholder-password',true).data('placeholder-id',j).bind('focus.placeholder',b);k.data('placeholder-textinput',l).data('placeholder-id',j).before(l)}k=k.removeAttr('id').hide().prev().attr('id',j).show()}k.addClass('placeholder').val(k.attr('placeholder'))}else{k.removeClass('placeholder')}}f(function(){f('form').bind('submit.placeholder',function(){var g=f('.placeholder',this).each(b);setTimeout(function(){g.each(d)},10)})});f(window).bind('unload.placeholder',function(){f('.placeholder').val('')})}(jQuery));
