jQuery(document).ready(function() {
	
	jQuery('#recentPostBox a.close').click(function() {
		jQuery('#recentPostBox').fadeOut('fast');
		return false;
	});
			
	// open new window for rel="external"
	jQuery("a[href*='http://']:not([href*='"+location.hostname+"'])")
	.attr("target","_blank")
	.addClass("external");
	
	// function to append a close button to content window
	closeWin();
	
	if (jQuery('#content').is(':visible')) {
	jQuery('a#tweet').hide();
	}
	
	
	// latest tweet
	var ipod = {    
    sensitivity: 7, // number = sensitivity threshold (must be 1 or higher)    
    interval: 20, // number = milliseconds for onMouseOver polling interval    
    over: function()
		{
		// jQuery('#latestTweet').fadeIn('fast');
		jQuery('#latestTweet').animate(
			
			{
			opacity: 'show',
			right: '30px'
			},
			{
			queue: false,
			duration: '600'
			});
		
		},
    timeout: 4000, // number = milliseconds delay before onMouseOut    
    out: function(){
		// jQuery('#latestTweet').fadeOut('fast');
		
		jQuery('#latestTweet').animate(
			{
			opacity: 'hide',
			right: '21px'
			},
			{
			queue: false,
			duration: '600'
			});
		
		}   
	};
	jQuery('a#tweet').hoverIntent(ipod);
	jQuery('a.aktt_tweet_time').before('<br />');
	
	jQuery('#linkOverlay a, #featuredPics a').hover(function() {
	var title = jQuery(this).attr('title');
	jQuery('ul#siteNav a[title='+ title +']').addClass('hover');
	}, function() {
	jQuery('ul#siteNav a').removeClass('hover');
	});
	
	jQuery('#linkOverlay a, #featuredPics a').click(function() {
	var title = jQuery(this).attr('title');
	jQuery('ul#siteNav a').removeClass('active');
	jQuery('ul#siteNav a[title='+ title +']').addClass('active');
	});
	
	jQuery('ul#siteNav a').click(function() {
	jQuery('ul#siteNav a').removeClass('active');
	jQuery(this).addClass('active');
	});	

	// fancy box
	jQuery("a.fancybox").fancybox({
		speedIn: 600,
		speedOut: 200,
		overlayShow: true,
		overlayColor: '#110D0B',
		overlayOpacity: 1,
		autoScale: false,
		title: false
	});
	
	// mailing list
	jQuery('#follow li.subscribe a').click(function() {
	jQuery('#mail_chimp').append('<a href="#" class="close pngfix" title="close window">close window</a>');
			jQuery('#mail_chimp a.close').append(function(){
				jQuery(this).click(function() {
				jQuery('#mail_chimp').fadeOut('fast', function() {
				jQuery('#mail_chimp a.close').remove() });
				return false
				});
	});
	
											   
	jQuery('#mail_chimp').fadeIn('fast');									   
	});
	
	jQuery('#mc_signup_submit').click(function() {
	jQuery('#mail_chimp').show().delay(6000).fadeOut('slow');
	});


	// hover glow on heading 1 logo
	jQuery('#canvas div.wrap > h1 a').hover(function() {
	var hover_class = jQuery(this).attr('id');
	jQuery(this).before('<span class='+ hover_class +'></span>');
	jQuery(this).prev().fadeIn(300);
	}, function() {
	jQuery('#canvas div.wrap > h1').find('span').remove();
	});
	
	// hover glow on link overlay
	jQuery('#linkOverlay a').hover(function() {
	var hover_class = jQuery(this).attr('id');
	jQuery(this).before('<span class='+ hover_class +'></span>');
	jQuery(this).prev().fadeIn(300);
	}, function() {
	jQuery('#linkOverlay').find('span').remove();
	});
	
	// mixer hover add additional glow style for wall outlet
	jQuery('#linkOverlay a#musicLink2').hover(function() {
	var hover_class = jQuery(this).attr('id');
	jQuery(this).before('<span class="'+ hover_class +' alt"></span>');
	jQuery(this).prev().fadeIn(300);
	}, function() {

	});
		
	// hover glow states on featured pics
	jQuery('#featuredPics a').hover(function() {
	var hover_pic_class = jQuery(this).parent().attr('id');
	jQuery(this).parents('#featuredPics').prepend('<span class='+ hover_pic_class +'></span>');
	jQuery('#featuredPics span').fadeIn(300);
	}, function() {
	jQuery('#featuredPics').find('span').remove();
	});


	// contact form
	/* BEGIN TARGET FOR CONTACT FORM */
	var ocean = { target: '#alert1', beforeSubmit: showRequest, success: showResponse }; 
	jQuery('#oceanForm').ajaxForm(ocean);	  

}); /* END DOM READY */


