<!--//--><![CDATA[//><!--

function validateSearch(obj) {
	if(obj.value == "") {
		alert("Please enter a search phrase");
		return false;
	} else {
		location.href = '/cms/search/search2.asp?zoom_query=' + obj.value;
		return false;
	}
}

function flashWrite(flashfile,x,y,flashvar) {
	document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='"+ x +"' height='"+ y +"'>");
	document.write("<param name='movie' value='"+ flashfile +"' />");
	document.write("<param name='quality' value='high' />");
	document.write("<param name='flashvars' value='"+ flashvar +"' />");
	document.write("<param name='wmode' value='transparent' />");
	document.write("<embed src='"+ flashfile +"' wmode='transparent' ");
	document.write("flashvars='"+ flashvar +"'  ");
	document.write("quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='"+ x +"' height='"+ y +"'></embed>");
	document.write("</object>");
}

function printYear() {
	var today = new Date();
	document.write(today.getFullYear());
}

function writeEmail(email) {
	document.write('<a href="mailto:'+email+'">'+email+'</a>');
}

function changeTextSize(textSize) {
	document.body.className = 'site ' + textSize;
	return false;
}

function printPage() {
	window.print();
	return false;
}

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;
}

function startAnim() {
    galleryPlay = true;
    $('div.galleryProgress').fadeIn();
    $('div.galleryProgressOverlay').css({ width:0 }).animate({ width: 100 }, 5000, 'linear', function(){
        startAnim();
        $('div.galleryBox a.btnCarouselNextAlt').click();
    });
}
function stopAnim() {
    galleryPlay = false;
    $('div.galleryProgressOverlay').stop();
    $('div.galleryProgress').fadeOut();
}
function resetAnim() {
    // $('div.galleryProgressOverlay').css({ width:0 });
    $('div.galleryProgressOverlay').stop();
    startAnim();
}

$(document).ready(function(){
    $('a.lightBox').lightBox({
        imageLoading: '/system/assets/images/lightbox/lightbox-ico-loading.gif',
        imageBtnClose: '/system/assets/images/lightbox/lightbox-btn-close.gif',
        imageBtnPrev: '/system/assets/images/lightbox/lightbox-btn-prev.gif',
        imageBtnNext: '/system/assets/images/lightbox/lightbox-btn-next.gif'
    });

    $('#banner > div.carouselMask > ul').adidoCarousel({
        animCallback:function(e, c, s, o){
            e.children('li').children('div.txt').css({ left: -940 });
            e.children('li:nth-child(' + c + ')').children('div.txt').delay(2000).animate({ left: 0 }, 1000);
        },
        animDelay: 100,
        animSpeed: 100,
        mode: 'fade',
        pager: true,
        pagerElement: '#banner .carouselPager',
        pagerStyle: 'image'
    });
    $('div#banner div.rightCol ul').adidoCarousel({ buttons:false, mode: 'fade' });
    
    $('input.textClear').focus(function() {
        var t = $(this).attr('title');
        var v = $(this).val();
        if (v == t) {
            $(this).val('');
        }
    }).blur(function() {
        var t = $(this).attr('title');
        var v = $(this).val();
        if (v == '') {
            $(this).val(t);
        }
    });
    $('textarea.textClear').focus(function() {
        var t = $(this).attr('title');
        var v = $(this).text();
        if (v == t) {
            $(this).text('');
        }
    }).blur(function() {
        var t = $(this).attr('title');
        var v = $(this).text();
        if (v == '') {
            $(this).text(t);
        }
    });
    
    $('#banner div.carouselPager li').hover(function(){
        $(this).stop().animate({ top: -10 });
    }, function(){
        $(this).stop().animate({ top: 0 });
    });
    
    /* Gallery / Carousel */
    
    var galleryPlay = false;
    
    
    $('div.galleryBox ul.galleryListing img').addClass('pagerImg');
    $('div.galleryBox ul.galleryListing').adidoCarousel({ 
        animCallback: function(e, c, s, o){
            e.children('li').children('p').slideUp().hide();
            e.children('li:nth-child(' + c + ')').children('p').delay(1500).slideDown();
            
        },
        autoStart: false,
        buttonNext: 'div.galleryBox a.btnCarouselNextAlt',
        buttonPrev: 'div.galleryBox a.btnCarouselPrevAlt',
        mode: 'fade',
        pager: true,
        pagerElement: 'div.galleryBox .carouselPager',
        pagerMove: true,
        pagerStyle: 'image',
        resizeMask: true
    });
    
    // startAnim();
    $('div.galleryControls a.btnCarouselPlay').click(function(e){
        e.preventDefault();
        var c = $(this).children('span');
        if (galleryPlay) {
            galleryPlay = false;
            stopAnim();
        } else {
            galleryPlay = true;
            startAnim();
        }
    });
    $('div.galleryControls a.btnCarouselPrev').click(function(e){
        e.preventDefault();
        if(galleryPlay){
            resetAnim();
        }
        $('a.btnCarouselPrevAlt').click();
    });
    $('div.galleryControls a.btnCarouselNext').click(function(e){
        e.preventDefault();
        if(galleryPlay){
            resetAnim();
        }
        $('a.btnCarouselNextAlt').click();
    });
    $('a.btnCarouselFull').click(function(e){
        $('ul.galleryListing li.acActive a').click();
        stopAnim();
    });
    
    $('div.galleryBox div.carouselPager ul').adidoCarousel({
        autoStart: false,
        buttonNext: 'div.galleryBox a.btnCarouselNextAlt',
        buttonPrev: 'div.galleryBox a.btnCarouselPrevAlt',
        clickContinue: false,
        mode: 'loop'
    });
    
    $('div.galleryBox div.carouselPager ul li').hover(function(){
        var img = $(this).children('img').clone();
        var position = $(this).position();
        var parentPosition = $(this).parent().parent().position();
        var totalOffset = position.left + parentPosition.left;
        // totalOffset = totalOffset + 10;
        $('div.carouselPagerHover').show().html(img).css({ left: totalOffset, top: -110 });
    }, function(){
        $('div.carouselPagerHover').hide();
    }).click(function(e){
        var index = $(this).index();
        var w = $(this).outerWidth(true);
        var $parent = $(this).parent();
        
        for(i = 0; i < index; i++){
            // Clone Items
            $parent.children('li:eq(' + i + ')').clone(true).appendTo($parent);
        }
        var l = w * index;
        $parent.animate({ left: -l }, function(){
            for(i = 0; i < index; i++){
                // Remove items
                $parent.children().first().remove();
            }
            $parent.css({ left: 0 }).children().removeClass('acpActive').first().addClass('acpActive');
        });
    });
    
    $(':first-child').addClass('first');
    $(':last-child').addClass('last');
});

//--><!]]>
