﻿/**
 * SMDHU Public Website Standard Page JavaScript
 * Copyright (c) 2008 Simcoe Muskoka District Health Unit
 * Date: 7/30/2008
 *
 * @author Kevin Pipher
 * @version 0.1.0
 */
$(document).ready(function(){

    //set up the pop-down trigger for the topics menu
    setupPopDownTrigger($("a.siteSearchButton"), $("#menuSearchPopdown"));

    //during page load, check to see if resolution cookie exists
    var cookieWidth = getResCookie();
    
    //if it exists and is set, set the resolution based on it, otherwise use the browser width
    if (cookieWidth > 0) {
        setResStyleSheet(cookieWidth);
    }
    else {
        setResStyleSheet($(window).width());
    }
    
    //add an event listener to set the stylesheet during resize
    $(window).resize(function(){
    
        //get the current and cookie-stored width
        var currentWidth = $(window).width();
        var cookieWidth = getResCookie();        
        
        //if the width has changed, update the stylesheet
        if (cookieWidth != currentWidth) {
            setResStyleSheet(currentWidth);   
        }
        
    });
     
});
