///////////////////////////////////////
// Init Carousel widget 
///////////////////////////////////////

	function mycarousel_initCallback(carousel)
	{
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
			carousel.startAuto(0);
		});
	
		carousel.buttonPrev.bind('click', function() {
			carousel.startAuto(0);
		});
	
		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.stopAuto();
		}, function() {
			carousel.startAuto();
		});
	};
	jQuery(document).ready(function() {
		jQuery('#slider').jcarousel({
			auto: 5,
			scroll: 1,
			wrap: 'last',
			initCallback: mycarousel_initCallback
		});
	});

function checkbox_highlight() {
		$("div.selectboxes").removeClass("checked");
		$("div.selectboxes:has(input:checked)").addClass("checked");	
	}
	
function popup(url) {
	var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
	if (is_chrome) { 
		// damn Chrome popup bug
		return true; 
	} else {
		newwindow=window.open(url,'name','height=480,width=640');	
		newwindow.focus(); 
		return false;
	}
}



// Read a page's GET URL variables and return them as an associative array.
function getUrlVars()
{
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');

    for(var i = 0; i < hashes.length; i++)
    {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }

    return vars;
}


///////////////////////////////////////
// Init pngfix for IE 5.5 & 6
///////////////////////////////////////
	$(document).ready(function(){ 
        $(document).pngFix();

		var params = {
			"wmode":"transparent"
		};
		swfobject.embedSWF("inc/top_flash.swf", "masthead", "930", "222", "9.0.0", "../flash/expressInstall.swf","",params);
		
		
		/*  Setup marquis tabs  */

		var tabs = $('div.tabbed div.tab');
			
		$('div.tabbed ul.tab-list li a').click(function () {
			tabs.hide().filter(this.hash).fadeIn(500);
			$('div.tabbed ul.tab-list li a').removeClass('selected');
			$(this).addClass('selected');
			return false;
		}).filter(':first').click();		

		
		/*  Setup marquis thumbs  */
		$('div.tab').each(function(){
			var spa = $(this).find('div.spa-details'),
				tab = $(this).find('ul.spa-thumbs li a');
				
			tab.click(function () {
				spa.hide().filter(this.hash).fadeIn(500);
				tab.removeClass('selected');
				$(this).addClass('selected');
				return false;
			}).filter(':first').click();		
		});
		/* fix nth-child for non-supported browsers */
		$('ul.spa-thumbs li:nth-child(4n)').css('margin-right',0);
		
		/* Fix youtube tab */
		var get = getUrlVars();
		
		if( typeof get['v']!='undefined' ) {
			$('ul.tab-list a[href="#film"]').click();
		}
				
	}); 
	

