// JavaScript Document

$(function(instantiate) {
	$(document).ready(function(){
							   
		var myWidth = $(window).width();
		var myHeight = $(window).height();
		var ratio = 1440/900;
		
		$('#navBack').css('background','#FFF').fadeTo(0,0.9);
		$('#nav a').css('color','#000');
		
function navDelay() {		
		$('#nav').animate({
			top: '+=69px',
		}, 1000, "swing").css('color','#000');
}
		window.setTimeout(navDelay, 1500);
						
		if((myWidth/myHeight) >= ratio) {
						
			$('#content').css({
				width: function() {
					return (myWidth * 1.05) + "px";
				},
				height: function() {
				return ((myWidth / ratio) * 1.0125) + "px";
				}
			});
			$('#backgroundOther').css({
				width: function() {
					return (myWidth * 1.0025) + "px";
				},
				height: function() {
				return ((myWidth / ratio) * 1.0025) + "px";
				}
			});
			$('#backgroundOther img').css({
				width: function() {
					return (myWidth * 1.0025) + "px";
				},
				height: function() {
				return ((myWidth / ratio) * 1.0025) + "px";
				}
			});
			$('#foreground').css({
				width: function() {
					return (myWidth * 1.3) + "px";
				},
				height: function() {
				return ((myWidth / ratio) * 1.0125) + "px";
				}
			});
		} else if((myWidth/myHeight) < ratio) {
			$('#content').css({
				width: function() {
					return ((myHeight * ratio) * 1.05) + "px";
				},
				height: function() {
				return (myHeight * 1.0125) + "px";
				}
			});
			$('#backgroundOther').css({
				width: function() {
					return ((myHeight * ratio) * 1.0025) + "px";
				},
				height: function() {
				return (myHeight * 1.0025) + "px";
				}
			});
			$('#backgroundOther img').css({
				width: function() {
					return ((myHeight * ratio) * 1.0025) + "px";
				},
				height: function() {
				return (myHeight * 1.0025) + "px";
				}
			});
			$('#foreground').css({
				width: function() {
					return ((myHeight * ratio) * 1.3) + "px";
				},
				height: function() {
				return (myHeight * 1.0125) + "px";
				}
			});
		}
			$('#parallax .parallax_layer').parallax({
				mouseport: $('#parallax')
			}); 
		
	});
});

$(function(loadRight) {
	if ($.browser.msie || $.browser.mozilla) {
		$('#backgroundOther,#content,#foreground').show();
	} else {
	var layers = new Array;
	layers[0]=$('#backgroundOther img');
	layers[1]=$('#content img');
	layers[2]=$('#foreground img');
	
	$.each(layers,function(){
		$(this).load(function(){
			$(this).parent().show();
		});
	});
	}
});
			  
$(function(imageResize) {
	   
	$(window).bind({
		resize: function(event) {
			var myWidth = $(window).width();
			var myHeight = $(window).height();
			var ratio = 1440/900;
			
			if((myWidth/myHeight) >= ratio) {
			
				$('#content').css({
					width: function() {
						return (myWidth * 1.05) + "px";
					},
					height: function() {
						return ((myWidth / ratio) * 1.0125) + "px";
					}
				});
				$('#backgroundOther').css({
					width: function() {
						return (myWidth * 1.0025) + "px";
					},
					height: function() {
						return ((myWidth / ratio) * 1.0025) + "px";
					}
				});
				$('#backgroundOther img').css({
					width: function() {
						return (myWidth * 1.0025) + "px";
					},
					height: function() {
						return ((myWidth / ratio) * 1.0025) + "px";
					}
				});
				$('#foreground').css({
					width: function() {
						return (myWidth * 1.3) + "px";
					},
					height: function() {
						return ((myWidth / ratio) * 1.0125) + "px";
					}
				});
			} else if((myWidth/myHeight) < ratio) {
				$('#content').css({
					width: function() {
						return ((myHeight * ratio) * 1.05) + "px";
					},
					height: function() {
						return (myHeight * 1.0125) + "px";
					}
				});
				$('#backgroundOther').css({
					width: function() {
						return ((myHeight * ratio) * 1.0025) + "px";
					},
					height: function() {
						return (myHeight * 1.0025) + "px";
					}
				});
				$('#backgroundOther img').css({
					width: function() {
						return ((myHeight * ratio) * 1.0025) + "px";
					},
					height: function() {
						return (myHeight * 1.0025) + "px";
					}
				});
				$('#foreground').css({
					width: function() {
						return ((myHeight * ratio) * 1.3) + "px";
					},
					height: function() {
						return (myHeight * 1.0125) + "px";
					}
				});
			};
				$('#parallax .parallax_layer').parallax({
					mouseport: $('#parallax')
				}); 
			
		}
	});
});


var preLoad = new Array();
					
		preLoad[0] = new Image(); 
		preLoad[0].src="assets/images/pages/collections/static-bg.jpg";
		preLoad[1] = new Image(); 
		preLoad[1].src="assets/images/pages/inquiries/static-bg.jpg";
		preLoad[2] = new Image(); 
		preLoad[2].src="assets/images/pages/press/static-bg.jpg";
		preLoad[3] = new Image(); 
		preLoad[3].src="assets/images/pages/press/static-bg.jpg";
		preLoad[4] = new Image(); 
		preLoad[4].src="assets/images/pages/shopsplash/static-bg.jpg";
		preLoad[5] = new Image(); 
		preLoad[5].src="assets/images/pages/stockists/static-bg.jpg";
		preLoad[6] = new Image(); 
		preLoad[6].src="assets/images/pages/story/static-bg.jpg";
		preLoad[7] = new Image(); 
		preLoad[7].src="assets/images/collections/fall_2011_look_031.jpg";
		preLoad[8] = new Image(); 
		preLoad[8].src="assets/images/collections/resort_2011_look_022.jpg";
		preLoad[9] = new Image(); 
		preLoad[9].src="assets/images/collections/spring_2011_look_031.jpg";
		preLoad[10] = new Image(); 
		preLoad[10].src="assets/images/collections/fall_2011_look_001.jpg";
		preLoad[11] = new Image(); 
		preLoad[11].src="assets/images/collections/fall_2011_look_002.jpg";
		preLoad[12] = new Image(); 
		preLoad[12].src="assets/images/collections/spring_2011_look_001.jpg";
		preLoad[13] = new Image(); 
		preLoad[13].src="assets/images/collections/spring_2011_look_002.jpg";
		preLoad[14] = new Image(); 
		preLoad[14].src="assets/images/collections/resort_2011_look_001.jpg";
		preLoad[15] = new Image(); 
		preLoad[15].src="assets/images/collections/resort_2011_look_002.jpg";
		preLoad[16] = new Image(); 
		preLoad[16].src="assets/images/pages/collections/thumbs.png";
		preLoad[17] = new Image(); 
		preLoad[17].src="assets/images/pages/collections/scrollerBox_logo.png";

