﻿var $jq = jQuery;

function openWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


$(document).ready(function() {
	//highlighter.highlight();					   
    var button = $('#showhidebanner');
	var pathname;
	if (jQuery.url!= undefined){		
		pathname = jQuery.url.attr("path");
	}
    //alert(pathname);
    if (pathname != "/default.aspx") {
        //check the cookie when the page loads
        if ($.cookie('currentBannerToggle') != null) {
            if ($.cookie('currentBannerToggle') === 'hidden') {
                togglePhotoBanner(button, false);
            } else {
                togglePhotoBanner(button, true);
            }
        } else {
            $.cookie('currentBannerToggle', 'show', { path: '/' });
        }
    }
    //handle the clicking of the show/hide toggle button
    button.click(function() {
        //toggle the panel as required, base on current state
        $("#photo_rotator_photos").animate({ "height": "toggle" }, { duration: 1000 });
        if ($.cookie('currentBannerToggle') === 'hidden') { //     button.text() === "Show Banner") {
            togglePhotoBanner($(this), true);
        }
        else {
            togglePhotoBanner($(this), false);
        }
    });

});


function togglePhotoBanner(button, show) {

    var panel = $('#photo_rotator_photos');
   
    if (show) {
        $.cookie('currentBannerToggle', 'show', { path: '/' });
        panel.attr('class', 'pbshow');   
        button.text('Hide Banner');
        button.attr('class','collapse');
    }
    else {       
        $.cookie('currentBannerToggle', 'hidden', { path: '/' });      
        panel.attr('class', 'pbhide'); 
        button.text('Show Banner');
        button.attr('class','expand');
    }
}





function toggle( targetId ){ 
		  if (document.getElementById){
		      var target = document.getElementById(targetId);      
		     		       
				if (target.style.display == "none"){
				    target.style.display = "";				   
				} else {
				target.style.display = "none";				 
				} 
		}
}

function toggleFAQ(divID, linkID) {
    if (document.getElementById) {
        var targetdiv = document.getElementById(divID);
        var targetlink = document.getElementById(linkID);
        if (targetdiv.style.display == "none") {
            targetdiv.style.display = "";
            targetlink.className = 'collapse';
        } else {
            targetdiv.style.display = "none";
            targetlink.className = 'expand'
        }
    }
}
		
function toggleall(){
	
	for (var i = 1; i < 14; i++){
	 	targetid = "q" + i;
		target = document.getElementById(targetid);		
		 if (document.getElementById("showall").checked){
		 	target.style.display == "";
		}else{
			target.style.display = "none";
		}
	}alert("toggle all");
}

function fixIE6TransparentPNG() {
    // IE6 transparent PNG fixes
    //$jq('#logo img').ifixpng(); // no need to be transparent
    $jq('#logindisplay').ifixpng();
    $jq('#weather').ifixpng();
    $jq('#searcharea').ifixpng();
    $jq('.home-header').ifixpng();
    $jq('#photo_rotator_photos .nav .next').ifixpng();
    $jq('#photo_rotator_photos .nav .previous').ifixpng();
    $jq('#ttdsearchbutton').ifixpng();
    $jq('#newsletterbutton').ifixpng();
    //$jq("#events .rss").ifixpng(); //handled by .home-header
    //$jq("#blog .rss").ifixpng();
    // $jq("ul#menu li:hover").ifixpng(); // 8-bit non-transparent
}

///**** Header Slide Show ****/
//var slides = [];
//var slideIndex = 0;

//var nextSlide = null;
//var prevSlide = null;

//function slideshowHover() {
//    var photo = $jq('#rotator-photo').hover(function() {       
//        // show the navigation
//        $jq('#photo_rotator_photos .nav .next-container').fadeTo('fast', 0.7);
//        $jq('#photo_rotator_photos .nav .previous-container').fadeTo('fast', 0.7);
//        $jq('#photo_rotator_photos .mask').fadeTo('fast', 0.5);
//    }, function() {
//        $jq('#photo_rotator_photos .nav .next-container').fadeOut('fast');
//        $jq('#photo_rotator_photos .nav .previous-container').fadeOut('fast');
//        $jq('#photo_rotator_photos .mask').fadeOut('fast');
//    });
//}


