jQuery(document).ready(function(){
	/*
	$("#accordion").accordion({
		fillSpace: true,
		change: function(event, ui) { 
			Cufon.replace('#accordion h3');
		}
	});
	*/
	
	Cufon.replace('.klavReg, h1, h2, .home .half h2', {
		fontFamily: 'KlavReg',
		hover: true
	});
	Cufon.replace('.klavRegCaps, .content h2', {
		fontFamily: 'klavRegCaps',
		hover: true
	});
	Cufon.replace('.klavMed, .sendForm', {
		fontFamily: 'klavMed',
		hover: true
	});
	Cufon.replace('.home .half h2', {
		fontFamily: 'KlavReg',
		hover: true
	});
	
	$('.kwicks').kwicks({
        max : 710,
		duration: 200
    });
	/*
	$('.slide').mouseenter(function(){
		$(this).children('h1, h2').fadeOut('slow');
		$(this).children('a').addClass('play');
	}).mouseleave(function(){
		$(this).children('h1, h2').fadeIn('fast');
		$(this).children('a').removeClass('play');
	});
	
	
	*/
	var vid1 = '<object width="710" height="400" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param value="http://gn/wp-content/themes/cmi/video/distributionLrg.swf" name="movie"><param value="transparent" name="wmode"><embed width="710" height="400" wmode="transparent" type="application/x-shockwave-flash" src="http://www.cmiamerica.com/wp-content/themes/cmi/video/distributionLrg.swf"></object>';
	var vid2 = '<object width="710" height="400" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param value="http://gn/wp-content/themes/cmi/video/supplyLrg.swf" name="movie"><param value="transparent" name="wmode"><embed width="710" height="400" wmode="transparent" type="application/x-shockwave-flash" src="http://www.cmiamerica.com/wp-content/themes/cmi/video/supplyLrg.swf"></object>';
	var vid3 = '<object width="710" height="400" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"><param value="http://gn/wp-content/themes/cmi/video/storageLrg.swf" name="movie"><param value="transparent" name="wmode"><embed width="710" height="400" wmode="transparent" type="application/x-shockwave-flash" src="http://www.cmiamerica.com/wp-content/themes/cmi/video/storageLrg.swf"></object>';
	
	$('.slide1 a').click(function(){
		$('.needs').hide();
		$('.playerSlides .slide1').html(vid1);
		$('.playerSlides').addClass('slideOneOpen').show();
		$('.playerSlides .slide2, .playerSlides .slide3').click(function(){
			$('.playerSlides .slide1').html('');
			$('.playerSlides').removeClass('slideOneOpen').hide();
			$('.needs').show();
		});
		$('.playerSlides .slide1').unbind('click');
		return false;
	}).mouseenter(function(){
		$(this).addClass('play');
		$('.needs').stop().animate({
			left: '20px'				
		});
	}).mouseleave(function(){
		$(this).removeClass('play');
	});
	
	$('.slide2 a').click(function(){
		$('.needs').hide();
		$('.playerSlides .slide2').html(vid2);
		$('.playerSlides').addClass('slideTwoOpen').show();
		$('.playerSlides .slide1, .playerSlides .slide3').click(function(){
			$('.playerSlides .slide2').html('');
			$('.playerSlides').removeClass('slideTwoOpen').hide();
			$('.needs').show();
		});
		$('.playerSlides .slide2').unbind('click');
		return false;
	}).mouseenter(function(){
		$(this).addClass('play');
		$('.needs').stop().animate({
			left: '152px'				
		});
	}).mouseleave(function(){
		$(this).removeClass('play');
	});
	
	$('.slide3 a').click(function(){
		$('.needs').hide();
		$('.playerSlides .slide3').html(vid3);
		$('.playerSlides').addClass('slideThreeOpen').show();
		$('.playerSlides .slide1, .playerSlides .slide2').click(function(){
			$('.playerSlides .slide3').html('');
			$('.playerSlides').removeClass('slideThreeOpen').hide();
			$('.needs').show();
		});
		$('.playerSlides .slide3').unbind('click');
		return false;
	}).mouseenter(function(){
		$(this).addClass('play');
		$('.needs').stop().animate({
			left: '284px'				
		});
	}).mouseleave(function(){
		$(this).removeClass('play');
	});
	$('.kwicks').mouseenter(function(){
		if($.browser.msie && $.browser.version < 8){
			//do other stuff
			return;
		}else{
			$('.slide h1, .slide h2').stop().fadeOut(function(){ $(this).css({display: 'none'}) });	
		}
	}).mouseleave(function(){
		if($.browser.msie && $.browser.version < 8){
			//do other stuff
			return;
		}else{
			$('.slide h1, .slide h2').stop().fadeIn(function(){ $(this).css({opacity: '1'}) });
		}
		$('.needs').stop().animate({
			left: '20px'				
		});
	});
	
	$('.item').mouseenter(function(){
		$(this).addClass('active');
		$('.dropdown',this).show();
	}).mouseleave(function(){
		$(this).removeClass('active');
		$('.dropdown',this).hide();
		Cufon.replace('.menu .item a.klavReg',{
			fontFamily: 'klavReg',
			hover: true
		});
	}).click(function(){
		$(this).removeClass('active');
		$('.dropdown',this).hide();
	});
	
	var name = $('.uname');
	name.focus(function(){
		if(name.val() == 'username'){
			name.val('');
		}
	}).blur(function(){
		if(name.val() == ''){
			name.val('username');
		}
	});
	var email = $('.pword');
	email.focus(function(){
		if(email.val() == 'password'){
			email.val('');
		}
	}).blur(function(){
		if(email.val() == ''){
			email.val('password');
		}
	});
	$('hr').attr('size', "1");
	
	$('.video').fancybox({
		'padding'			: 10,
		'autoScale'			: false,
		'width'				: 640,
		'height'			: 360,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	$('.video2').fancybox({
		'padding'			: 10,
		'autoScale'			: false,
		'width'				: 480,
		'height'			: 360,
		'transitionIn'		: 'fade',
		'transitionOut'		: 'fade'
	});
	$('#showMore1').click(function(){
		$('#more1').slideDown();
		$('#showMore1').fadeOut();
		return false;
	});
});

