// Main Functions 

// Determine the size of the screen on the clients system. If it is an ipad, load the mobiel stylesheet. Otherwise, open the smallscreen or widescreen
if (navigator.userAgent.match(/iPad/i) != null) {
    // Mobile Styles
    document.write('<link rel="stylesheet" href="css/mobile.css" media="screen" />');
    // iPad additions
    document.write('<link rel="stylesheet" href="css/ipad.css" media="screen" />');
    // Mobile Functions

}
else if (document.documentElement.offsetWidth < 1024) {
    // Mobile Styles
    document.write('<link rel="stylesheet" href="css/mobile.css" media="screen" />');
    // Mobile Viewport and app settings
    document.write('<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;" />');
}
else {
    var windowHeight = $(window).height();
    var windowWidth = $(window).width();

    // Write StyleSheets
    document.write('<link rel="stylesheet" href="css/homeStyle.css" media="screen" />');
    document.write('<link href="css/global.css" rel="stylesheet" type="text/css"/>');

    if (document.documentElement.offsetWidth < 1025) {
        document.write('<link rel="stylesheet" href="css/smallScreen.css" media="screen" />');
    }

    if (windowHeight < 800 || windowWidth < 1400) {
        document.write('<link rel="stylesheet" href="css/smallScreen.css" media="screen" />');
    }

    var firstTimer = setTimeout("firstAnim()", 1000);
    var secondTimer = setTimeout("secondAnim()", 1500);
    var thirdTimer = setTimeout("thirdAnim()", 2000);
    var fourthTimer = setTimeout("fourthAnim()", 2500);
    var firthTimer = setTimeout("fithAnim()", 3000);

    function firstAnim() {
        $('.topNav').stop().animate({ width: '45%' }, { queue: false, duration: 500 });
        $('.logoWrap').stop().animate({ width: '35%' }, { queue: false, duration: 500 });
        $('.footer').stop().animate({ height: '4%' }, { queue: false, duration: 500 });

    }

    function secondAnim() {
        $('.mainContent').stop().animate({ height: '68%' }, { queue: false, duration: 500 });
    }

    function thirdAnim() {
        $('.mainContentLeft').fadeIn('slow');
    }

    function fourthAnim() {
        $('.mainContentRight').fadeIn('slow');
    }
    function fithAnim() {
        $('.bgImage').fadeIn('slow');
        $('.topNav ul').fadeIn('slow');
        $('.logo').fadeIn('slow');
    }

}



//Tweaks for nav and thumbs etc
$(document).ready(function () {
    $(".tourThumb").hover(
	  function () {
	      $(this).stop().animate({ opacity: 1 }, { queue: false, duration: 500 });

	  },
	  function () {
	      $(this).stop().animate({ opacity: 0.7 }, { queue: false, duration: 500 });
	  }
	);

	  //$('.toursFeed ul li p:contains("Val de Loire")').html().replace('Val de Loire', '<em>Val de Loire</em>');
    
});
