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;
}

$(document).ready(function() {
    if ($('div.lightbox').length > 0) {
        $('div.lightbox a').lightBox({
            imageLoading: '/cms/outertemplates/images/lightbox/lightbox-ico-loading.gif',
            imageBtnClose: '/cms/outertemplates/images/lightbox/lightbox-btn-close.gif',
            imageBtnPrev: '/cms/outertemplates/images/lightbox/lightbox-btn-prev.gif',
            imageBtnNext: '/cms/outertemplates/images/lightbox/lightbox-btn-next.gif'
        });
    }
    $(':first-child').addClass('first');
    $(':last-child').addClass('last');
    $('a[rel=newWindow]').attr('target', '_blank');

    $('#homeCarousel ul').adidoCarousel();
    $('#landingCarousel div.carouselMask ul').adidoCarousel({
        pager: true,
        pagerAuto: false
    });
    $('div.quoteMask ul').adidoCarousel({ mode: 'fade', dynamicResize: true });

    $('#infoBox h2').addClass('btn').wrapInner('<span></span>').click(function() {
        $this = $(this);
        if ($(this).hasClass('active')) {
            // Do nothing
        } else {
            $(this).siblings('.active').removeClass('active').next().slideToggle('fast').end().end().addClass('active').next().slideToggle('slow');
        }


    }).hover(function() {
        $(this).addClass('btnhover');
    },
     function() {
         $(this).removeClass('btnhover');
     }).next().hide();

    $('div.specialOffer').show().prev().addClass('active');

    $('table.tblContent, table.tblDefaultContent').each(function() {
        var h = 0;
        $(this).find('div.contentBox').each(function() {
            var th = $(this).height();
            if (th > h) {
                h = th;
            }
        }).height(h);
    });

    var h = 0;
    $('div.serviceBox').each(function() {
        var s = $(this).height();
        if (s > h) {
            h = s;
        }
    }).height(h);

    $('.miniBox, #mainCol, .serviceBox, #productContent').corners();
    
    var l = $('#infoBar ul.feedListing').size();
    if (l > 0) {
        var options = {
            newsList: "#infoBar ul.feedListing",
            startDelay: 10,
            placeHolder1: " []",
            tickerRate: 20
        };
        $().newsTicker(options);
    }

    $('.infoBox').each(function() {

        var n = $('#infoBox h2').size();

        if ($('#carousel').size() > 0) {
            var h = $('#carousel').height();
        } else {
            var h = 270;
        }
        h = h - ((32 * n) + 9 + 10 + 2);
        $(this).height(h);
    });
    $('#carousel ul.feedListing a').bigTarget();

    $('div#infoBox').each(function() {
        if ($('#carousel').size() > 0) {
            var h = $('#carousel').height();
        } else {
            var h = 270;
        }
        $(this).height(h);
    });

    $('div#infoBox input.textBox').focus(function() {
        var v = $(this).val();
        var t = $(this).attr('title');
        if (v == t) {
            $(this).val('');
        }
    }).blur(function() {
        var v = $(this).val();
        var t = $(this).attr('title');
        if (v == '') {
            $(this).val(t);
        }
    });
});
