$(document).ready(function(){

/* ------------------------------------------ Drop Down mobile ------------------------------------------ */

	if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
		
		$('#nav_clothing_trigger').toggle(function(){
			$('#nav_clothing_dd').show();
		},function() {
			$('#nav_clothing_dd').hide();
		});

		$('#nav_footwear_trigger').toggle(function(){
			$('#nav_footwear_dd').show();
		},function() {
			$('#nav_footwear_dd').hide();
		});

		$('#nav_accessories_trigger').toggle(function(){
			$('#nav_accessories_dd').show();
		},function() {
			$('#nav_accessories_dd').hide();
		});

		$('#nav_about_trigger').toggle(function(){
			$('#nav_about_dd').show();
		},function() {
			$('#nav_about_dd').hide();
		});
		
	}
	
	


/* ------------------------------------------ Home slides ------------------------------------------ */

	$('#brands_slideshow').cycle ({
		fx: 'scrollVert',
		speed:300,
		timeout:0,
		pager: '#brands_slideshow_nav_wrapper',
		pagerAnchorBuilder: function(idx, slide) {
            // return sel string for existing anchor
            return '#brands_slideshow_nav_wrapper li:eq(' + (idx) + ') a';
        }

	});

/* ------------------------------------------ Brand logo scroll ------------------------------------------ */	
	
	$('#brands_slideshow_nav_wrapper').hoverscroll({
		vertical:	true,
		width:		365,
		height:		455,
		arrowsOpacity: 1
	});

/* ------------------------------------------ Home Gallery ------------------------------------------ */

	var homeSlidesMain = $('#home_featured_main li').length;
	var homeSlidesSide = $('#home_featured_side li').length;
	
	if (homeSlidesSide > 1) {	
		$('#home_featured_side').cycle ({
			fx: 'fade',
			speed:400,
			timeout:7000,
			random:1,
			delay:3500
		});
	}

	if (homeSlidesMain > 1) {	
		$('#home_featured_main').cycle ({
			fx: 'fade',
			speed:400,
			timeout:7000,
			random:1
		});
	}


/* ------------------------------------------ Restaurant ------------------------------------------ */

	$('#food-slides').cycle ({
		fx: 'fade',
		speed:600
	});

/* ------------------------------------------ History ------------------------------------------ */
	
	$('#history_slide_1').cycle ({
		fx: 'fade',
		speed:600
	});

/* ------------------------------------------ Newsletter signup ------------------------------------------ */	

	$('#top_newsletter_email').focus(function() {
		if($(this).val() == this.defaultValue)
		$(this).val("");
	});

	$('#top_newsletter_email').blur(function() {
		if($(this).val() == "")
		$(this).val(this.defaultValue);
	});

	$('#top_newsletter_form').ajaxForm(function() { 
		$('#top_newsletter_form').animate({'left':'400px'},750);
		$('#top_newsletter_success').animate({'left':'0px'},750);
		_gaq.push(['_trackPageview','/newsletter_success']);
    }); 


/* ------------------------------------------ Contact Page------------------------------------------ */	

	$('.contact_single, .contact_textarea, #saddr').focus(function() {
		if($(this).val() == this.defaultValue)
		$(this).val("");
	});

	$('.contact_single, .contact_textarea, #saddr').blur(function() {
		if($(this).val() == "")
		$(this).val(this.defaultValue);
	});

	$('#contact_submit').click(function(e) {
        if ( $('#contact_name').val() == 'Your name' ) {
			$('#contact_name').val("");
		}
        if ( $('#contact_email').val() == 'Your email address' ) {
			$('#contact_email').val("");
		}
		if ( $('#contact_tel').val() == 'Your telephone number' ) {
			$('#contact_tel').val("");
		}
		if ( $('#contact_msg').val() == 'Message' ) {
			$('#contact_msg').val("");
		}
    });

	$('#contact_form').validate({
		rules: {
			contact_name: "required",
			contact_email: {
				required:true,
				email:true
			},
			contact_tel: "required",
			contact_msg: "required"
		},
		messages: {
			contact_name: {
				required:"&uarr; Please enter your name"
			},
			contact_email: {
				required:"&uarr; Please enter your email address",
				email:"&uarr; Please enter a valid email address"
			},
			contact_tel: {
				required:"&uarr; Please enter a contact number"
			},
			contact_msg: {
				required:"&uarr; Please enter your message"
			}
		}
	});

	$('#contact_form').ajaxForm(function() { 
		$('#contact_form').animate({'left':'400px'},750);
		$('#contact_success').animate({'left':'30px'},750);
		_gaq.push(['_trackPageview','/contact_success']);
    }); 


});