// jw player flash vars
	function createPlayer(start) {
		
		var flashvars = {
		file: 'http://www.jniice.com/wp-content/themes/jniice/flash/jniice-flatscreen.flv',
		autostart: start,
		backcolor: 'B95BF0',
		frontcolor: '000000',
		lightcolor: '000000',
		screencolor: '000000',
		stretching: 'fill',
		controlbar: 'none',
		repeat: 'single',
		displayclick: 'link',
		linktarget: '_self',
		link: 'http://www.jniice.com/videos/'
		};
	
		var params = {
		allowfullscreen: 'true',
		allowscriptaccess: "always",
		wmode: "opaque",
		menu: 'false'
		};
	
		var attributes = {
			id: 'flash',
			name: 'flash'
		};
		
		swfobject.embedSWF("http://www.jniice.com/wp-content/themes/jniice/flash/player.swf", "jvid", "270", "138", "9.0.0", "flash/expressInstall.swf", flashvars, params, attributes);
		player = document.getElementById('flash');
		
		}



function showRequest(formData, jqForm, ocean) { 
var queryString = jQuery.param(formData);
return true; }
/* END TARGET FOR CONTACT FORM */

/* FUNCTION TO CLEAR FORM AFTER SUBMISSION */ 
function showResponse(responseText, statusText) { } 
jQuery.fn.clearForm = function() {
  return this.each(function() {
	var type = this.type, tag = this.tagName.toLowerCase();
	if (tag == 'form')
	  return jQuery(':input',this).clearForm();
	if (type == 'text' || type == 'password' || tag == 'textarea')
	  this.value = '';
	else if (type == 'checkbox' || type == 'radio')
	  this.checked = false;
	else if (tag == 'select')
	  this.selectedIndex = -1;
  });
};

	// music player
	function music(music_id,music_file) {
	jQuery("#song"+ music_id).jPlayer({
		ready: function() {
		this.element.jPlayer("setFile", music_file);
		},
		swfPath: "http://www.jniice.com/wp-content/themes/jniice/js",
		volume: 100,
		oggSupport: false,
		nativeSupport: true,
		customCssIds: true,
		errorAlerts: false,
		bgcolor: "#000000"
	})
	.jPlayer("onProgressChange", function(loadPercent, playedPercentRelative, playedPercentAbsolute, playedTime, totalTime) {
	jQuery("#time"+ music_id).text(jQuery.jPlayer.convertTime(playedTime));
	})
	.jPlayer("cssId", "play", "play"+ music_id)
	.jPlayer("cssId", "pause", "pause"+ music_id)
	.jPlayer("cssId", "stop", "stop"+ music_id)
	.jPlayer("cssId", "loadBar", "loadBar"+ music_id)
	.jPlayer("cssId", "playBar", "playBar"+ music_id);
}

	// close window
	function closeWin() {
	jQuery('#content').append('<a href="#" class="close pngfix" title="close window">close window</a>');
			jQuery('#content a.close').append(function(){
				jQuery(this).click(function() {
				jQuery('#content').fadeOut();
				jQuery('ul#siteNav a').removeClass('active');
				jQuery('a#tweet').show();
				return false
				});
			});
	}

