function resizeBg(_this) {
	var ratio = window.innerHeight/window.innerWidth;
	if (ratio < .57) {
		$(_this).removeClass('inner-box-ver');
		$(_this).addClass('inner-box-hor');
	} else {
		$(_this).removeClass('inner-box-hor');
		$(_this).addClass('inner-box-ver');
	}
}

jQuery(document).ready(function(){

	$('#wrapper').ascensor({
		AscensorName:'box',
                //you can choose the name that will define id and class (default:'maison')
        WindowsFocus:true,
                //if you start on the first content(default:true)
        //WindowsOn:'0',
                //if you can to start to the 0,1,2,3 etc.. content
        Direction:'x',
                //What will be the direction of the ascensor
        NavigationDirection:'xy',
                //what will be his navigation direction(par défaut:'xy')
		Navig:false,
                //if you need a navigation system
        Link:false,
                //If you need a link per page for the next page
        PrevNext:true,
                //if you need a prev/next button
        KeyArrow:false,
                //deactivate the arrow key
        keySwitch:true,
                //deactivate navigation by arrow key
        CSSstyles:true,
                //if you need the Default CSS plugin
        ReturnURL:true,
                //if you need a url per page
        ReturnCode:false,
                //Give you id and class of the navig/link/content
		ChocolateAscensor:true,
                //if you need to place yourself all the stage
        //AscensorMap: '3|3',
                //define the size of a map
        ContentCoord:'1|1 & 1|2 & 2|2 & 2|3 & 3|3'
                //place stage one by one, indicating they positionx|positiony

	});
	
	$('.box div:first-child').each(function() {
		resizeBg(this);
	});
	
	
	$(window).resize(function() {
		$('.box div:first-child').each(function() {
			resizeBg(this);
		});
	});
	
	$('#boxPrev').addClass('navBtn');
	$('#boxNext').addClass('navBtn');
	$('.navBtn').attr('style', '');
	$('.navBtn').css({
		background: '#333',
		color: '#FFF',
		fontSize: 33,
		top: 60,
		//bottom: 95,
		lineHeight: '28px',
    	padding: '11px 15px 8px',
		position: 'fixed',
		zIndex: 20000
	});
	$('#boxPrev').css('right', 125).html('<');
	$('#boxNext').css('right', 55).html('>');
	
	
	/* Input 6 Textarea texts */
	jQuery('.placeholder').each(function(i) {
 
	 var item = jQuery(this);
	 var text = item.attr('rel');
	 var form = item.parents('form:first');
	
	 if (item.val() === '')
	 {
	 item.val(text);
	 //item.css('color', '#a08c89');
	 item.css('color', '#666666');
	 }
	 
	 item.bind('focus.placeholder', function(event) {
	 if (item.val() === text)
	 item.val('');
	 item.css('color', '');
	 });
	 
	 item.bind('blur.placeholder', function(event) {
	 if (item.val() === '')
	 {
	 item.val(text);
	 item.css('color', '#666666');
	 }
	 });
	 
	 form.bind("submit.placeholder", function(event) {
	 if (item.val() === text)
	 item.val("");
	 });
	 
	 });
	
	$('#form_submit').click(function(){
		//Setup any needed variables.
		var input_name = $('#form_name').val(),
			input_email = $('#form_email').val(),
			//input_subject = $('#form_subject').val(),
			input_message = $('#form_message').val(),
			response_text = $('#response');
			//Hide any previous response text 
			response_text.hide();
			
			//Change response text to 'loading...'
			response_text.html('<span>Loading...</span>').show();
			
			//Make AJAX request 
			$.post('http://www.mexicanstandoffdesign.com/form/contact-send.php', {name: input_name, email: input_email, message: input_message}, function(data) {
				response_text.html('<span>'+ data +'</span>');
			});
			
			//Cancel default action
			return false;
	});

	$('#human_btn').click(function() {
		if ( $('#human input[type=text]').attr('value') == 34 ) $('#human').html('<a href="mailto:elmexicanstandoff@gmail.com?subject=Hello there!">elmexicanstandoff@gmail.com</a>');
	});
	
});
