$(function() {
	//Documentation located in special.docs.js
	//Sifr
	//$('div#subnav h3').sifr({ strSWF: '/flash/hoefler-text-italic.swf', strColor: '#361b0a', strWmode: 'transparent', strFlashVars: 'textalign=center&' },{ expressInstall: true });


	$('div#subnav h3').sifr({ strSWF: '/flash/hoefler-text-italic.swf', strColor: '#1B263D', strWmode: 'transparent', strFlashVars: 'textalign=center&' },{ expressInstall: true });
	$('div#content h1').sifr({ strSWF: '/flash/hoefler-text.swf', strColor: '#fffaed', strWmode: 'transparent', strCase: 'upper', strFlashVars: 'letterSpacing=4&' },{ expressInstall: true });
	$('div#content-item h3').sifr({ strSWF: '/flash/hoefler-text.swf', strColor: '#fffaed', strWmode: 'transparent', strCase: 'upper', strFlashVars: 'letterSpacing=2&' },{ expressInstall: true });
	$('body.home div#content div#home-content h3').sifr({ strSWF: '/flash/hoefler-text.swf', strColor: '#fffaed', strWmode: 'transparent', strCase: 'upper', strFlashVars: 'letterSpacing=2&h=14&' },{ expressInstall: true });
	$('div#weather-wrapper h4').sifr({ strSWF: '/flash/hoefler-text-italic.swf', strColor: '#ab9886', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });
	$('div#weather-wrapper h5').sifr({ strSWF: '/flash/hoefler-text-italic.swf', strColor: '#fffaed', strWmode: 'transparent', strCase: 'upper' },{ expressInstall: true });

	
	//Dropdown Nav
	if(BROWSER=='msie6') {
		$('#nav-primary li').hover(
			function() { $(this).addClass('over'); },
			function() { $(this).removeClass('over'); }
		)
	}
	
	// JQModal 
	var openFn=function(hash){
		hash.w.show();
		$('#dialog').css({left:($(window).width()-$('#dialog').width())/2,top:$(window).scrollTop()+10});
	};
	
	var hideFn=function(hash){
			hash.w.hide()
		hash.o.remove();
	};

	
   $('#dialog').jqm({onShow: openFn, onHide: hideFn});

	
	// Close Button Highlighting. IE doesn't support :hover. Surprise?
	if($.browser.msie) {
		$('div.jqmAlert .jqmClose')
		.hover(
		function(){ $(this).addClass('jqmCloseHover'); }, 
		function(){ $(this).removeClass('jqmCloseHover'); });
	}

	
    $('#photo-content').flash({
        swf:"flash/hearts-photo_gallery.swf",
        width:900,
        height:610,
			params:{
				allowscriptaccess:"always",
	         wmode:"transparent",
				flashvars:{
					imagesXML: 'flash/xml/hearts-gallery.xml'
				}
			}
    });


// Ride the carousel...
	$('#homecarousel').after('<div id="control-links">').cycle({ 
		fx:     'fade', 
		speed:  800, 
		timeout: 0, 
		next: '.next-link',
		pager:  '#control-links' 
	});
	
});

function mycarousel_initCallback(carousel) {
	var jcsize = parseInt($("#control-links li").size());
	//$('ul.jcarousel-list li:eq('+jcsize+')').find('.next').hide();
	//alert(jcsize);
	jQuery('#control-links a').bind('click', function() {
		var cindex = $(this).parent().attr("id");
		cindex = cindex.substring(1);
        carousel.scroll(jQuery.jcarousel.intval( cindex ));
		$("#control-links a img").attr("src","/images/layout/control1.png");
		$(this).children("img").attr("src","/images/layout/control2.png");
        return false;
    });
	
	jQuery('.next-link').bind('click', function() {
		var cindex = $(this).parent().parent().parent().attr('jcarouselindex');
		//cindex = cindex.substring(5);
		cindex = parseInt(cindex) + 1;
		$("#control-links a img").attr("src","/images/layout/control1.png");
		$("#control-links").find("li#c"+cindex+" a").children("img").attr("src","/images/layout/control2.png");
		//alert(cindex +"+"+ jcsize);
		if (cindex == (jcsize+1)) {
			carousel.scroll(1);
			$("#control-links").find("li#c1 a").children("img").attr("src","/images/layout/control2.png");
		} else {
        	carousel.next();
		}
        return false;
    });
	
};
