$( document ).ready( function() {

$("body").addClass("jscript");	
h1class();
extLinks();
swapVid();

$("#contactForm").validate();

$('#slideShow').cycle({ 
    fx:     'fade', 
    speed:  'fast', 
    timeout: 0, 
    pager:  '#slideShowNav', 
    pagerAnchorBuilder: function(idx, slide) { 
        // return selector string for existing anchor 
        return '#slideShowNav li:eq(' + idx + ') a'; 
    } 
});

// slideshow type two
$('.galleryLoop').cycle('fade');


var firstclip=$("#youtubeThumbsContainer:first img").attr("id");
var firstclipTitle=$("#youtubeThumbsContainer:first img").attr("alt");

$("#youtubeDisplay").append("<h3>"+firstclipTitle+"</h3><object width=\"438\" height=\"368\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+firstclip+"&rel=1\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/"+firstclip+"&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"438\" height=\"368\"></embed></object>");




$("#youtubeThumbsContainer img").click(function(){
var youtubeID=$(this).attr("id");
var youtubeIDTitle=$(this).attr("alt");
$("#youtubeDisplay").empty();
$("#youtubeDisplay").append("<h3>"+youtubeIDTitle+"</h3><object width=\"438\" height=\"368\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+youtubeID+"&rel=1\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/"+youtubeID+"&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"438\" height=\"368\"></embed></object>");
return false;
});

//$('#stars').pulse({
 //   speed: 900,
 //   opacityRange: [0.4,0.9,0.2,0.6,0.5]
//});

//$('a.blink').pulse({
 //   backgroundColors: ['red','indigo']
 //   });


});
 
 




// swap video
function swapVid() {
$("a.swapVideo").click(function(){
var youtubeID=$(this).attr("id");
$("#swap").html("<object width=\"332\" height=\"262\"><param name=\"movie\" value=\"http://www.youtube.com/v/"+youtubeID+"&rel=1\"></param><param name=\"wmode\" value=\"transparent\"></param><embed src=\"http://www.youtube.com/v/"+youtubeID+"&rel=1\" type=\"application/x-shockwave-flash\" wmode=\"transparent\" width=\"332\" height=\"262\"></embed></object>");
return false;
});
};


// external links
function extLinks() {

	$( "a[@rel='external']" ).click( function(){
		window.open( this.href );
		return false;
	});
	
};

function h1class() {
var htmlStr = $("div.h1 h1").html();
$("div.h1 h1").addClass( htmlStr.toLowerCase() );
}

