$(document).ready(function(){
	resCheck();
	$("#screenAlert").css({
		"width" : $(window).width(),
		"height" : $(window).height()
	})
	$("#screenAlertContent").css({
		"top" : ($(window).height() - $("#screenAlertContent").height())/2,
		"left" : ($(window).width() - $("#screenAlertContent").width())/2
	})
	if(isiPad){
		formatforipad()
	}
});

$(window).resize(function() {
	$("#screenAlert").css({
		"width" : $(window).width(),
		"height" : $(window).height()
	})
	$("#screenAlertContent").css({
		"top" : ($(window).height() - $("#screenAlertContent").height())/2,
		"left" : ($(window).width() - $("#screenAlertContent").width())/2
	})
	if(this.resizeTO) clearTimeout(this.resizeTO);
	this.resizeTO = setTimeout(function() {
		$(this).trigger('resizeEnd');
	}, 100);
});
$(window).bind('resizeEnd', function() {
	resCheck();
});

function resCheck(){
		var isiPad = navigator.userAgent.match(/iPad/i) != null;
		if(!isiPad){
			if($(window).width() < 920 || $(window).height() < 500){
				//$("#screenAlert").fadeIn("fast")
			}else{
				//$("#screenAlert").fadeOut("fast");
			}

			// CONCURSO NAVIDAD
			h_header = $('#header').outerHeight();
			h_footer = $('#footer').outerHeight();
			h_newsletter = $('#newsletter').outerHeight();
			h_window = $(window).height()-115;
			h = h_window-(h_header+h_footer);
			if(h>472)
				h = 472;
			//if(h<300)
				//h = 300;
			$('#newsletter').height(h);
			//$('#showroom_image').height(h);

			/*$(document).ready(function(){
				if($('#showroom').length){
					$('#footer').css('top','630px');
					//$('#footer').css('padding-top','30px');
					$('#footer').css('padding-bottom','40px');
				}
			});*/

		}else{
			$(document).ready(function(){
				if($('#newsletter').length){
					$('#footer').css('top','750px');
					$('#footer').css('width','830px');
					$('#footer').css('padding-top','30px');
					$('#footer').css('padding-bottom','40px');
					$('#newsletter').css('padding-top','30px');
					$('#newsletter').css('padding-left','60px');
					$('#newsletter').css('background-position','465px 40px');
					$('#newsletter').height(640);
					$('#header').css('padding-left','150px');
					//left_menu_marker = $('.menu_marker').first().css('left');
					//left_menu_marker = left_menu_marker.replace('px','');
				}

				/*if($('#showroom').length){
					$('#footer').css('top','630px');
					//$('#footer').css('padding-top','30px');
					$('#footer').css('padding-bottom','40px');
				}*/
			});
		}	
}


var myScroll;
var isiPad = navigator.userAgent.match(/iPad/i) != null;
function makescroller(){
	myScroll = new iScroll('photoReelInner',{bounceLock:true,checkDOMChanges: true, fadeScrollbar:true, hScrollbar : false});
	//document.addEventListener('touchstart', function(e){ $("#photoReelInner").preventDefault(); }, false);
}
function formatforipad(){
	$("#scrollBar").remove();	
}
if(isiPad){
document.addEventListener('DOMContentLoaded', makescroller, false);
}

function resetScroller(){
			$("#photoReelInner > div").hide()
			$("#photoReelInner").css({
				"width" : 0
			})
			$("#photoReelInner > div").show()
			$("#photoReelInner").css('left', 0);
			setTimeout(function () { myScroll.refresh(); myScroll.scrollTo(0,0,"0ms") }, 0)
			formatforipad()
		}