//function initializeSlideshow() {
//    slideshowHover();

//    if (slides.length <= 1)
//        return;

//    $jq('#photo_rotator_photos .nav .previous').click(function(e) {
//        e.stopPropagation();
//        moveToPreviousSlide(e);
//    });
//    $jq('#photo_rotator_photos .photo img').click(function(e) {
//        e.stopPropagation();
//        moveToNextSlide(e);
//    });
//    $jq('#photo_rotator_photos .nav').click(function(e) {
//        moveToNextSlide(e);
//    });

//    preloadNextSlide();
//}

//function moveToNextSlide(e) {
//    prevSlide = slides[slideIndex]; // previous slide is current

//    slideIndex++;
//    if (slideIndex > slides.length - 1)
//        slideIndex = 0;
//    nextSlide = slides[slideIndex];

//    // show next image
//    $jq('#photo_rotator_photos .photo img').attr('src', '/images/rotator/' + nextSlide[0]).attr('alt', nextSlide[1]);
//    $jq('#photo_rotator_photos .caption').html(nextSlide[1]);
//    preloadNextSlide();
//    e.preventDefault();
//}

//function moveToPreviousSlide(e) {
//    nextSlide = slides[slideIndex]; // next slide is current
//    slideIndex--;

//    // calculate previous slide
//    if (slideIndex < 0)
//        slideIndex = slides.length - 1;
//    prevSlide = slides[slideIndex];

//    // show next image
//    $jq('#photo_rotator_photos .photo img').attr('src', '/images/rotator/' + prevSlide[0]).attr('alt', prevSlide[1]);
//    $jq('#photo_rotator_photos .caption').html(prevSlide[1]);
//    preloadNextSlide();
//    e.preventDefault();
//}
//function preloadNextSlide() {
//    var nextImage = new Image();
//    nextIndex = slideIndex + 1;
//    if (nextIndex > slides.length - 1)
//        nextIndex = 0;
//    var nextSlidePre = slides[nextIndex];
//    nextImage.src = '/images/rotator/' + nextSlidePre[0];
//}


//function setActiveStyleSheet(title) {
//    var i, a, main;
//    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
//        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
//            a.disabled = true;
//            if (a.getAttribute("title") == title) a.disabled = false;
//        }
//    }
//    
//}

//function getActiveStyleSheet() {
//    var i, a;
//    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
//        if (a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
//    }
//    return null;
//}

//function getPreferredStyleSheet() {
//    var i, a;
//    for (i = 0; (a = document.getElementsByTagName("link")[i]); i++) {
//        if (a.getAttribute("rel").indexOf("style") != -1
//       && a.getAttribute("rel").indexOf("alt") == -1
//       && a.getAttribute("title")
//       ) return a.getAttribute("title");
//    }
//    return null;
//}

//function createCookie(name, value, days) {
//    if (days) {
//        var date = new Date();
//        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
//        var expires = "; expires=" + date.toGMTString();
//    }
//    else expires = "";
//    document.cookie = name + "=" + value + expires + "; path=/";
//    
//}

//function readCookie(name) {
//    var nameEQ = name + "=";
//    var ca = document.cookie.split(';');
//    for (var i = 0; i < ca.length; i++) {
//        var c = ca[i];
//        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
//        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
//    }
//    return null;
//}

//window.onload = function(e) {
//    var cookie = readCookie("style");
//    var title = cookie ? cookie : getPreferredStyleSheet();
//    setActiveStyleSheet(title);
//}

//window.onunload = function(e) {
//    var title = getActiveStyleSheet();
//    createCookie("style", title, 365);
//}

//var ssCookie = readCookie("style");
//var ssTitle = ssCookie ? ssCookie : getPreferredStyleSheet();
//setActiveStyleSheet(ssTitle);





