/*================================*/
/*=== Free-Resource Btn Script ===*/
/*================================*/

function fadeThemIn(){
	$('#homeFree').children('div').fadeIn('slow',function(){fadeThemOut();});
};
function fadeThemOut(){
	$('#homeFree').children('div').fadeOut('slow',function(){fadeThemIn();});
};
$(document).ready(function(){
	fadeThemIn();
});

/*==============*/
/*=== Banner ===*/
/*==============*/

jQuery(function(){

$(".main_image .desc").show(); //Show Banner
$(".main_image .block").animate({ opacity: 0.85 }, 1 ); //Set Opacity
$(".image_thumb ul li:first").addClass('active'); //Add the active class (highlights the very first list item by default)

//runs function on click
$(".image_thumb ul li").click(function () {
$active = $(this);
slideSwitchClick();
})
.hover(function(){ //Hover effects on list-item
$(this).addClass('hover'); //Add class �hover� on hover
}, function() {
$(this).removeClass('hover'); //Remove class �hover� on hover out
});

//runs function, set timer here
$(function() {
//setInterval( �slideSwitchTimed()�, 6000 );
playSlideshow = setInterval( "slideSwitchTimed()", 6000 );
});

//pauses on hover
$('.homeBanner').hover(function() {
clearInterval(playSlideshow);
},
function() {
playSlideshow = setInterval( "slideSwitchTimed()", 6000 );
});

});

function slideSwitchTimed() {
$active = $('.image_thumb ul li.active').next();
if ( $active.length == 0 ) $active = $('.image_thumb ul li:first'); //goes back to start when finishes
slideSwitch();
}

function slideSwitchClick() {
slideSwitch();
}

function slideSwitch() {
var $prev = $('.image_thumb ul li.active');

//Show active list-item
$prev.removeClass('active');
$active.addClass('active');

//Set Variables
var imgAlt = $active.find('img').attr("alt"); //Get Alt Tag of Image
var imgTitle = $active.find('a').attr("href"); //Get Main Image URL
var imgDesc = $active.find('.block').html(); //Get HTML of the �block� container
var imgDescHeight = $(".main_image").find('.block').height(); //Find the height of the �block�

if ($(this).is(".active")) { //If the list item is active/selected, then�
return false; // Don�t click through � Prevents repetitive animations on active/selected list-item
} else { //If not active then�
//Animate the Description
$(".main_image img").animate({ opacity: 0}, 250 );
$(".main_image .block").animate({ opacity: 0, marginBottom: -imgDescHeight }, 250 , function() {
$(".main_image .block").html(imgDesc).animate({ opacity: 0.85, marginBottom: "0" }, 250 );
$(".main_image img").attr({ src: imgTitle , alt: imgAlt}).animate({ opacity: 1}, 250 );
});
}
return false;
}

