$ektron(document).ready(function () {
    //$ektron('#gastretch').width(($ektron(document).width()-990)/2); 
    $ektron('#fmessage-body').width((685 + ($ektron(document).width() - 990) / 2));
    function chkarrows() {
        cp = $("#carousel").position();
        if (cp.left < 0) { $("#goleft img").show(); }
        if (cp.left > -1) { $("#goleft img").hide(); }
        if (cp.left < -1914) { $("#goright img").hide(); }
        if (cp.left > -1913) { $("#goright img").show(); }
    }
    $ektron('#goright').hover(
		function () {
		    thep = $ektron("#carousel").position();
		    theo = thep.left + 9000;
		    $ektron("#carousel").animate({
		        left: "-2400px"
		    }, theo);
		},
		function () {
		    $ektron("#carousel").stop();
		    chkarrows();
		});
    $ektron('#goleft').hover(
		function () {
		    thep = $ektron("#carousel").position();
		    theo = thep.left * -3;
		    $ektron("#carousel").animate({
		        left: "0px"
		    }, theo);
		},
		function () {
		    $ektron("#carousel").stop();
		    chkarrows();
		});
    //Preload images
    var xx = new Array();
    $ektron("#carousel li img").each(function (i) {
        xx[i] = $ektron('<img/>').attr('src', this.src.replace('_off', '_on'));
    });

    $ektron('#carousel li img').hover(
		function () {
		    this.src = this.src.replace(/_off/, "_on");
		},
		function () {
		    this.src = this.src.replace(/_on/, "_off");
		});

    $('.trigger').bind("click", function (e) {
        $(".indent-hide").hide().css({ color: 'white', backgroundColor: 'transparent' })
        $(".trigger").css({ color: '#00457a', fontWeight: 'bold', display: 'block', backgroundColor: 'transparent', height: '15px', padding: '2px' }).hover(function () { $(this).css('color', 'blue'); }, function () { $(this).css('color', '#00457a'); });
        if ($(this).next().hasClass("opened")) 
        {
            $(this).next().removeClass("opened");
            $(this).css("z-index","20");
        }
        else
        {
            $(".indent-hide").removeClass("opened");
            $(this).next().addClass("opened");
            $(this).css("z-index", "35");
            $(this).next().css("z-index", "40");
            $(this).next().toggle('fast', function () { $(this).prev().height($(this).height() + 17); $(this).css({ marginTop: (($(this).height()) * -1) - 15, color: 'black' }); });
            $(this).css({ color: '#00457c', fontWeight: 'bold', display: 'list-item', listStylePosition: 'inside', listStyleType: "none", backgroundColor: '#CaDaea', padding: '5px', marginBottom: '5px' });
        }
    });

    dice = Math.ceil(Math.random() * 3);
    $("#homepicWrap img").attr("src", "/images/homepic" + dice + ".jpg");
    msgs = Array("No Message", "We deliver customized marketing solutions through<br/>superior implementation and dedicated client service.",
					 "We create functional and easy-to-navigate websites<br/>that achieve your company's online goals.",
					 "Our dedicated team of experts utilizes a comprehensive, yet<br/>creative approach to maximize your online marketing investment.");

    $("#fmessage-body").html(msgs[dice]);


});		
