var banner;
$(document).ready(function(){

	//Homepage carousel
	$('#affiliatesScroll').jcarousel({
		wrap: 'circular'
	});

	//Video carousel
	$('#araCarousel').jcarousel({
		wrap: 'circular'
	});

	//Video gallery
	$('.videoThumb a').click( function() {
		$('.videoThumb a').removeClass("on");								   
		var src = $(this).attr("href");
		$(".mainVideo").html('<object width="640" height="385"><param name="movie" value="' + src +'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="' + src +'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>');
		$(this).addClass("on");
		return false;
	});
	
	//Homepage promo banners
	$("#promoBox div").hover(function() {
		banner = $(this).attr("rel")				  
		$("#promoBox").css("backgroundImage","url('http://ara.fivesite.co.uk/wp-content/themes/ara/images/promoBox/" + banner + ".jpg')");
		$(this).css("color", "#000000");
		},function() {
		$("#promoBox").css("backgroundImage","none");
	});

	//Zebra striping
	$("tr:nth-child(odd)").addClass("odd");	
	
	Cufon.replace('h1, .welcome', { fontFamily: 'universltstd-light' });
	Cufon.replace('h2', { fontFamily: 'Helvetica' });
	
	/** Rounded Corders for images */
    $(".alignright, .alignleft, .aligncenter").each(function() {

        var img = $(this);        

        // build wrapper
        var wrapper = $('<div class="rounded_wrapper"></div>');
        wrapper.width(img.width());
        wrapper.height(img.height());

        // move CSS properties from img to wrapper
        wrapper.css('float', img.css('float'));
        img.css('float', 'none')

        wrapper.css('margin-right', img.css('margin-right'));
        img.css('margin-right', '0')

        wrapper.css('margin-left', img.css('margin-left'));
        img.css('margin-left', '0')

        wrapper.css('margin-bottom', img.css('margin-bottom'));
        img.css('margin-bottom', '0')

        wrapper.css('margin-top', img.css('margin-top'));
        img.css('margin-top', '0')

        wrapper.css('display', 'block');
        img.css('display', 'block')

        // wrap image
        img.wrap(wrapper);

        // add rounded corners
        img.after('<div class="tl"></div>');
        img.after('<div class="tr"></div>');
        img.after('<div class="bl"></div>');
        img.after('<div class="br"></div>');

    });
    
	var leftcolHeight = $('#leftPart').height();
	var rightcolHeight = $('#newsPart').height();


	if ($('#middlePart').height() < leftcolHeight) {
	    $('#middlePart').height(leftcolHeight)
	}
	
	if ($('#middlePart').height() < rightcolHeight) {
	    $('#middlePart').height(rightcolHeight)
	}
	
	if ($('#rightPart').height() < leftcolHeight) {
	    $('#rightPart').height(leftcolHeight)
	}


});