/*================*/
/*=== Fancybox ===*/
/*================*/

		$(document).ready(function() {
				
			$(".various3").fancybox({
				'padding'			: 15,					
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
			
			$("#details1").fancybox({
				'padding'			: 15,					
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
			
			
			$("#details2").fancybox({
				'padding'			: 15,					
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
			
			
			$("#details4").fancybox({
				'padding'			: 15,					
				'width'				: '75%',
				'height'			: '75%',
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});
			
			$(".youtube").fancybox({
				'padding'			: 0,
				'width'				: 640,
				'height'			: 390,
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe',
				'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			});
			
			$("#details3,#details6").fancybox({
				'padding'			: 0,
				'width'				: 640,
				'height'			: 390,
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe',
				'wmode'				: 'transparent',
				'allowfullscreen'	: 'true'
			});
			
			$(".details7").fancybox({
				'padding'			: 0,
				'width'				: 450,
				'height'			: 460,
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe',
				'wmode'				: 'transparent'
			});
			
			$(".gallery").fancybox({
				'padding'			: 0,					
				'width'				: 575,
				'height'			: 650,
				'autoScale'			: false,
				'transitionIn'		: 'elastic',
				'transitionOut'		: 'elastic',
				'type'				: 'iframe'
			});

	});

/*=================*/
/*=== Slideshow ===*/
/*=================*/

$(window).load(function() {
    $('#slider').nivoSlider({
        effect:'slideInLeft', //Specify sets like: 'random,sliceDown,sliceDownLeft,sliceUp,sliceUpLeft,sliceUpDown,sliceUpDownLeft,fold,fade,random,slideInRight,slideInLeft'
        slices:15,
        animSpeed:500, //Slide transition speed
        pauseTime:3000,
        startSlide:0, //Set starting Slide (0 index)
        directionNav:true, //Next & Prev
        directionNavHide:true, //Only show on hover
        controlNav:true, //1,2,3...
        controlNavThumbs:true, //Use thumbnails for Control Nav
        controlNavThumbsFromRel:false, //Use image rel for thumbs
        controlNavThumbsSearch: '.jpg', //Replace this with...
        controlNavThumbsReplace: '.jpg', //...this in thumb Image src
        keyboardNav:false, //Use left & right arrows
        pauseOnHover:true, //Stop animation while hovering
        manualAdvance:false, //Force manual transitions
        captionOpacity:0.8, //Universal caption opacity
        beforeChange: function(){},
        afterChange: function(){},
        slideshowEnd: function(){}, //Triggers after all slides have been shown
        lastSlide: function(){}, //Triggers when last slide is shown
        afterLoad: function(){} //Triggers when slider has loaded
    });
});

/*===============================*/
/*=== Pocket Poster Slideshow ===*/
/*===============================*/

jQuery(document).ready(function(){
	jQuery('#slideshow').fadeSlideShow({
	PlayPauseElement: false,
	NextElement: false,
	PrevElement: false,
	ListElement: false
});
});

/*===============*/
/*=== Twitter ===*/
/*===============*/

$(document).ready(function(){
	getTwitters('tweet', { 
	id: 'KrisATDaydream', 
	count: 2, 
	enableLinks: true, 
	ignoreReplies: true, 
	clearContents: true,
	template: '"%text%" <a href="http://twitter.com/%user_screen_name%/status/%id%/">%time%</a>'
});
});

/*=================*/
/*=== Window Script ===*/
/*=================*/

function wopen(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=no, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

/*===========================*/
/*=== Window With Scroll Bar Script ===*/
/*===========================*/

function wopenscroll(url, name, w, h)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    name,
    'width=' + w + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=no');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}

/*====================*/
/*=== Partners Page Script ===*/
/*====================*/

$(document).ready(function() {
  	$.viewMap = {
    	'0' : $([]),
    	'view1' : $('#view1'),
    	'view2' : $('#view2'),
    	'view3' : $('#view3'),
    	'view4' : $('#view4'),
    	'view5' : $('#view5'),
    	'view6' : $('#view6'),
    	'view7' : $('#view7'),
    	'view8' : $('#view8'),
    	'view9' : $('#view9'),
    	'view10' : $('#view10'),
    	'view11' : $('#view11'),
    	'view12' : $('#view12'),
    	'view13' : $('#view13'),
    	'view14' : $('#view14'),
    	'view15' : $('#view15'),
    	'view16' : $('#view16'),
    	'view17' : $('#view17'),
    	'view18' : $('#view18'),
    	'view19' : $('#view19'),
    	'view20' : $('#view20'),
    	'view21' : $('#view21'),
    	'view22' : $('#view22'),
    	'view23' : $('#view23'),
    	'view24' : $('#view24'),
    	'view25' : $('#view25'),
    	'view26' : $('#view26'),
    	'view27' : $('#view27'),
    	'view28' : $('#view28'),
    	'view29' : $('#view29'),
    	'view30' : $('#view30'),
    	'view31' : $('#view31'),
		'view32' : $('#view32'),
		'view33' : $('#view33'),
		'view34' : $('#view34'),
		'view35' : $('#view35'),
		'view36' : $('#view36'),
    	'view37' : $('#view37'),
    	'view38' : $('#view38'),
    	'view39' : $('#view39'),
    	'view40' : $('#view40'),
    	'view41' : $('#view41'),
    	'view42' : $('#view42'),
    	'view43' : $('#view43'),
    	'view44' : $('#view44'),
    	'view45' : $('#view45'),
    	'view46' : $('#view46'),
    	'view47' : $('#view47'),
    	'view48' : $('#view48'),
    	'view49' : $('#view49'),
    	'view50' : $('#view50'),
    	'details1' : $('#details1'),
    	'details2' : $('#details2'),
    	'details3' : $('#details3')
  };

  $('#viewSelector,#viewSelector2').change(function() {
    // hide all
    $.each($.viewMap, function() { this.slideUp(); });
    // show current
    $.viewMap[$(this).val()].slideDown();
  });
});
